Re: table name restiction

From: Richard Huxton <dev(at)archonet(dot)com>
To: dale <dalen(at)czexan(dot)net>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: table name restiction
Date: 2005-01-31 21:43:51
Message-ID: 41FEA697.3040609@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Michael Fuhr 2005-01-31 21:54:27 Re: how to release a transaction lock on a table?
Previous Message Tom Lane 2005-01-31 21:41:43 Re: Dereferencing a 2-dimensional array in plpgsql