Re: Column does not exists?

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: "Leonardo M(dot) Ramé" <l(dot)rame(at)griensu(dot)com>, PostgreSql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Column does not exists?
Date: 2015-03-26 17:24:39
Message-ID: 551440D7.7020305@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 03/26/2015 10:21 AM, "Leonardo M. Ramé" wrote:
>
> El 26/03/15 a las 14:18, Adrian Klaver escibió:
>> On 03/26/2015 10:12 AM, "Leonardo M. Ramé" wrote:
>>> Ok, I have this table:
>>>
>>> CREATE TABLE sessions
>>> (
>>> "SESSIONID" integer NOT NULL,
>>> "SESSIONTIMESTAMP" character varying(45) NOT NULL,
>>> "SESSIONDATA" character varying(200) DEFAULT NULL::character varying,
>>> CONSTRAINT sessions_pkey PRIMARY KEY ("SESSIONID")
>>> )
>>>
>>> Now, when I do:
>>>
>>> DELETE From sessions WHERE SESSIONTIMESTAMP < '2010-01-01 10:02:02'
>>>
>>> I get:
>>>
>>> ERROR: column "sessiontimestamp" does not exist
>>> LINE 1: DELETE From sessions WHERE SESSIONTIMESTAMP < '2010-01-01 10...
>>> ^
>>> ********** Error **********
>>>
>>> ERROR: column "sessiontimestamp" does not exist
>>> SQL state: 42703
>>> Character: 28
>>>
>>> But if I do:
>>>
>>> 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?.
>>
>> See here, bottom of 4.1.1. Identifiers and Key Words:
>>
>> http://www.postgresql.org/docs/9.3/interactive/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS
>>
>>
>
> Thanks, then it looks like SESSIONTIMESTAMP is an identifier?.

"The tokens MY_TABLE and A are examples of identifiers. They identify
names of tables, columns, or other database objects, depending on the
command they are used in. Therefore they are sometimes simply called
"names". "

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Leonardo M. Ramé 2015-03-26 17:30:33 Re: Column does not exists?
Previous Message Francisco Olarte 2015-03-26 17:23:23 Re: Column does not exists?