Thread: Query about SQL in PostgreSQL

Query about SQL in PostgreSQL

From
Muhammad Nadeem Ashraf
Date:
Hi,
I am new user of PostGreSQL 8.0.1. While using it i faced following issue. As SQL is Case insensetive Language So the Uper or Lower cases are not significant. But while using the database there is problem.
If i Create new Table with name (tblstudent) then upon SQL queries it is fine to use Select * from tblstudent. However i face probel if i give the name of table in Capital letters i.e. if the name is (tblStudent) then upon using Select * from tblStudent, following error is appeard:
ERROR:  relation "tblst" does not exist 
 
And if i use the query Select * from "tblStudent" then it works fine.
 
 
Please help me out in this regard.
Nadeem
 


Yahoo! Mail Mobile
Take Yahoo! Mail with you! Check email on your mobile phone.

Re: Query about SQL in PostgreSQL

From
KÖPFERL Robert
Date:
Postgres has the weird behavour to compare identifies case sensitive BUT to downcast any non-quoted identifier inside an SQL statement.
So it is reccomended to just use lower case (for readability)
-----Original Message-----
From: Muhammad Nadeem Ashraf [mailto:nadeem_engg@yahoo.com]
Sent: Dienstag, 19. April 2005 11:49
To: pgsql-sql@postgresql.org
Subject: [SQL] Query about SQL in PostgreSQL

Hi,
I am new user of PostGreSQL 8.0.1. While using it i faced following issue. As SQL is Case insensetive Language So the Uper or Lower cases are not significant. But while using the database there is problem.
If i Create new Table with name (tblstudent) then upon SQL queries it is fine to use Select * from tblstudent. However i face probel if i give the name of table in Capital letters i.e. if the name is (tblStudent) then upon using Select * from tblStudent, following error is appeard:
ERROR:  relation "tblst" does not exist 
 
And if i use the query Select * from "tblStudent" then it works fine.
 
 
Please help me out in this regard.
Nadeem
 


Yahoo! Mail Mobile
Take Yahoo! Mail with you! Check email on your mobile phone.

Re: Query about SQL in PostgreSQL

From
Thomas Kellerer
Date:

On 19.04.2005 11:48 Muhammad Nadeem Ashraf wrote:

> Hi,
> I am new user of PostGreSQL 8.0.1. While using it i faced following
> issue. As SQL is Case insensetive Language So the Uper or Lower cases
> are not significant. But while using the database there is problem.
> If i Create new Table with name (tblstudent) then upon SQL queries it is
> fine to use Select * from tblstudent. However i face probel if i give
> the name of table in Capital letters i.e. if the name is (tblStudent)
> then upon using Select * from tblStudent, following error is appeard:
> ERROR:  relation "tblst" does not exist 
>  
> And if i use the query Select * from "tblStudent" then it works fine.
>  
>  

This is how SQL is defined in the ANSI standard. If you use double quotes around
your object names, then it's case sensitiv. If you omit the double quotes it's
not. General rule: do not use double quotes at all, and your fine (this is true
for other DBMS like Oracle and Firebird as well)

Thomas




Re: Query about SQL in PostgreSQL

From
Sean Davis
Date:
On Apr 19, 2005, at 5:48 AM, Muhammad Nadeem Ashraf wrote:

> Hi,
> I am new user of PostGreSQL 8.0.1. While using it i faced following
> issue. As SQL is Case insensetive Language So the Uper or Lower cases
> are not significant. But while using the database there is problem.
> If i Create new Table with name (tblstudent) then upon SQL queries it
> is fine to use Select * from tblstudent. However i face probel if i
> give the name of table in Capital letters i.e. if the name is
> (tblStudent) then upon using Select * from tblStudent, following error
> is appeard:
> ERROR:  relation "tblst" does not exist 
>  
> And if i use the query Select * from "tblStudent" then it works fine.

SQL is case insensitive.  However, identifiers (table names, column
names, index names, etc.) are case sensitive in Postgresql.  So, your
operational understanding of how things work seems to be correct.  I
tend to use all lower-case, just because it saves me some thought, but
I know some folks like to use a mix of upper and lower case so that
they can be used in a web application, for example.  If you do use
mixed or upper case, you do have to quote them.

If you still have a problem, could you be more specific about what it
is?

Sean



Re: Query about SQL in PostgreSQL

From
Reinoud van Leeuwen
Date:
On Tue, Apr 19, 2005 at 02:48:46AM -0700, Muhammad Nadeem Ashraf wrote:
> Hi,
> I am new user of PostGreSQL 8.0.1. While using it i faced following 
> issue. As SQL is Case insensetive Language So the Uper or Lower cases 
> are not significant. But while using the database there is problem.
> If i Create new Table with name (tblstudent) then upon SQL queries it 
> is fine to use Select * from tblstudent. However i face probel if i give 
> the name of table in Capital letters i.e. if the name is (tblStudent) 
> then upon using Select * from tblStudent, following error is appeard:
> ERROR:  relation "tblst" does not exist 
>  
> And if i use the query Select * from "tblStudent" then it works fine.
>  
>  
> Please help me out in this regard.

What exactly is the problem? Just use the names of tables you have 
created.

-- 
__________________________________________________
"Nothing is as subjective as reality"
Reinoud van Leeuwen    reinoud.v@n.leeuwen.net
http://www.xs4all.nl/~reinoud
__________________________________________________


Re: Query about SQL in PostgreSQL

From
Richard Huxton
Date:
Muhammad Nadeem Ashraf wrote:
> Hi,
> I am new user of PostGreSQL 8.0.1. While using it i faced following 
> issue. As SQL is Case insensetive Language So the Uper or Lower cases 
> are not significant. But while using the database there is problem.
> If i Create new Table with name (tblstudent) then upon SQL queries it is 
> fine to use Select * from tblstudent. However i face probel if i give 
> the name of table in Capital letters i.e. if the name is (tblStudent) 
> then upon using Select * from tblStudent, following error is appeard:
> ERROR:  relation "tblst" does not exist 
>  
> And if i use the query Select * from "tblStudent" then it works fine.

If you quote your table-names when you create them you should always 
quote them when you use them.

If you don't quote your table-names when you create them, there is no 
need to quote them when you use them.

--   Richard Huxton  Archonet Ltd


Re: Query about SQL in PostgreSQL

From
Andrew Sullivan
Date:
On Tue, Apr 19, 2005 at 11:59:58AM +0200, KÖPFERL Robert wrote:
> Postgres has the weird behavour to compare identifies case sensitive BUT to
> downcast any non-quoted identifier inside an SQL statement. 
> So it is reccomended to just use lower case (for readability) 

Or never double-quote identifiers.  I sort of don't believe exactly
the original poster's report, however, because the error message
wasn't right no matter what.  I'd like to see a real session
transcript.  Also, this probably belongs on -general.

A

-- 
Andrew Sullivan  | ajs@crankycanuck.ca
Information security isn't a technological problem.  It's an economics
problem.    --Bruce Schneier


Re: Query about SQL in PostgreSQL

From
"Jeff Eckermann"
Date:
"Muhammad Nadeem Ashraf" <nadeem_engg@yahoo.com> wrote in message 
news:20050419094846.21474.qmail@web50506.mail.yahoo.com...
> Hi,
> I am new user of PostGreSQL 8.0.1. While using it i faced following issue. 
> As SQL is Case insensetive Language So the Uper or Lower cases are not 
> significant. But while using the database there is problem.
> If i Create new Table with name (tblstudent) then upon SQL queries it is 
> fine to use Select * from tblstudent. However i face probel if i give the 
> name of table in Capital letters i.e. if the name is (tblStudent) then 
> upon using Select * from tblStudent, following error is appeard:
> ERROR:  relation "tblst" does not exist

That should have worked.  Can you provide a session transcript that shows 
this?

>
> And if i use the query Select * from "tblStudent" then it works fine.
>
>
> Please help me out in this regard.
> Nadeem
>
>
>
> ---------------------------------
> Yahoo! Mail Mobile
> Take Yahoo! Mail with you! Check email on your mobile phone. 




Re: Query about SQL in PostgreSQL

From
"Jeff Eckermann"
Date:
Forget that message.  I need another cup of coffee!

"Jeff Eckermann" <jeff_eckermann@yahoo.com> wrote in message 
news:d433uh$2ujf$2@news.hub.org...
> "Muhammad Nadeem Ashraf" <nadeem_engg@yahoo.com> wrote in message 
> news:20050419094846.21474.qmail@web50506.mail.yahoo.com...
>> Hi,
>> I am new user of PostGreSQL 8.0.1. While using it i faced following 
>> issue. As SQL is Case insensetive Language So the Uper or Lower cases are 
>> not significant. But while using the database there is problem.
>> If i Create new Table with name (tblstudent) then upon SQL queries it is 
>> fine to use Select * from tblstudent. However i face probel if i give the 
>> name of table in Capital letters i.e. if the name is (tblStudent) then 
>> upon using Select * from tblStudent, following error is appeard:
>> ERROR:  relation "tblst" does not exist
>
> That should have worked.  Can you provide a session transcript that shows 
> this?
>
>>
>> And if i use the query Select * from "tblStudent" then it works fine.
>>
>>
>> Please help me out in this regard.
>> Nadeem
>>
>>
>>
>> ---------------------------------
>> Yahoo! Mail Mobile
>> Take Yahoo! Mail with you! Check email on your mobile phone.
>
>