[Gdal-dev] CreateLayer: PostGIS primary key?

Craig Miller craig.miller at spatialminds.com
Fri Dec 2 21:37:29 EST 2005


>From what I've read, it's best to name all constraints. So, I think the
following will create a named primary key constraint called %s_pk:


                 "CREATE TABLE \"%s\" ( "
                 "   OGC_FID SERIAL, "
                 "   WKB_GEOMETRY %s, "
                 "   CONSTRAINT \"%s_pk\" PRIMARY KEY (OGC_FID) )",

--Craig


-----Original Message-----
From: fwarmerdam at gmail.com [mailto:fwarmerdam at gmail.com] On Behalf Of Frank
Warmerdam
Sent: Friday, December 02, 2005 6:17 PM
To: Craig Miller
Cc: Gdal-Dev
Subject: Re: [Gdal-dev] CreateLayer: PostGIS primary key?

On 12/2/05, Craig Miller <craig.miller at spatialminds.com> wrote:
> Is there a way to specify that the FID column should be the primary 
> key when creating a PostGIS layer with OGRDatasource::CreateLayer?
>
> Is there any reason why I wouldn't want to use the FID column as the 
> primary key?

Craig,

In normal situations I can't see any reason the FID column should not
be the primary key.   There is currently no way to make CreateLayer()
make the OGC_FID column the primary key as part of it's operation.
I can't see any harm in adding that though.

What would I change the following to, in order to make OGC_FID the primary
key?

                 "CREATE TABLE \"%s\" ( "
                 "   OGC_FID SERIAL, "
                 "   WKB_GEOMETRY %s )",

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    | Geospatial Programmer for Rent





More information about the Gdal-dev mailing list