[gdal-dev] ogr2ogr question

jratike80 jukka.rahkonen at maanmittauslaitos.fi
Mon Dec 21 23:36:25 PST 2020


Hi,

No, -overwrite does not truncate but it drops the table. However, with the
PostgreSQL driver it is also possible to truncate the table by using this
documented method  https://gdal.org/drivers/vector/pg.html#vector-pg. Check
the configuration options

"OGR_TRUNCATE: If set to “YES”, the content of the table will be first
erased with the SQL TRUNCATE command before inserting the first feature.
This is an alternative to using the -overwrite flag of ogr2ogr, that avoids
views based on the table to be destroyed. Typical use case: “ogr2ogr -append
PG:dbname=foo abc.shp –config OGR_TRUNCATE YES”."

-Jukka Rahkonen-


ghtmtt wrote
> 
> Just for information: -overwrite is doing a "truncate table" before 
> adding the new features? Is this the reason that FK, CHECKS and other 
> customization will be lost?
> 
> Cheers and thanks
> 
> Matteo





--
Sent from: http://osgeo-org.1560.x6.nabble.com/GDAL-Dev-f3742093.html


More information about the gdal-dev mailing list