Migrate SPATIAL data from Oracle to Postgresql

后端 未结 2 400
醉话见心
醉话见心 2021-01-03 06:13

I am trying my best to migrate a spatial database from Oracle to Postgresql and failing miserably.

I have tried many different avenues as you can see from my previo

相关标签:
2条回答
  • 2021-01-03 06:42

    The accepted solution didn't work for me.

    Install GDAL/OGR using OSGeo4W, and in Advanced Install mode select gdal-oracle10g.

    Then execute this command:

    ogr2ogr 
    -a_srs {{SRS}} 
    -overwrite -f 
    "PostgreSQL" 
    -nln {{POSTGIS SCHEMA}}.{{POSTGIS TABLE}} 
    PG:"
    host='{{POSTGIS HOST}}' 
    port='{{POSTGIS PORT}}' 
    user='{{POSTGIS USER}}' 
    password='{{POSTGIS PASSWORD}}' 
    dbname='{{POSTGIS DATABASE}}'" 
    OCI:"{{ORACLE USER}}/{{ORACLE PASSWORD}}
    @(DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)
    (HOST = {{ORACLE HOST}})
    (PORT = {{ORACLE PORT}})))
    (CONNECT_DATA = (SID = {{ORACLE SID}})))
    :{{ORACLE SCHEMA}}.{{ORACLE TABLE}}"
    

    replace {{ }} items with your values!

    You need to do this for each table. There is an spreadsheet that can generate these commands for you:

    http://gis-expert.com/wp/2018/09/12/how-to-migrate-spatial-data-from-oracle-to-postgis/

    0 讨论(0)
  • 2021-01-03 07:02

    There are two popular options: open source ogr2ogr or a commercial offering from Safe Software.

    Here is how I'd approach the ogr2ogr solution.

    First, you need to have the right tools: GDAL/OGR. If you are on Unix, compile using the right libraries to get Oracle support (not enabled by default). But I'm going to assume you are on Windows. The simplest way to get open source geospatial tools is with OSGeo4W. To enable Oracle support for GDAL/OGR, you need to also select the gdal-oracle10g package in setup.exe with the "Advanced Install" mode. More info about the Oracle package is at this page, and note that you also need to supply the non-free OCI.DLL. When working, you should see the driver name appear with ogr2ogr --formats.

    Your basic command from the OSGeo4W Shell should look something like:

    ogr2ogr -f "PostgreSQL" PG:"host=localhost user=someuser dbname=somedb password=password port=5432" OCI:someuser/password layername
    

    Here is more info on GDAL/OGR:

    • ogr2ogr command usage: http://www.gdal.org/ogr2ogr.html
    • Oracle Driver: http://www.gdal.org/drv_oci.html
    • PostgreSQL/PostGIS driver: http://www.gdal.org/drv_pg.html
    0 讨论(0)
提交回复
热议问题