[postgis-users] shp2pgsql options?

Paul Ramsey pramsey at refractions.net
Mon Mar 20 12:56:20 PST 2006


oids are *not* required by Mapserver.  They are used for queries, in  
the case where you have not defined a unique column with "using  
unique" in your DATA statement.  But you do have a unique id in your  
table... gid is created by shp2pgsql as a unique primary key.

So load up things in 8.1 w/o oids.  Since you are using shp2pgsql as  
your loader, you are getting a unique primary key called 'gid'  
defined for you by the tool.  So you can use this as a data statement:

DATA "the_geom from geotable using unique gid"


On Mar 20, 2006, at 12:20 PM, Thom DeCarlo wrote:

> Hello,
> I've been trying to load a set of shapefiles into a PostgreSQL 8.1.1 +
> PostGIS 1.1.0 database and having a bit of trouble with missing  
> "oids". I've
> read that the current PostgreSQL doesn't create tables with OID by  
> default,
> but they are required for use with MapServer. Due to that, my load  
> process
> becomes:
> shp2pgsql -p -I -s <EPSG> shapefile.shp tablename  
> >tablename_create.sql
> vi tablename_create.sql
>    add "WITH OIDS" to the "CREATE TABLE" command
> psql -d database -f tablename_create.sql
> shp2pgsql -a -s <EPSG> shapefile.shp tablename | psql -d database
> That's a bit of a pain when dealing with hundreds of shapefiles. Is  
> there an
> option for shp2pgsql (maybe "-O") that would tell it to create the  
> tables
> with OIDS?
> Thanks,
> Thom
> --
> Thom DeCarlo
> ----------------------------------------
>      there was coffee.
>      life would go on.
>           william gibson, the winter market
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users

More information about the postgis-users mailing list