Re: double quotes around table and column names

Поиск
Список
Период
Сортировка
От Mike Mascari
Тема Re: double quotes around table and column names
Дата
Msg-id 3DDC964D.9070405@mascari.com
обсуждение исходный текст
Ответ на double quotes around table and column names  ("Thomas T. Thai" <tom@minnesota.com>)
Список pgsql-general
Thomas T. Thai wrote:
> What is the suggested way of using double quotes around table and column
> names? Is there a standard or suggested usage?

I would avoid using double quotes entirely, if possible. If you
use double quotes on mixed-case table and column names, you must
be sure to always use double quotes. I'd use all lowercase,
unquoted names. Unquoted names get folded into lowercase, so
even if you quoted the lowercase name, the queries would still work:

Examples:

---- QUOTED NAMES ----

 > CREATE TABLE "Foo" ("Key" integer);
CREATE
 > SELECT * FROM Foo;
ERROR:  Relation "foo" does not exist
 > SELECT * FROM "Foo";
  key
-----
(0 rows)

---- UNQUOTED NAMES ----

 > CREATE TABLE Foo (Key integer);
CREATE
 > SELECT * FROM Foo;
  key
-----
(0 rows)

 > SELECT * FROM foo;
  key
-----
(0 rows)

 > SELECT * FROM "Foo";
ERROR:  Relation "Foo" does not exist
 > SELECT * FROM "foo";
  key
-----
(0 rows)

So you might as well be consistent and do a:

CREATE TABLE foo (key integer);

Hope that helps,

Mike Mascari
mascarm@mascari.com




В списке pgsql-general по дате отправления:

Предыдущее
От: Christoph Dalitz
Дата:
Сообщение: Re: is the sqlca.sqlabc value unique for each response type
Следующее
От: "Erwan DUROSELLE"
Дата:
Сообщение: Rép. : double quotes around table and column names