Saawan
Saawan

Reputation: 383

Problems while Using postgres_fdw

I m getting some problem while using postgres_fdw.

    CREATE SERVER foreign_server
    FOREIGN DATA WRAPPER postgres_fdw
    OPTIONS (host '192.162.0.1', port '5432', dbname 'Test');



    CREATE USER MAPPING FOR postgres
    SERVER foreign_server
    OPTIONS (user 'foreign_user', password 'password');


    CREATE FOREIGN TABLE foreign_table (
    id serial NOT NULL,
    data text)SERVER foreign_server
    OPTIONS (schema_name 'public', table_name 'employee');


    select * from employee  where user ='foreign_user'

Now I can see entries are made to pg_foreign_data_wrapper, pg_foreign_server and pg_foreign_table tables.
But how do I access employee table of remote system.

I mean select * from employee where user ='foreign_user' doesn't give any result. Though it has data in Employee table of remote system.

Any idea please?

Upvotes: 1

Views: 1243

Answers (1)

s87
s87

Reputation: 21

But How do I access employee table of remote system.

You just need to access the foreign table, say "SELECT * FROM foreign_table;".

The procedure seems fine, but your foreign table doesn't have a column named "user", so your query must cause an error.

It would be better to show what has happened actually. Showing actual query and error messages helps us understand where the problem is.

Upvotes: 2

Related Questions