Re: Special table names
От | Tom Lane |
---|---|
Тема | Re: Special table names |
Дата | |
Msg-id | 813.1267207337@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | Re: Special table names (Marcin Krol <mrkafk@gmail.com>) |
Список | pgsql-novice |
Marcin Krol <mrkafk@gmail.com> writes: > Michael Wood wrote: >> It seems SQLAlchemy lied to you about creating the table, or perhaps >> you did not check an error code or something. >> >> blah=> create table user (id int); >> ERROR: syntax error at or near "user" >> LINE 1: create table user (id int); > Apparently it did lie, bc I was able to write objects to that table > without problems IIRC. It's fairly likely that what SQLAlchemy actually did was to double-quote "user" in the commands it issued for you. Observe: regression=# create table user (id int); ERROR: syntax error at or near "user" LINE 1: create table user (id int); ^ regression=# create table "user" (id int); CREATE TABLE regression=# select * from user; current_user -------------- postgres (1 row) regression=# select * from "user"; id ---- (0 rows) Without quotes, user is a reserved word that selects a SQL-standard function. With quotes, it's just an identifier that you can use to name a table if you choose. regards, tom lane
В списке pgsql-novice по дате отправления: