Oracle Gateway To PostgreSQL
This document describes how to create and manage an Oracle database link to a PostgreSQL database, assuming both databases are located on Linux servers.
PostgreSQL server setup
- Create entry in pg_hba.conf file for the Oracle database server host.
Oracle server setup
- yum install unixODBC*
- yum install postgresql-odbc
- odbcinst -j
- odbc_config --odbcini --odbcinstini
- edit /etc/odbcinst.ini to configure the PostgreSQL driver
- edit /etc/odbc.ini to set up a data source for connecting to the PostgreSQL database. You will need:
- a data source name (try to make this match the database name)
- the database name
- the database server
- a database login
- the login password *** Make sure password does not contain a % ***
- the database port number
- use isql to test connection
isql -v <data source name>
Oracle home configuration
- create $ORACLE_HOME/hs/admin/initDSN.ora (where "DSN" is the data source name), using $ORACLE_HOME/hs/admin/initdg4odbc.ora as a model
- include any additional environment variables you may need
- edit $ORACLE_HOME/network/admin/listener.ora to add an entry for the DSN
- edit $ORACLE_HOME/network/admin/tnsnames.ora to add an entry for the DSN
- restart the listener
Oracle database link
- create a user in the Oracle database to own the database link and views to the PostgreSQL data
- try to make the username match the username in the PostgreSQL database
- grant connect, resource, create view, and create database link to the Oracle user
- create the database link.
- It must NOT be a public database link!
- Since the Banner database must have global_names set to true, the name of the database link must match an internal name in the PostgreSQL database. This is most likely NOT the same as the name you entered in /etc/odbc.ini. If you select the wrong name, the link will be created; however, when you query against a table in the link, you will get an error message that will tell you what the correct name should be.
Data security
- create Oracle views to the PostgreSQL data.
- grant select access on the views to Oracle users and/or roles as needed.
References
Accessing PostgreSQL databases using psqlODBC in Oracle: https://www.enterprisedb.com/postgres-tutorials/accessing-postgresql-databases-using-psqlodbc-oracle
---
BTSHowTo
DataAdminHowTo
DB_Administration