[postgis-users] using quotation for table columns

Michael Fuhr mike at fuhr.org
Fri Jun 2 09:08:48 PDT 2006


On Fri, Jun 02, 2006 at 09:23:56AM -0500, CYW wrote:
> For some tables I created with shp2pgsql, I have to use double quotations
> around all non-geom table columns in SQL, e.g.,
> 	SELECT "ID" FROM sometable;
> 
> If I do: 
> 	SELECT ID FROM sometable;
> It will say: column "id" does not exist.

PostgreSQL folds unquoted identifiers to lowercase, so if an
identifier was created with quotes and in uppercase or mixed case
then you'll need to quote that identifier whenever you reference
it.  See "Identifiers and Key Words" in the PostgreSQL documentation:

http://www.postgresql.org/docs/8.1/interactive/sql-syntax.html#SQL-SYNTAX-IDENTIFIERS

shp2pgsql creates identifiers in lowercase unless you use the -k
option, which preserves the case found in the data.  Did you use -k
when you ran shp2pgsql?  If so, and if the identifiers in the data
were uppercase, then that would explain what you're seeing.

-- 
Michael Fuhr



More information about the postgis-users mailing list