问 insert into t(x,y) values(11.'joe');
update t set x=50 where ...;
rollback work;执行后insert语句是否生效?
测试如下:
SQL> select * from t;
X Y
---------- --------------------
1 hello
2 hello
3 hello
4 hello
5 hello
6 hello
7 hello
8 hello
9 hello
110 hello
11 hello
X Y
---------- --------------------
12 hello
13 hello
14 hello
15 hello
16 hello
17 hello
18 hello
19 hello
30 hello
21 hello
22 hello
X Y
---------- --------------------
23 hello
24 hello
25 hello
26 hello
27 hello
28 hello
29 hello
30 hello
31 hello
32 hello
33 hello
X Y
---------- --------------------
34 hello
35 hello
36 hello
37 hello
38 hello
39 hello
40 hello
41 hello
42 hello
43 hello
44 hello
X Y
---------- --------------------
45 hello
46 hello
47 hello
48 hello
49 hello
50 hello
已选择50行。
SQL> insert into t(x,y) values(1111,'test');
已创建 1 行。
SQL> begin
2 update t
3 set x=500 where x=50;
4 rollback work;
5 end;
6 /
PL/SQL 过程已成功完成。
SQL> select * from t where x=111;
未选定行
SQL> select * from t where x=500;
未选定行
说明数据并没有commit;
原因:insert 语句和该语句块都是同一个数据库session的一部分,属于同一个事务!
[@more@]来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/264678/viewspace-923625/ ,如需转载,请注明出处,否则将追究法律责任。