Re: Autonumbering Problem?

From: Andreas <maps(dot)on(at)gmx(dot)net>
To: mobilepc(at)mobilepcclinic(dot)net
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Autonumbering Problem?
Date: 2006-08-21 18:16:09
Message-ID: 44E9F869.6040506@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Arthur Baldwin schrieb:
> tco=# insert into customers (FullName) values ('Arthur E. Baldwin');
> ERROR: relation "customers" does not exist
> tco=# \d
> List of relations
> Schema | Name | Type | Owner
> --------+----------------------+----------+--------
> public | Customers | table | arthur
> public | Customers_CustID_seq | sequence | arthur
> (2 rows)
>
> What am I doing wrong?
>
Postgresql's handles identifiers case relevant, as the other posters
allready mentioned.
So you created Customers with "C" and wanted to insert into customers
with "c".
The same goes for column names, too.
You can either use double quotes " for all identifiers or stop using
upper case characters in names. Actually I'm not even sure if PG
converts unquoted identifiers to lower or rather to upper case internally.
This behaviour seems to be stupid but AFAIK it conforms to SQL rules and
it is cleaner because you get what you asked for and not what the DBMS
thinks you probaply wanted to ask for but didn't.

I guess you used some GUI tool to create the tables. PGAdmin for example
uses the quotes automatically if you try to create tables/columns with
mixed case names.
That could lead to ambiguities since you are even alowed to have a table
"Customers" besides another one called "customers".

And while we are at it ... PG distinguishes upper/lower case in string
comparisons, too.
You should be aware that MySQL and Access will find 'Arthur', 'arthur',
'ArtHur' if you use SELECT ... WHERE name= 'arthur'.
Postgresql only shows 1 record that matches the criterium exacly.

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Saranya Sivakumar 2006-08-21 18:21:55 Incremental backup with Postgres 7.3.2
Previous Message Andreas 2006-08-21 17:40:12 invalid byte sequence ?