gpt4 book ai didi

postgresql - pgsql_fdw 的选项

转载 作者:行者123 更新时间:2023-11-29 12:47:38 24 4
gpt4 key购买 nike

我正在探索 pgsql_fdw模块,我遇到了以下情况:

我有一个本地数据库,它是远程数据库的副本,但数据不同。开发与生产。我想创建一个指向生产版本的外部表。由于文档表明外部表的名称必须是唯一的,因此我决定创建一个 fdw 模式并将所有外部表放在其中。我执行了:

create foreign table foreign_table(columna bigint, columnb text)  
server foreign_server;

显然 pgsql_fdw 在 fully_qualified 表名之间使用 1 对 1 的映射,当然“fdw.foregin_table”在 foreign_server 上不存在,它是“public.foreign_table”,所以我得到:

ERROR:  could not execute EXPLAIN for cost estimation  
DETAIL: ERROR: schema "fdw" does not exist

documentation CREATE FOREIGN TABLE 有一个选项参数:

OPTIONS ( option 'value' [, ...] )  
Options to be associated with the new foreign table.
The allowed option names and values are specific to each foreign data wrapper
and are validated using the foreign-data wrapper's validator function.
Option names must be unique.

我的问题是:pgsql_fdw 的选项是什么?是否有特定的选项来指定外表名称而不是假设远程和本地相同?

最佳答案

您需要的选项是:

CREATE FOREIGN TABLE your_local_shema.your_local_table (
field_1 int, field_2 int, ...
)
SERVER foreign_server
OPTIONS (SCHEMA_NAME 'your_remote_schema', TABLE_NAME 'your_remote_table')

关于postgresql - pgsql_fdw 的选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10917626/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com