Re: Column does not exists?

From: Francisco Olarte <folarte(at)peoplecall(dot)com>
To: Leonardo M(dot) Ramé <l(dot)rame(at)griensu(dot)com>
Cc: PostgreSql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Column does not exists?
Date: 2015-03-26 17:23:23
Message-ID: CA+bJJbwKytxShnfJeO_WvDXrQNDQEUsC2kKNhXKzkm8sq8Ed4w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi Leonardo:

On Thu, Mar 26, 2015 at 6:12 PM, "Leonardo M. Ramé" <l(dot)rame(at)griensu(dot)com> wrote:
> DELETE From sessions WHERE SESSIONTIMESTAMP < '2010-01-01 10:02:02'
> ERROR: column "sessiontimestamp" does not exist
> LINE 1: DELETE From sessions WHERE SESSIONTIMESTAMP < '2010-01-01 10...
...
> DELETE From sessions WHERE "SESSIONTIMESTAMP" < '2010-01-01 10:02:02'
>
> It DOES work.
>
> Why the db doesn't recognize the name of the table without quotes?.

Unquoted identifiers for several things, column names amongst them,
are treated by case folding in SQL. Many DBs do it to uppercase,
postgres does it to lower case ( as hinted by the column name being
printed in lowercase ). So if you QUOTE an UPPERCASE name you must
quote it always.

As a rule of thumb, I'll recommend quoting your identifiers always or
never, quoting it in some statements ( create ) and not others ( 1st
delete ) will normally surprise you on unpleasant ways.

Francisco Olarte.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2015-03-26 17:24:39 Re: Column does not exists?
Previous Message Leonardo M. Ramé 2015-03-26 17:21:48 Re: Column does not exists?