Using ogr2ogr to import shapefile into PostGIS, I would like to be able to use specific SQL statements (ex: create index, alter column, add constraint, ...) within my ogr2ogr command line, to be applied to my output PostGIS table. At the moment I have to make the dedicated SQL requests within PostgreSQL, apart from my ogr2ogr call. I though it could be part of the -lco options, or -sql, but I didn't manage to get it work.
1 Answer
You cannot do such things with ogr2ogr but once you have the table created you can use ogrinfo https://gdal.org/programs/ogrinfo.html with the -sql
parameter.
ogrinfo [postgis_connection] -sql "create index new_idx on my_table (column_name)"
psql
script to your load procedure