How to connect to localhost with postgres_fdw?

后端 未结 2 2015
长情又很酷
长情又很酷 2021-01-02 16:59

The idea is that I have local database named northwind, and with postgres_fdw I want to connect with another database named test on lo

2条回答
  •  清酒与你
    2021-01-02 17:51

    After many attempts probably I found a proper way to connect:

    CREATE SERVER app_db 
    FOREIGN DATA WRAPPER postgres_fdw 
    OPTIONS (dbname 'test', port '5432', host 'localhost');
    

    Then:

    CREATE USER MAPPING for postgres
    SERVER app_db 
    OPTIONS (user 'postgres', password 'postgres');
    

    And then:

    CREATE FOREIGN TABLE groups
    (
      id serial NOT NULL,
      name character varying(255) NOT NULL,
      version integer DEFAULT 0
    )
     SERVER app_db OPTIONS (schema_name 'public', table_name 'groups')
    

    But is there a solution to check if it's really "remote" connection? Because servers are on the same localhost and I don't know if I can be sure.

提交回复
热议问题