--- title: "postgres_fdw 사용" slug: "clouddbforpostgresql-postgresqlfdw" updated: 2026-09-17T09:07:41Z published: 2026-09-17T09:07:41Z canonical: "guide.ncloud-docs.com/clouddbforpostgresql-postgresqlfdw" stale: true --- > ## Documentation Index > Fetch the complete documentation index at: https://guide.ncloud-docs.com/llms.txt > Use this file to discover all available pages before exploring further. # postgres_fdw 사용 VPC 환경에서 이용 가능합니다. Cloud DB for PostgreSQL에서 postgres_fdw extension을 제공하며 아래 사용 가이드를 참고해 주십시오. ## console을 통한 extension 설치 Cloud DB For PostgreSQL에서는 superuser 권한을 제공하지 않으므로 console을 통해 superuser 권한이 필요한 extension을 설치할 수 있습니다. 자세한 내용은 아래 가이드를 참고해 주시기 바랍니다. - [Extension 설치](https://guide.ncloud-docs.com/release-20260917/docs/clouddbforpostgresql-postgresqlextension#extension-%EC%84%A4%EC%B9%98) ## ACG 설정 DB 서버간 통신을 위해 ACG 설정이 필요합니다. 자세한 내용은 아래 가이드를 참고해 주십시오. - [ACG 설정 가이드](https://guide.ncloud-docs.com/release-20260917/docs/server-acg-vpc) ## DB user 관리 및 접근제어 설정 외부에서 접근하거나 Cloud DB For PostgreSQL 간 원활한 통신을 위해 DB user에 대한 접근제 어 설정이 필요합니다. 자세한 내용은 아래 가이드를 참고해 주십시오. - [user 관리](https://guide.ncloud-docs.com/release-20260917/docs/clouddbforpostgresql-postgresqlserver#db-user-%EA%B4%80%EB%A6%AC) #### Cloud DB For PostgreSQL 간 통신 ![postgres_fdw_extension](https://cdn.document360.io/6998976f-9d95-4df8-b847-d375892b92c2/Images/Documentation/postgres_fdw_extension.png?sv=2026-02-06&spr=https&st=2026-10-26T17%3A47%3A48Z&se=2026-10-26T18%3A47%3A48Z&sr=c&sp=r&sig=Efecd6AR8lklznfkEXiLzE%2Ft2vfO9yrI%2Bs1xw1mvwA4%3D) console을 통해 Cloud DB for PostgreSQL > DB Server에서 클러스터를 선택합니다. 확인되는 private domain을 nslookup을 수행하거나 사설 ip를 확인합니다. ``` nslookup {private domain} Non-authoritative answer: 이름: {private domain} Address: xxx.xxx.xxx.xxx ``` 확인된 private ip를 이용해 접근제어를 설정합니다. ![postgres_fdw_db_user](https://cdn.document360.io/6998976f-9d95-4df8-b847-d375892b92c2/Images/Documentation/postgres_fdw_db_user.png?sv=2026-02-06&spr=https&st=2026-10-26T17%3A47%3A48Z&se=2026-10-26T18%3A47%3A48Z&sr=c&sp=r&sig=Efecd6AR8lklznfkEXiLzE%2Ft2vfO9yrI%2Bs1xw1mvwA4%3D) ## postgres_fdw 사용 예시 위의 절차를 모두 진행했다고 가정합니다. #### source DB 정보 예시 - DB명 : testdb - DB owner : testappo - private ip : 10.0.0.6 - DB 포트 : 5432 #### target DB 정보 예시 - DB명 : testdb - DB owner : testappo #### source DB에서 스키마 및 데이터 생성 데이터를 조회할 remote 서버로 스키마 및 테이블 생성 그리고 데이터를 insert합니다. ``` create schema test; create table test.test_table(aa int , bb text); insert into test.test_table(aa,bb) values(1,'a'); insert into test.test_table(aa,bb) values(2,'b'); insert into test.test_table(aa,bb) values(3,'c'); insert into test.test_table(aa,bb) values(4,'d'); ``` #### target DB에서 postgres_fdw 설정 및 조회 source DB에 있는 테이블을 조회하기 위해 postgres_fdw 설정을 진행합니다. 아래 예시의 OPTIONS에는 source DB에 대한 정보를 입력합니다. ``` #### 스키마를 생성합니다. create schema test; #### postgres_fdw가 설치된 DB에 DB owner로 접속 후 "postgres_server"라는 이름으로 FOREIGN DATA WRAPPER를 생성합니다. CREATE SERVER postgres_server FOREIGN DATA WRAPPER postgres_fdw OPTIONS (host '10.0.0.6', port '5432', dbname 'testdb'); #### 생성된 FDW 확인 select * from pg_foreign_data_wrapper; #### db user(role)에 대한 user mapping 설정 -- target DB에 생성된 role : testappo -- source DB에 생성된 role : testappo CREATE USER MAPPING FOR testappo SERVER postgres_server OPTIONS (user 'testappo', password '******'); #### user 맵핑 생성확인 select * from pg_user_mappings #### foreigin tabler 생성 CREATE FOREIGN TABLE test.test_table_fw ( aa int, bb text ) SERVER postgres_server OPTIONS ( schema_name 'test', table_name 'test_table'); #### foreign table 확인 select * from pg_foreign_table; SELECT * FROM information_schema.foreign_tables; #### 설정한 FDW를 이용해 조회 select * from test.test_table_fw; ```