简体   繁体   English

使用postgres_fdw时出现问题

[英]Problems while Using postgres_fdw

I m getting some problem while using postgres_fdw . 使用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. 现在,我可以看到对pg_foreign_data_wrapperpg_foreign_serverpg_foreign_table表的输入。
But how do I access employee table of remote system. 但是如何访问远程系统的员工表。

I mean select * from employee where user ='foreign_user' doesn't give any result. 我的意思是select * from employee where user ='foreign_user'不给出任何结果。 Though it has data in Employee table of remote system. 虽然它在远程系统的Employee表中有数据。

Any idea please? 有什么想法吗?

But How do I access employee table of remote system. 但是如何访问远程系统的员工表。

You just need to access the foreign table, say " SELECT * FROM foreign_table; ". 您只需要访问外部表,说“ 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. 该过程似乎很好,但是您的外部表没有名为“ user”的列,因此您的查询必须引起错误。

It would be better to show what has happened actually. 最好显示实际发生的情况。 Showing actual query and error messages helps us understand where the problem is. 显示实际的查询和错误消息有助于我们了解问题所在。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM