Received: from bastuba.partitur.se (bastuba.partitur.se [193.219.246.194]) by hub.org (8.9.3/8.9.3) with ESMTP id KAA97686 for ; Tue, 13 Jul 1999 10:20:15 -0400 (EDT) (envelope-from kudo@partitur.se) Received: from partitur.se (tb303.partitur.se [193.219.246.230]) by bastuba.partitur.se (8.8.8/8.8.8) with ESMTP id QAA27823; Tue, 13 Jul 1999 16:19:23 +0200 (CEST) (envelope-from kudo@partitur.se) Sender: kudo@partitur.se Message-ID: <378B4AEB.60D6B07F@partitur.se> Date: Tue, 13 Jul 1999 16:19:23 +0200 From: Patrik Kudo Organization: Partitur Informationsteknik X-Mailer: Mozilla 4.51 [en] (X11; I; FreeBSD 3.2-STABLE i386) X-Accept-Language: sv,en MIME-Version: 1.0 To: Tom Lane CC: pgsql-sql@postgreSQL.org Subject: Re: [SQL] "quoting" column names References: <22436.931874901@sss.pgh.pa.us> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Tom Lane wrote: > > Patrik Kudo writes: > > create table login (userid text, when datetime); > > select when from login where userid = 'xxxx'; > > In 6.5 I have to do: > > select "when" from login where userid = 'xxxx'; > > Right ... WHEN is a keyword in CASE expressions, which didn't use to > be implemented but are now. Ah! that explains that part... > > My question now is, should I always quote column names, just in case, > > or should I only quote column names that are "almost reserved"? > > In theory you should only have to worry about keywords that are > reserved in SQL92 but that Postgres hasn't gotten around to implementing > yet. That's a fairly short list, I think, but I do not have the > details handy. (Anyone?) The list of reserved keywords can be found at: http://www.postgresql.org/ -> Info Central -> Documentation -> User's Guide -> SQL Syntax -> Key Words. That list doesn't say which need to be quoted though. > Quoting every column name in sight would make your SQL pretty unreadable > (pg_dump now does it by default ... try reading pg_dump commands :-(). > Also, if you have a reserved word as a column name, you won't be able > to access the table at all using tools that don't quote column names. > Better to rename your columns if you get burnt by this. Will do, will do... /Kudo