作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
heroku 上的 Postgres 9.3.2。
很确定我只是个白痴,但我似乎无法弄清楚为什么我的语法是错误的。
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
最佳答案
用户
是 reserved keyword在 Postgres 中。如果你想引用名为 user 的实际表,你必须将它放在引号中:
DROP TABLE "用户";
如果可以的话,最好不要使用保留关键字作为表名。它通常最终会在路上产生奇怪的问题。 Users
可能是一个更好的表格名称。
关于sql - Postgres 删除表语法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21051521/
我是一名优秀的程序员,十分优秀!