Received: from sss.sss.pgh.pa.us (sss.pgh.pa.us [209.114.166.2]) by hub.org (8.9.3/8.9.3) with ESMTP id KAA94679 for ; Tue, 13 Jul 1999 10:09:44 -0400 (EDT) (envelope-from tgl@sss.pgh.pa.us) Received: from sss.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.sss.pgh.pa.us (8.9.1/8.9.1) with ESMTP id KAA22438; Tue, 13 Jul 1999 10:08:21 -0400 (EDT) To: Patrik Kudo cc: pgsql-sql@postgreSQL.org Subject: Re: [SQL] "quoting" column names In-reply-to: Your message of Tue, 13 Jul 1999 14:15:40 +0200 <378B2DEC.84B1514A@partitur.se> Date: Tue, 13 Jul 1999 10:08:21 -0400 Message-ID: <22436.931874901@sss.pgh.pa.us> From: Tom Lane 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. > 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?) 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. regards, tom lane