Column Name = column does not exist

Поиск
Список
Период
Сортировка
Искать

Column Name = column does not exist

От:
brian stapel <brians_224@hotmail.com>
Дата:
Thanks for your time.
 
I'm in the process of trying to incorporate three Human Resource systems into one.  Each of the three systems had a different author and no standards were followed - consequently the table design leaves a bit to be desired.  One of the most critical tables has a field named:Last_Name (case specific).  When I execute 'Select Last_Name from employee' the statement fails with the following message: column "last_name" does not exist.  If I wrap the field name in quotes "Last_Name" for example, the query works as expected.
 
Is this typical behavior?
 
Thanks again.


Get the Live.com Holiday Page for recipes, gift-giving ideas, and more. Check it out!

Re: Column Name = column does not exist

От:
Sean Davis <sdavis2@mail.nih.gov>
Дата:
brian stapel wrote:
> Thanks for your time.
>  
> I'm in the process of trying to incorporate three Human Resource 
> systems into one.  Each of the three systems had a different author 
> and no standards were followed - consequently the table design leaves 
> a bit to be desired.  One of the most critical tables has a field 
> named:Last_Name (case specific).  When I execute 'Select Last_Name 
> from employee' the statement fails with the following message: column 
> "last_name" does not exist.  If I wrap the field name in quotes 
> "Last_Name" for example, the query works as expected.
>  
> Is this typical behavior?
>  
Yes.  Postgresql case-collapses unless things are quoted.  The rule of 
thumb is, if you quote anywhere, you probably should quote EVERYWHERE. 

Sean

Re: Column Name = column does not exist

От:
Bruno Wolff III <bruno@wolff.to>
Дата:
On Mon, Jan 08, 2007 at 16:38:57 -0600,
  brian stapel  wrote:
> Thanks for your time.
>  
> I'm in the process of trying to incorporate three Human Resource systems into one.  Each of the three systems had a different author and no standards were followed - consequently the table design leaves a bit to be desired.  One of the most critical tables has a field named:Last_Name (case specific).  When I execute 'Select Last_Name from employee' the statement fails with the following message: column "last_name" does not exist.  If I wrap the field name in quotes "Last_Name" for example, the query works as expected.
>  
> Is this typical behavior?

Yes. In postgres, unquoted column and table names are converted to lower case.

In general, the advice is to either never quote names or always quote them.
FAQ