Re: SQL: Are the "" around table & coloumnames necessary?

From: Oliver Elphick <olly(at)lfix(dot)co(dot)uk>
To: Mikey <mikey(dot)unsafe(at)gmx(dot)net>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: SQL: Are the "" around table & coloumnames necessary?
Date: 2002-02-21 21:39:25
Message-ID: 1014327565.3217.862.camel@linda
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Mon, 2002-02-18 at 12:43, Mikey wrote:
> Hello,
>
> when I write a select for example,
> it doesn't work this way:
>
> select col1, col2
> from my_table;
>
> instead of that I have to write
>
> select "col1", "col2"
> from "my_table";
>
> I dont understand this...is there a way to use
> the more comfortable form without "" ?

The two queries you show are identical. However, if any of the column
names contain upper-case characters and were enclosed in double-quotes
when the table was created, you will get the behaviour you are
complaining about, because all unquoted identifiers are folded to
lower-case before the query is executed.

The solution is not to use upper-case characters in identifiers.
If you already have tables with upper-case names, drop them and recreate
them (or do pg_dumpall, edit the dump file and reload the database).

--
Oliver Elphick Oliver(dot)Elphick(at)lfix(dot)co(dot)uk
Isle of Wight http://www.lfix.co.uk/oliver
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839 932A 614D 4C34 3E1D 0C1C

"My sheep hear my voice, and I know them, and they
follow me; And I give unto them eternal life; and they
shall never perish, neither shall any man pluck them
out of my hand." John 10:27,28

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Jean-Luc Lachance 2002-02-21 21:55:04 Re: maximum of sums
Previous Message Jie Liang 2002-02-21 21:21:45 Re: all tables in a DB\?