From: Craig Ringer <craig@postnewspapers.com.au>
To: ikorot@earthlink.net
Cc: pgsql-odbc@postgresql.org
Subject: Re: Table creation
Date: Mon, 16 Nov 2009 11:02:15 +0800
Message-ID: <4B00C0B7.2060406@postnewspapers.com.au> (raw)
In-Reply-To: <26627023.1258337329909.JavaMail.root@elwamui-hybrid.atl.sa.earthlink.net>
References: <26627023.1258337329909.JavaMail.root@elwamui-hybrid.atl.sa.earthlink.net>
On 16/11/2009 10:08 AM, ikorot@earthlink.net wrote:
> Hi, ALL,
> I'm new to this list and to PostgreSQL. However, I am
> a C++ developer with some ODBC development experience.
>
> I heard that in PostgreSQL it is possible to create table
> in 2 ways:
>
> CREATE TABLE "Foo" ....;
>
> CREATE TABLE Foo... ;
>
> So, when using unquoted version all query should check for
> the case sensitivity.
>
> Is it possible to check how the table was created to use proper
> query syntax?
If the unquoted form was used, the table name will have been downcased
by PostgreSQL. It's still case sensitive, just forced to lower case.
Essentially,
CREATE TABLE Foo ... ;
is exactly equivalent to:
CREATE TABLE "foo" ... ;
in terms of its effects after the CREATE statement has executed. So, if
you expect to have any non-lower-case identifiers (table names, index
names, constraint names, etc) in your database, ALWAYS quote your
identifiers. If they're all lower case, it'll still work.
The only problem that'll arise is if your application is told by some
external source to access table "Foo" but doesn't know if the external
source created it as "Foo" or "foo". In that case, you can either query
INFORMATION_SCHEMA with a case-insensitive search to find the table
(which is slow and ugly) or just fix your app to be consistent about
quoting and case.
--
Craig Ringer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-odbc@postgresql.org
Cc: craig@postnewspapers.com.au, ikorot@earthlink.net
Subject: Re: Table creation
In-Reply-To: <4B00C0B7.2060406@postnewspapers.com.au>
References: <26627023.1258337329909.JavaMail.root@elwamui-hybrid.atl.sa.earthlink.net> <4B00C0B7.2060406@postnewspapers.com.au>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox