基于 opengauss5.0.0 编译时使能了oracle_fdw插件,按照网上的帖子,
创建插件,create server,create user mapping,create foreign table 一路过关斩将走下来,
可以查询oracle外表,可以向oracle外表insert,但是更新的时候报错:
openGauss=# update oracle_test_fdw set name = 'updated second line';
ERROR: no primary key column specified for foreign Oracle table
DETAIL: For UPDATE or DELETE, at least one foreign table column must be marked as primary key column.
HINT: Set the option "key" on the columns that belong to the primary key.
按照提示,问题是我不知道在哪一步,用什么语法设置这个key的column? 文档里也没找到
之前的完整过程如下:
openGauss=# create server oracle_test foreign data wrapper oracle_fdw options(dbserver '172.32.150.13:1521/nlpass01');
CREATE SERVER
openGauss=# create user mapping for postgres server oracle_test options (user 'paastest', password 'Paas1015');
CREATE USER MAPPING
openGauss=# create foreign table oracle_test_fdw(id int, name varchar(64)) server oracle_test options (schema 'PAASTEST',table 'OG_FDW_TEST01');
CREATE FOREIGN TABLE
openGauss=# select oracle_diag();
oracle_diag
---------------------------------------------------------------------------------------------------------
oracle_fdw 2.2.0, PostgreSQL 9.2.4, Oracle client 12.2.0.1.0, ORACLE_HOME=/usr/lib/oracle/12.2/client64
(1 row)
openGauss=# insert into oracle_test_fdw values (2, 'This is the second line');
INSERT 0 1
openGauss=# select * from oracle_test_fdw;
id | name
----+-------------------------
1 | hello nihao
2 | This is the second line
openGauss=# update oracle_test_fdw set name = 'updated second line';
ERROR: no primary key column specified for foreign Oracle table
DETAIL: For UPDATE or DELETE, at least one foreign table column must be marked as primary key column.
HINT: Set the option "key" on the columns that belong to the primary key.
oracle侧表定义为:
create table og_fdw_test01 (id int primary key, name varchar2(64));
insert into og_fdw_test01 values (1, 'hello nihao');
谢谢!
新大陆软件 秦浩
mobile: 17625988619
e-mail:qinhao@newland.com.cn