1

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;
Papaya Labs
  • 1,069
  • 8
  • 11

2 Answers2

5

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

a_horse_with_no_name
  • 497,550
  • 91
  • 775
  • 843
0

use this

select [limit] from companies;

or

select companies.[limit] from companies;
Faisal Hameed
  • 104
  • 1
  • 9