Last Updated: February 25, 2016
·
793
· arn-e

PostgreSQL 'user' keyword

This is a little situational, but it's worth knowing that PostgresSQL considers 'user' to be a reserved word.

That is to say, take the following hypothetical table :

my_table

id

user

address

While a "select * from my_table" will return the expected values, attempting to select the "user" column directly will not, and return a different value entirely :

select user from my_table

current_user

abcdefghijklmnop

The valued returned is the current_user, which is also typically the same as the session user.

The actual "user" column can in fact be accessed directly using dot notation (e.g. "select mytable.user from mytable"), however if using some kind of ORM on top of PostgreSQL this may not be particularly feasible or easy to configure.