Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

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.

share|improve this question
add comment

2 Answers 2

up vote 2 down vote accepted

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
);
share|improve this answer
    
And don't forget to use quotes in every query you execute on this table, "user" will always be a reserved word. –  Frank Heikens Feb 28 '11 at 8:58
add comment

"user" is a reserved word. You may want to try "username" instead. http://www.postgresql.org/docs/8.3/static/sql-keywords-appendix.html

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.