471,084 Members | 1,046 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,084 software developers and data experts.

Parenthesis in Queries

Is there a way to turn off the need to use parenthesis in queries for tablenames 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

Thanks
Tim


---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Nov 23 '05 #1
4 2239
Oudenhoven, Timothy L wrote:
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

Thanks
Tim

Yes, sortof.

Just define all of your table and column names to be in lowercase.
Postgresql is sortof SQL standard here, in that names in quotes are
case-sensitive, and names without quotes give the illusion of case
insensitivity by turning them all into lowercase.

The deviation from the standard is because the standard dictates
"UPPERCASE". If you were to try the same thing on Oracle, my advice
would be "define all of your table and column names to be uppercase".

Shachar

--
Shachar Shemesh
Lingnu Open Source Consulting
http://www.lingnu.com/
---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Nov 23 '05 #2
Oudenhoven, Timothy L wrote:
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

Thanks
Tim

Yes, sortof.

Just define all of your table and column names to be in lowercase.
Postgresql is sortof SQL standard here, in that names in quotes are
case-sensitive, and names without quotes give the illusion of case
insensitivity by turning them all into lowercase.

The deviation from the standard is because the standard dictates
"UPPERCASE". If you were to try the same thing on Oracle, my advice
would be "define all of your table and column names to be uppercase".

Shachar

--
Shachar Shemesh
Lingnu Open Source Consulting
http://www.lingnu.com/
---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Nov 23 '05 #3
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
-----------------------------------------------------------------

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Nov 23 '05 #4
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
-----------------------------------------------------------------

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Nov 23 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Colossus | last post: by
reply views Thread by Gregory Nans | last post: by
reply views Thread by chenyu468 | last post: by
38 posts views Thread by Steve Kirsch | last post: by
2 posts views Thread by Mike Cooper | last post: by
reply views Thread by Oudenhoven, Timothy L | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.