PostgreSQl事务
前提
先确定SequoiaDB已经开始事务功能,此次测试时,已经将11830节点,即gruop1数据组开启了事务功能。
如果未开启,可以去SequoiaDB_HOME/conf/local/11830/sdb.conf中,将transactionon=true
create server sdb_server_tran foreign data wrapper sdb_fdw options(address 'node-2:11830, node-3:11830, node-4:11830', service '11830', user 'sdbadmin', password 'sdbadmin', transaction 'on');
// 建表语句,重点注意数据类型,必须对应上!否则会连接失败
create foreign table test2(name text, id int) server sdb_server_tran options( collectionspace 'foo', collection 'bar', decimal 'on');
测试
select * from test2;
name | id
------+----
aa | 12
(1 row)
begin;
insert into test2 values('aaa',1231);
INSERT 0 1
foo=# select * from test2;
name | id
------+------
aa | 12
aaa | 1231
(2 rows)
rollback;
select * from test2;
name | id
------+----
aa | 12
(1 row)