Opened 4 years ago

Closed 4 years ago

Last modified 3 years ago

#5091 closed enhancement (fixed)

Allow PostGIS table overwrite updates via truncate

Reported by: mpfister Owned by: warmerdam
Priority: low Milestone: 1.11.0
Component: OGR_SF Version: unspecified
Severity: normal Keywords:
Cc:

Description

ogr2ogr updates a PostGIS table by first running a DROP CASCADE on the table, then recreating it. If there are views on the table, they are dropped by the CASCADE. Is it possible to update a table by instead running TRUNCATE on the table to empty it, then filling it with new records? I've tried combinations of the current options and don't think you can accomplish this result presently.

Change History (4)

comment:1 Changed 4 years ago by Even Rouault

You can try: 'ogrinfo pg:dbname=XXXX -sql "truncate table foo"' before running ogr2ogr -append

comment:2 Changed 4 years ago by mpfister

Yes, I truncate with psql already, though that's a handy trick to use ogrinfo.

comment:3 Changed 4 years ago by Even Rouault

Component: defaultOGR_SF
Milestone: 2.0
Resolution: fixed
Status: newclosed

trunk r26055 "PG: add a OGR_TRUNCATE configuration option that can be used as an alternative to the -overwrite flag of ogr2ogr, but that avoids DROP TABLE ... CASCADE which destroys views based on the tables (#5091)"

comment:4 Changed 3 years ago by Even Rouault

Milestone: 2.01.11.0
Note: See TracTickets for help on using tickets.