PostgreSQL CREATE TABLE error

postgresql

I'm new in PostgreSQL. I try to create table in database. In psql i write:

CREATE TABLE mail_user (
   user char(50) NOT NULL,
   domain char(50) NOT NULL,
   password char(50) NOT NULL
);

But i get error:

ERROR: syntax error at or near "user"
LINE 2: user char(50) NOT NULL,
^

What's wrong? How can i fix it?

Thank you.

Best Answer

You can use reserved words by quoting them:

CREATE TABLE mail_user (
   "user" char(50) NOT NULL,
   domain char(50) NOT NULL,
   password char(50) NOT NULL
);