--- title: "postgres_fdw 사용" slug: "clouddbforpostgresql-postgres-fdw-use" updated: 2026-08-20T09:03:30Z published: 2026-08-20T09:03:30Z canonical: "guide-gov.ncloud-docs.com/clouddbforpostgresql-postgres-fdw-use" --- > ## Documentation Index > Fetch the complete documentation index at: https://guide-gov.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을 제공합니다. ## 콘솔을 통한 extension 설치 Cloud DB For PostgreSQL에서는 superuser 권한을 제공하지 않으므로 콘솔을 통해 superuser 권한이 필요한 extension을 설치할 수 있습니다. 자세한 내용은 아래 가이드를 참조해 주시기 바랍니다. * [Extension 설치](/docs/extension) ## ACG 설정 DB 서버 간 통신을 위해 ACG 설정이 필요합니다. 자세한 내용은 아래 가이드를 참조해 주십시오. * [ACG 설정 가이드](/docs/compute-compute-2-3-vpc) ## DB User 관리 및 접근제어 설정 외부에서 접근하거나 Cloud DB For PostgreSQL 간 원활한 통신을 위해 DB 사용자에 대한 접근제어 설정이 필요합니다. 자세한 내용은 아래 가이드를 참조해 주십시오. * [DB User 관리](/docs/clouddbforpostgresql-postgresqlserver#DBUser관리) #### Cloud DB For PostgreSQL 간 통신 ![postgres_fdw_extension_gov](https://cdn.document360.io/f2d93c92-8957-408f-94df-b9b370f76a32/Images/Documentation/postgres_fdw_extension_gov.png){height="80%" width="80%"} 콘솔을 통해 Cloud DB for PostgreSQL > DB Server에서 클러스터를 선택합니다. 확인되는 private domain을 nslookup을 수행하거나 사설 IP를 확인합니다. ```sql nslookup {private domain} Non-authoritative answer: 이름: {private domain} Address: xxx.xxx.xxx.xxx ``` 확인된 사설 IP를 이용해 접근제어를 설정합니다. ![postgres_fdw_db_user](https://cdn.document360.io/f2d93c92-8957-408f-94df-b9b370f76a32/Images/Documentation/postgres_fdw_db_user.png){height="80%" width="80%"} ## 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합니다. ```sql 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에 대한 정보를 입력합니다. ```sql #### 스키마를 생성합니다. 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; ```