Configure the fdw--between postgres9.3 to realize the mutual visits between different postgres databases

Source: Internet
Author: User
Tags wrapper postgres database

The following is the installation, configuration, use of FDW to achieve Postgres database mutual access method, reproduced annotated Source:

1, source installation FDW support (requires database source installation)

Cd/usr/local/postgresql-9.3.2/contrib/postgres_fdw
Make
Su
Make install
2. Create FDW extension (log in to Super User database)
\c Postgres Postgres
Create extension POSTGRES_FDW;


3, Authorization (the use of the module to grant user test)
GRANT USAGE on FOREIGN DATA WRAPPER POSTGRES_FDW to test;


4. Create server (log in to database with normal user, create server, connect target database address: 192.168.109.10, Database: D_test, Port: 1921)
\c d_test Test
Create server Srv_test foreign data wrapper POSTGRES_FDW options (host ' 192.168.109.10 ', dbname ' d_test ', Port ' 1921 ');


5. Create User mappings (map the remote database user test and password to the created server)
Create user mapping for test server srv_test options (user ' test ', password ' test ');


6. Create remote table (create local table, point to remote database, can specify schema:test1 of remote table)
Create foreign table L_T3 (C1 int,c2 varchar) server srv_test options (schema_name ' test1 ', table_name ' T3 ');

7. Testing
SELECT * from L_t3;
INSERT into L_T3 values (2.2222,2);

Configure the fdw--between postgres9.3 to realize the mutual visits between different postgres databases

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.