1

I wish to convert a layer that has no geometry field from Oracle to the Esri Shape format (DBF file only). I can do it manually from within QGis but I'd like to automate the process and use ogr2ogr (or a similar tool) instead, as I have dozens of such layers.

  • Perhaps some of the methods in this post might help: ogr2ogr convert all shapefiles in a directory – Joseph Oct 26 '16 at 11:49
  • Your question is a bit unclear, do you want to convert from Oracle table to shapefile or Oracle table to dBase (dbf)? – artwork21 Oct 26 '16 at 13:15
  • I have a large number of Oracle database tables that contain no geometry. I'm going to convert them to the Esri format. No SHP files, only the DBF file that contains attribute data. – Matti Siren Oct 26 '16 at 13:52
  • Have you already tried a conversion from OCI to ESRI Shapefile with ogr2ogr? – user30184 Oct 26 '16 at 20:28
  • Yes I tried but ogr2ogr says it "couldn't fetch the requested layer". Maybe because there's no geometry in the layer. I was wondering if there was some switch to overcome this. – Matti Siren Oct 27 '16 at 6:00
2

The following works for me. Here is the input table:

SQL> desc us_cities_n
Name                                     Null?    Type
---------------------------------------- -------- ----------------------------
ID                                                NUMBER
CITY                                              VARCHAR2(42 CHAR)
STATE_ABRV                                        VARCHAR2(2 CHAR)
POP90                                             NUMBER
RANK90                                            NUMBER

The following command makes a dbf file only:

$ ogr2ogr us_cities_n.dbf OCI:scott/tiger@orcl121:us_cities_n

(this is using GDAL/OGR 2.0.1)

  • Hi Albert, thanks for the solution! It was maybe just too simple so I didn't find it myself. :) I could have done this table by table from within QGIS but I'm so lazy I wanted to have an easier way. :) – Matti Siren Oct 28 '16 at 8:52
  • I was surprised too. I first tried it with csv output. Then decided to give it a try for dbf. And it worked :-) – Albert Godfrind Oct 28 '16 at 12:51

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.