为什么 group 在 postgres 中是一个错误的别名 + Django 的 auth_group 表
为什么以下简单查询不起作用(在后端使用 Django),
# select group.name from auth_group as group;
ERROR: syntax error at or near "."
LINE 1: select group.name from auth_group as group;
而以下有效
# select groupd.name from auth_group as groupd;
name
---------------
FO Admin Role
admin
alice
bob
(4 rows)
使用 group
作为别名有什么问题?
Why is that the following simple query does not work (Using Django in the backend)
# select group.name from auth_group as group;
ERROR: syntax error at or near "."
LINE 1: select group.name from auth_group as group;
while the following works
# select groupd.name from auth_group as groupd;
name
---------------
FO Admin Role
admin
alice
bob
(4 rows)
What is wrong with using group
as an alias ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
group
是保留关键字 (group by
),因此不能用作常规标识符。您可以通过将其括在双引号中
作为“group”
来使用它,但我强烈建议使用其他名称。group
is a reserved keyword (group by
) and thus can't be used as a regular identifier.You could use it by enclosing it in double quotes
as "group"
but I strongly recommend to use some other name.