我的postgres数据库的表格中有字段"limit"。我运行 psql,但我无法选择、更新、更改此字段,因为是 postgresql 中的保留字。有没有办法管理这个字段?
serene-retreat::SILVER=> select limit from companies;
ERROR: syntax error at or near "limit"
LINE 1: select limit from companies;
在SQL中,保留(键)字需要使用双引号括起来:
select "limit"
from companies;
请注意,这也会使列区分大小写:"LIMIT"
的名称与"limit"
不同。
这一切都在手册中解释:
http://www.postgresql.org/docs/current/static/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS
使用这个
select [limit] from companies;
或
select companies.[limit] from companies;