Re: Parenthesis in Queries

From: Martin Marques <martin(at)bugs(dot)unl(dot)edu(dot)ar>
To: "Oudenhoven, Timothy L" <Timothy(dot)L(dot)Oudenhoven(at)uwsp(dot)edu>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: Parenthesis in Queries
Date: 2004-05-04 11:40:05
Message-ID: 200405040840.05296.martin@bugs.unl.edu.ar
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

El Dom 02 May 2004 17:15, Oudenhoven, Timothy L escribió:
> Is there a way to turn off the need to use parenthesis in queries for table
> names etc. I have seen in some documentation examples that parenthesis are
> not used in the queries. In my install of postgre 7.4 I get an error when
> I do not use them.
>
> Example with parenthesis which works in my build
> select * from portal."User"
>
> where I would like to use
> select * from portal.User

Does are not parenthesis, but doble quotes.

When you don't put quotes on the relations name, PG will lower case the name,
and there is where you get the error.

Solution: Don't use quoted relation names ever. This includes especially when
you create tables, becuase if you do this:

CREATE TABLE tab1 (
"ID" SERIAL,
"User" VARCHAR(30)
);

tab1.ID will not exist, becuase PG interprets it as tab1.id (see the case
difference), but will recognize pretty well tab1."ID".

--
08:35:02 up 5 days, 13:57, 2 users, load average: 0.63, 0.73, 0.75
-----------------------------------------------------------------
Martín Marqués | select 'mmarques' || '@' || 'unl.edu.ar'
Centro de Telematica | DBA, Programador, Administrador
Universidad Nacional
del Litoral
-----------------------------------------------------------------

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2004-05-04 12:15:23 Re: pgsql documentation error ?
Previous Message Karsten Hilbert 2004-05-04 10:24:37 interval output format available that removes ambiguity ?