I've been struggling with this for a while, tried a few different ideas inspired by these pages:http://www.gdal.org/ogr2ogr.htmlhttp://www.gdal.org/ogr/drv_pg.htmlhttp://www.gdal.org/ogr/drv_pg_advanced.htmlhttp://trac.osgeo.org/gdal/wiki/ConfigOptions
but I always end up with ogc_fid as the primary key. Anyone know of a way to get ogr2ogr to use an existing primary key for the fid?
Alternatively, does anyone know how I can get this existing key to be an autoincrement sequence after the ogr2ogr load?I've tried:
`CREATE SEQUENCE my_table_my_pk_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1;ALTER TABLE public.my_table_my_pk_seq OWNER TO postgres;ALTER SEQUENCE my_table_my_pk_seq OWNED BY my_table.my_pk;ALTER TABLE ONLY my_table ALTER COLUMN my_pk SET DEFAULT nextval('my_table_my_pk_seq'::regclass);ALTER TABLE my_table ALTER COLUMN my_pk SET NOT NULL;SELECT pg_catalog.setval('my_table_ogc_fid_seq', NUMBER_OF_FEATURES_IMPORTED, true);`but I get database errors when trying to insert features.
Any help appreciated.
Mini
أكثر...
but I always end up with ogc_fid as the primary key. Anyone know of a way to get ogr2ogr to use an existing primary key for the fid?
Alternatively, does anyone know how I can get this existing key to be an autoincrement sequence after the ogr2ogr load?I've tried:
`CREATE SEQUENCE my_table_my_pk_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1;ALTER TABLE public.my_table_my_pk_seq OWNER TO postgres;ALTER SEQUENCE my_table_my_pk_seq OWNED BY my_table.my_pk;ALTER TABLE ONLY my_table ALTER COLUMN my_pk SET DEFAULT nextval('my_table_my_pk_seq'::regclass);ALTER TABLE my_table ALTER COLUMN my_pk SET NOT NULL;SELECT pg_catalog.setval('my_table_ogc_fid_seq', NUMBER_OF_FEATURES_IMPORTED, true);`but I get database errors when trying to insert features.
Any help appreciated.
Mini
أكثر...