PostgreSQL的fdw 實踐

來源:互聯網
上載者:User

標籤:


oracle_fdw:http://francs3.blog.163.com/blog/static/4057672720122354546425/



postgres_fdw:http://www.postgresql.org/docs/9.4/static/postgres-fdw.html

postgres_fdw用來訪問外部的PostgreSQL伺服器。

舉例列示步驟:

  1. 配置外部資料庫伺服器允許遠端存取。

  2. 在本機資料庫伺服器中,建立外部資料表:

postgres=# create extension postgres_fdw;CREATE EXTENSIONpostgres=# create server foreign_server foreign data wrapper postgres_fdw options (host ‘192.168.100.232‘,port ‘5432‘, dbname ‘postgres‘);CREATE SERVERpostgres=# create user postgres_fdw superuser password ‘postgres‘;CREATE ROLEpostgres=# create user mapping for postgres_fdw  server foreign_server options (user ‘postgres‘, password ‘postgres‘); CREATE USER MAPPINGpostgres=# create foreign table lyy_fdw(id int, name varchar)server foreign_server options (schema_name ‘public‘,table_name ‘lyy‘);CREATE FOREIGN TABLE--此時外部資料表建立完畢,進行查詢(已可獲得外部伺服器中的public.lyy表的資料):postgres=# select * from postgres.lyy_fdw; id | name ----+------  1 | lily  2 | lucy 11 | hhhh(3 rows)


3.此後每當外部資料庫伺服器中相應的表資料變化,本機伺服器中的相應外部資料表資料也變化。








PostgreSQL的fdw 實踐

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.