Migrate SPATIAL data from Oracle to Postgresql

六月ゝ 毕业季﹏ 提交于 2019-11-30 15:24:36
Mike T

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:

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/

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!