PostgreSQL — column names of a table are case-sensitive

All identifiers (including column names) that are not double-quoted are converted to lower case in PostgreSQL. Column names that were created with double-quotes and thereby retained upper-case letters (and/or other syntax violations) have to be double-quoted for the rest of their life. So, PostgreSQL column names are case-sensitive:

SELECT * FROM people WHERE "first_Name" = 'xyz';

Note that 'xyz' does not need to be double-quoted. Values (string literals) are enclosed in single quotes.

If you try to do this query ( first_Name is a column in the table people

SELECT * FROM people WHERE first_Name='xyz';

And you will meet this error

ERROR: column “first_Name” does not exist

 

Advice is to use legal, lower-case names exclusively so double-quoting is not needed.

 

(Thanks, Scott, for some hints.)

 

References:

http://stackoverflow.com/questions/20878932/are-postgresql-column-names-case-sensitive

1 thought on “PostgreSQL — column names of a table are case-sensitive”

Leave a Reply

Your email address will not be published. Required fields are marked *