Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

Postgres 9.3.2 on heroku.

Pretty sure I'm just being an idiot, but I can't seem to figure out why my syntax is wrong.

db=> \dt
              List of relations
 Schema |    Name    | Type  |     Owner      
--------+------------+-------+----------------
 public | device     | table | admin
 public | post       | table | admin
 public | user       | table | admin
(3 rows)

// why does this fail?
db=> drop table user; 
ERROR:  syntax error at or near "user"
LINE 1: drop table user;

// does the right thing
db=> drop table error; 
ERROR:  table "error" does not exist
share|improve this question
add comment

1 Answer 1

up vote 2 down vote accepted

User is a reserved keyword in Postgres. You'll have to put it in quotes if you want to refer to an actual table named user:

DROP TABLE "user";

Probably best to stay away from using reserved keywords as table names if you can help it. It usually ends up creating weird problems down the road. Users might be a better name for a table.

share|improve this answer
    
Thanks. Did not know that. Will accept in 12 minutes. –  Derek Jan 10 at 18:21
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.