3 ms·
In psql: wiredfool=> select * from user; user ----------- wiredfool (1 row) Rule 0, Don't name tables with reserved words.
by wiredfool 3y ago
In psql:
wiredfool=> select * from user;
user
-----------
wiredfool
(1 row)
Rule 0, Don't name tables with reserved words.
- jstx1 3y agoThere's many keywords that make good column names though - user, id, name, date, version, timestamp.
- wiredfool 3y agoOf those, user is the only one that must be quoted in postgresql. It doesn't show up that way in psql through, so it's a bit inconsistent. test=# create table test ( id serial, "user" text, date text, timestamp text, name text, version text); CREATE TABLE Then again, lots of things are actually valid column identifiers, if they're quoted. test=# alter table test add column "select" text; ALTER TABLE test=# alter table test add column "*" text; ALTER TABLE test=# alter table test add column "from" text; ALTER TABLE test=# select "select", "*", "from" from test; select | * | from --------+---+------ (0 rows) test=# \d test Table "public.test" Column | Type | Collation | Nullable | Default -----------+---------+-----------+----------+---------------------------------- id | integer | | not null | nextval('test_id_seq'::regclass) user | text | | | date | text | | | timestamp | text | | | name | text | | | version | text | | | select | text | | | * | text | | | from | text | | |
- noelbautista91 3y agoThis is why one should go with `$APP_User` or append `$APP` to generic sounding classes/tables. It's a slight inconvenience. Or maybe get into the habit of wrapping your table/column names with backticks to tell the query language of choice that you're not referring about the keyword.