繁体   English   中英

如何使用 postgres_fdw 设置外部表的权限?

[英]How to set up permissions on foreign table using postgres_fdw?

源数据位于数据库公共模式中的表中(参考 pg 文档: https : //www.postgresql.org/docs/current/postgres-fdw.html ):

create table keys (
    id varchar not null,
    keyname varchar not null,
    created timestamp default current_timestamp not null,
    modified timestamp default current_timestamp not null
);

引用用户/模式/数据库是vids / public / vids

  1. 设置服务器连接
CREATE SERVER keys
        FOREIGN DATA WRAPPER postgres_fdw
        OPTIONS (host '1.2.3.4', port '5432', dbname 'keys');
  1. 创建用户映射
CREATE USER MAPPING FOR vids
        SERVER keys
        OPTIONS (user 'keys', password 'keys');
  1. 创建表映射
create foreign table keys (
    id varchar not null,
    keyname varchar not null,
    created timestamp default current_timestamp not null,
    modified timestamp default current_timestamp not null
) server keys options (schema_name 'public', table_name 'keys');
  1. 尝试当作为西元西元DB连接来访问外部表:
vids=> select * from keys;
ERROR:  permission denied for foreign table keys

鉴于用户密钥是外部数据库中密钥表的所​​有者,我不明白。 这里应该做什么?

来自@jjanes 的评论:

该错误消息表明问题是在本地端”。外部表的地方repfresentation由nowned vidsvids没有权限给它,所以它从来没有得到足够远弄清楚,如果keys访问keys上外国

所以对我的步骤的更正是:

 grant all on table keys to clips;

暂无
暂无

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

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