1

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.

PolyGeo
65.5k29 gold badges115 silver badges349 bronze badges
asked Jul 28, 2021 at 12:07
2
  • 1
    I don't think you can do that - just add a psql script to your load procedure Commented Jul 28, 2021 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 Commented Jul 28, 2021 at 13:24

1 Answer 1

2

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)"
answered Aug 3, 2021 at 9:12

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.