0

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.

2
  • 1
    I don't think you can do that - just add a psql script to your load procedure
    – Ian Turton
    Jul 28 at 12:47
  • yes that's what I'm doing ... I was just thinking such an option within ogr2ogr would be nice to have. Thanks Jul 28 at 13:24
1

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)"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.