Postgresql/admin

postgresql에서 외부 데이터 조회하는 방법

dbavayne 2025. 3. 13. 16:17
  • 목적 : postgresql에서 oracle 또는 mysql 데이터를 조회한다.
  • 방안 : oracle_fdw, mysql_fdw 활용

주요 기능

  1. 데이터 조회 및 수정
  2. SQL 쿼리의 통합 실행
  3. 데이터 통합

설치방법

  1. oracle_fdw
git clone https://github.com/laurenz/oracle_fdw.git
cd oracle_fdw
make
sudo make install

CREATE EXTENSION oracle_fdw;

CREATE SERVER oracle_server
FOREIGN DATA WRAPPER oracle_fdw
OPTIONS (dbserver '//oracle_host:1521/service_name');

CREATE USER MAPPING FOR postgres
SERVER oracle_server
OPTIONS (user 'oracle_user', password 'oracle_password');

CREATE FOREIGN TABLE oracle_table (
    column1 INTEGER,
    column2 VARCHAR
)
SERVER oracle_server
OPTIONS (schema 'oracle_schema', table 'oracle_table');
  1. mysql_fdw
git clone https://github.com/EnterpriseDB/mysql_fdw.git
cd mysql_fdw
make
sudo make install

CREATE EXTENSION mysql_fdw;

CREATE SERVER mysql_server
FOREIGN DATA WRAPPER mysql_fdw
OPTIONS (host 'mysql_host', port '3306', dbname 'mysql_db');

CREATE USER MAPPING FOR postgres
SERVER mysql_server
OPTIONS (user 'mysql_user', password 'mysql_password');

CREATE FOREIGN TABLE mysql_table (
    column1 INTEGER,
    column2 VARCHAR
)
SERVER mysql_server
OPTIONS (table 'mysql_table');

'Postgresql > admin' 카테고리의 다른 글

sql plan 변경 모니터링  (0) 2025.03.13
기본 모니터링 쿼리  (0) 2025.02.13
VACUUM type 에 따른 redo 발생량 차이  (0) 2024.11.13