本篇内容主要讲解“Oracle和PostgreSQL在事务处理上面有哪些区别”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“Oracle和PostgreSQL在事务处理上面有哪些区别”吧!
Oracle
Oracle数据库,在同一个事务中的多个语句,如某个语句执行出错,该语句不影响其他语句的执行,如事务提交,则执行成功语句会持久化到DB中。
测试脚本:
TEST-orcl@server4>drop table tbl3;
Table dropped.
TEST-orcl@server4>create table tbl3(var varchar(2),fixed char(2));
Table created.
TEST-orcl@server4>
TEST-orcl@server4>insert into tbl3 values('1','1');
1 row created.
TEST-orcl@server4>insert into tbl3 values('2','2');
1 row created.
TEST-orcl@server4>insert into tbl3 values('测试x3','测试x3');
insert into tbl3 values('测试x3','测试x3')
*
ERROR at line 1:
ORA-12899: value too large for column "TEST"."TBL3"."VAR" (actual: 6, maximum:
2)
TEST-orcl@server4>insert into tbl3 values('4','4');
1 row created.
TEST-orcl@server4>
TEST-orcl@server4>commit;
Commit complete.
TEST-orcl@server4>
TEST-orcl@server4>select * from tbl3;
VA FI
-- --
1 1
2 2
4 4
TEST-orcl@server4>
PG
PG数据库,在同一个事务中的多个语句,如某个SQL语句执行出错,则就算在其后执行commit,事务也会回滚。如在该出错语句之后执行其他DML语句,则会报错。
testdb=# drop table if exists tbl3;
tbl3;DROP TABLE
testdb=# create table tbl3(var varchar(2),fixed char(2));
CREATE TABLE
testdb=#
testdb=# begin;
BEGIN
testdb=#
testdb=# insert into tbl3 values('1','1');
INSERT 0 1
testdb=# insert into tbl3 values('2','2');
INSERT 0 1
testdb=# insert into tbl3 values('测试3','测试3');
ERROR: value too long for type character varying(2)
testdb=# insert into tbl3 values('4','4');
ERROR: current transaction is aborted, commands ignored until end of transaction block
testdb=#
testdb=# commit;
ROLLBACK
testdb=#
testdb=# select * from tbl3;
var | fixed
-----+-------
(0 rows)
到此,相信大家对“Oracle和PostgreSQL在事务处理上面有哪些区别”有了更深的了解,不妨来实际操作一番吧!这里是亿速云网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!