[Gdal-dev] Need Help with ogr2ogr Import Shapefile Error

Frank Warmerdam warmerdam at pobox.com
Mon Dec 4 14:07:11 EST 2006


Bill Thoen wrote:
> But now I can't access the table! Is there something about this table name
> it doesn't like? Why can't I display the table structure or select anything
> from this table?
> 
> (BTW, notice that it uses lowercase letters in one of the error messages,
> but not both.)
> 
> clu=# \d
>                     List of relations
>  Schema |            Name             |   Type   | Owner
> --------+-----------------------------+----------+--------
>  public | clu_001ilna04_U             | table    | bthoen
>  public | clu_001ilna04_U_ogc_fid_seq | sequence | bthoen
>  public | geometry_columns            | table    | bthoen
>  public | spatial_ref_sys             | table    | bthoen
> (4 rows)
> 
> clu=# \d clu_001ilna04_U
> Did not find any relation named "clu_001ilna04_U".
> clu=# select * from clu_001ilna04_U;
> ERROR:  relation "clu_001ilna04_u" does not exist
> clu=#

Bill,

Postgresql is case sensitive, and it also forces all tokens to lower
case unless they are quoted.  OGR (perhaps unfortunately) defaults to
preserving the case of your table names by quoting them in SQL statements
so you get tables like yours.  But to actually use them interactively
you would need to quote the name.

eg.
\d "clu_00lilna04_U"

or
select * from  "clu_00lilna04_U"

You can use the -nln switch to ogr2ogr to apply a different name to
the loaded table than is in the original table.

Note that similar issues apply to field names, but by default OGR
forces all field names to lower case.  This can be disabled by
the LAUNDER creation flag.  No doubt I ought to apply the same logic
to table names to avoid this sort of misery.

Actually, I think I'll apply that change today before issuing GDAL 1.4.0
beta1.

Best regards,
-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | President OSGeo, http://osgeo.org




More information about the Gdal-dev mailing list