Re: Double Quoting Table Names????

From: Mike Mascari <mascarm(at)mascari(dot)com>
To: Edward Muller <edwardam(at)home(dot)com>
Cc: wsheldah(at)lexmark(dot)com, pgsql-general(at)postgresql(dot)org
Subject: Re: Double Quoting Table Names????
Date: 2001-09-28 03:13:08
Message-ID: 3BB3EAC4.EF8F393F@mascari.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Edward Muller wrote:
>
> The tables were created using phpPgAdmin30beta.
>
> Here is the SQL used to create one the tables
>
> (phpPgAdmin displays this after the create).
>
> CREATE TABLE "Clients" (
> "clientid" SERIAL,
> "name" char (40) ,
> "startdate" char (6) ,
> "enddate" char (6) ,
> "isactive" bool ,
> "acctnumber" int4 ,
> "acctpasswd" char (20) ,
> "adminid" SERIAL ,
> PRIMARY KEY ("clientid"), UNIQUE ("clientid"));
> CREATE INDEX "Clients_clientid_key" ON "Clients"("clientid");
> CREATE INDEX "Clients_name_key" ON "Clients"("name");
> CREATE INDEX "Clients_startdate_key" ON "Clients"("startdate");
> CREATE INDEX "Clients_enddate_key" ON "Clients"("enddate");
> CREATE INDEX "Clients_isactive_key" ON "Clients"("isactive");
> CREATE INDEX "Clients_acctnumber_key" ON "Clients"("acctnumber");
> CREATE INDEX "Clients_acctpasswd_key" ON "Clients"("acctpasswd");
>
> So doing the following query via the phpPgAdmin30 webpage:
>
> SELECT * from Clients;
>
> give me this error:
>
> PostgreSQL said: ERROR: Relation 'clients' does not exist
>
> Doing the same with pgsql give me:
>
> ERROR: Relation 'client' does not exist
>
> Doing the same query from JDBC give me ... well you get the idea...
>
> Now if I replace SELECT * from Clients; with SELECT * from "Clients"; it
> works fine.
>
> Why? Is it because of case?

Yes. A quoted table/column/index name is case-sensitive. An unquoted
table/column/index name is folded into lower case. If you do not
have table/column/index names with spaces, you could try the
following:

(Warning - This appears to work fine for me, but I suggest you
pg_dump your database first)

UPDATE pg_class SET relname = lower(relname);
UPDATE pg_attribute SET attname = lower(attname);

Hope that helps,

Mike Mascari
mascarm(at)mascari(dot)com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Barry Lind 2001-09-28 03:24:25 Re: PostGres is not using indices in select, I would like it to because it is too slow !
Previous Message Keary Suska 2001-09-28 03:05:11 Re: temp table::persistance problem