Sql Postgres删除表语法错误
希罗库的Postgres 9.3.2 我很确定我只是个白痴,但我似乎不明白为什么我的语法是错误的Sql Postgres删除表语法错误,sql,postgresql,heroku,Sql,Postgresql,Heroku,希罗库的Postgres 9.3.2 我很确定我只是个白痴,但我似乎不明白为什么我的语法是错误的 db=> \dt List of relations Schema | Name | Type | Owner --------+------------+-------+---------------- public | device | table | admin public | post | tab
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
用户
是Postgres中的一员。如果要引用名为user:
删除表“用户”代码>
如果可以的话,最好不要使用保留关键字作为表名。它通常会在接下来的过程中产生奇怪的问题Users
可能是表的更好名称。我也有同样的错误。我的数据库名称非常独特,不是一个保留关键字
。仍然需要用引号将数据库名称括起来
”
对于那些可能忘记的人,请始终添加分号代码>在语句末尾,我总是忘记