CREATE SERVER foreign_server
FOREIGN DATA WRAPPER postgres_fdw
OPTIONS (host '10.68.5.192', port '5432', dbname 'postgres');
CREATE USER MAPPING FOR postgres
SERVER foreign_server
OPTIONS (user 'postgres', password 'pgpassword');
CREATE FOREIGN TABLE foreign_table (
id integer NOT NULL,
data text
)
SERVER foreign_server
OPTIONS (schema_name 'some_schema', table_name 'some_table');
CREATE FOREIGN TABLE foreign_table (
id integer NOT NULL,
data text
)
CREATE FOREIGN TABLE foreign_table ( "id" int4 NOT NULL, "memo" VARCHAR ( 100 ) COLLATE "pg_catalog"."default", "insert_time" TIMESTAMP ( 6 ) ) SERVER foreign_server OPTIONS ( SCHEMA_NAME'public', TABLE_NAME't1' );
)
--oracle
CREATE SERVER oradb FOREIGN DATA WRAPPER oracle_fdw OPTIONS ( dbserver '//10.68.5.192:1521/msunora' );
--GRANT USAGE ON FOREIGN SERVER oradb TO pguser;
CREATE USER MAPPING FOR postgres SERVER oradb
OPTIONS (user 'sfx', password 'password');
--SQLSERVER
CREATE SERVER mssql_svr
FOREIGN DATA WRAPPER tds_fdw
OPTIONS (servername '10.68.4.34', port '1433', database 'db', tds_version '7.1');
CREATE USER MAPPING FOR postgres SERVER mssql_svr
OPTIONS (username 'sa', password 'password');
CREATE FOREIGN TABLE foreign_table ( "id" int4 NOT NULL, "memo" VARCHAR ( 100 ) COLLATE "pg_catalog"."default", "insert_time" TIMESTAMP ( 6 ) ) SERVER foreign_server OPTIONS ( SCHEMA_NAME'public', TABLE_NAME't1' );
)
IMPORT FOREIGN SCHEMA dbo
EXCEPT (DEPTS)
FROM SERVER mssql_svr
INTO public
OPTIONS (import_default 'true');