7

I wonder what's the difference between the ogr2ogr parameters -append and -update.

It seems that they both are used to prevent ogr2ogr from creating a new layer:

-append: Append to existing layer instead of creating a new one
-update: Open existing output datasource in update mode rather than trying to create a new one

There also seems to be a difference between running ogr2ogr on windows and on linux. I use "ogr2ogr -skipfailures -append" to fill some existing oracle tables with data. both ogr2ogr versions are 1.11( Windows 1.11.1 Linux GDAL 1.11.5). On windows the tables are filled with data, on linux there is just an error that the table already exist and no data is inserted.

Thomas B
  • 8,807
  • 1
  • 21
  • 62

1 Answers1

8

You would normally use both -update -append simultaneously.

Use -update to avoid creation of a new datasource, that is a new file or a new database.

Use -append to merge matching layers inside the datasource.

Dima Chubarov
  • 405
  • 2
  • 11
  • 1
    Right, for example with GeoPackege if only -update is used then the existing database file is used but the existing layer will be overwritten. For single-layer datasources like shapefiles the difference is not so obvious and the behavior with different drivers may vary slightly. – user30184 May 23 '19 at 06:29
  • @Dimitri Chobarow: According to the gdal docs the -append parameter itself is sufficient to tell ogr2ogr to not create a new target layer. On windows I don't neet to use -update to append data to an existing database table. – Thomas B May 23 '19 at 06:32
  • @user30184: for datasources like spatialite/geopackage the difference between update and append makes sence, true. for database tables --append should be sufficient but on my linux server tables are not updated when I just use --append, on windows it works fine (see edited question above) – Thomas B May 23 '19 at 06:47
  • Oracle OCI driver has some specialities and generic ogr2ogr parameters do not always work. Read https://gdal.org/drv_oci.html and if you find a driver specific option use that. Some examples: overwrite, truncate, srid, dim, geometry_name. – user30184 May 23 '19 at 06:52
  • Right, because GDAL can't create Oracle databases then -update is effectively the only option that can work. I can't say where the difference between Windows and Linux come, but it may also be that you have different versions of the native OCI libraries from Oracle. OCI driver is rather special and sometimes it requires some experiments to get the desired result. At that time I recommend to take notes and save them for the future. Also the Oracle side setting can have an effect, especially on things like character sets and handling dates and times. – user30184 May 23 '19 at 07:01