Postgres drop table syntax error

后端 未结 2 1591
长发绾君心
长发绾君心 2020-12-18 19:37

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
              Li         


        
相关标签:
2条回答
  • 2020-12-18 20:33

    I had the same error. My database name was very unique and not a reserved keyword. Still needed to wrap the database name with quotation marks

    "<database_name>"

    Also for those that might forget always add a semicolon ; at the end of the statement, I always forget.

    0 讨论(0)
  • 2020-12-18 20:34

    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.

    0 讨论(0)
提交回复
热议问题