问题
I have the field 'limit' in a table in my postgres database. I run psql and I can't select, update, change this field because is a reserved word in postgresql. There is a way to manage this field?
serene-retreat::SILVER=> select limit from companies;
ERROR: syntax error at or near "limit"
LINE 1: select limit from companies;
回答1:
In SQL reserved (key)words need to be quoted using double quotes:
select "limit"
from companies;
Note that this also makes column case-sensitive: "LIMIT"
is a different name than "limit"
.
This all explained in the manual:
http://www.postgresql.org/docs/current/static/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS
回答2:
use this
select [limit] from companies;
or
select companies.[limit] from companies;
来源:https://stackoverflow.com/questions/29053168/how-to-select-the-reserved-word-limit-in-postgres