Re: table name restiction - Mailing list pgsql-general

From Richard Huxton
Subject Re: table name restiction
Date
Msg-id 41FEA697.3040609@archonet.com
Whole thread Raw
In response to table name restiction  (dale <dalen@czexan.net>)
List pgsql-general
dale wrote:
> PostgreSQL users,
>     What are the restrictions on naming tables or columns in tables
> other than uniqueness (assuming ascii characters)?  For instance, are
> names case sensitive.  What special characters can be used
> (`_`,`-`,` `).  I looked at the docs in the tutorial part in the
> beginning and in the description of CREATE TABLE but could not find
> naming restriction info.  Could someone point me in the right direction?

As a rule of thumb, stick to all-one-case, a-z,0-9 and _
This should be portable to other database systems. SQL is case
insensitive (although the standard folds to UPPERCASE whereas PG folds
to lower). You can create a case-sensitive table by quoting but you will
need to use quotes in future too.

So this will work (because PG treats them all as "mytable"):
   CREATE TABLE MyTable
   SELECT * FROM MYTABLE
   SELECT * FROM mytable
   SELECT * FROM MyTaBlE
This will not (because the select ends up as "mytable" not "MyTable"):
   CREATE TABLE "MyTable"
   SELECT * FROM MyTable

--
   Richard Huxton
   Archonet Ltd

pgsql-general by date:

Previous
From: Scott Marlowe
Date:
Subject: Re: postgres session termination
Next
From: Tom Lane
Date:
Subject: Re: Dereferencing a 2-dimensional array in plpgsql