[Gdal-dev] ogr2ogr creation of internal object id (oid) column in pgsql table

Even Rouault even.rouault at mines-paris.org
Wed Sep 30 15:03:02 EDT 2009


Selon Ted Spradley <tspradley at snoogems.com>:

When OGR creates a PG table, the name of the primary key is 'OGC_FID'. So, you
just have to replace 'oid' by 'OGC_FID' in your example.

>
> Hi,
>
> I have used ogr2ogr to load data from shapefile countyp020.shp into
> db=project1, following Tyler Mitchell's 'Web Mapping Illustrated'.
>
> > ogr2ogr -f "PostgreSQL" PG:dbname=project1 countyp020.shp
>
> Tyler explains that: to optimize for Mapserver we can create an index on the
> unique ID for the table.  If we use a simple DATA statement in a map file:
> DATA wkb_geometry from countyp020, Mapserver will use PostgreSQL's internal
> object ID.  The oid column doesn't appear in the column listing for a table,
> but we can use it in a SELECT statement.
>
> I am assuming:
>
> SELECT oid FROM countyp020 LIMIT 1;
>
> should return one value for the column 'oid'.  Instead the return is:
>
> ERROR:  column "oid" does not exist
> LINE 1: SELECT oid FROM countyp020 LIMIT 1;
>                ^
>
> So, when preparing the table for performance, the CREATE INDEX statement
> fails.
>
> project1=# CREATE INDEX idx_countyp020 ON countyp020 (oid);
> ERROR:  column "oid" does not exist
>
> When the ogr2ogr command above is given, I am assuming that ogr2ogr creates
> the SQL CREATE TABLE, and INSERT statements to hold the data from the
> shapefile.  And PostgreSQL, then does the table creation.  Is the 'oid'
> column created by default or do we somehow need to instruct ogr2ogr to add
> 'oid' as a column?
>
> Thank you,
> Ted S.
>
>
>
> --
> View this message in context:
>
http://n2.nabble.com/ogr2ogr-creation-of-internal-object-id-oid-column-in-pgsql-table-tp3744541p3744541.html
> Sent from the GDAL - Dev mailing list archive at Nabble.com.
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev
>




More information about the gdal-dev mailing list