DB2:非自动提交
1、非实例schema测试:
[db2inst9@th1 ~]$ db2 +C "select * from bbb.bbb"
ID
-----------
1
5
2 record(s) selected.
[db2inst9@th1 ~]$ db2 +C "insert into bbb.bbb values (9)"
DB20000I The SQL command completed successfully.
[db2inst9@th1 ~]$ db2 +C "select * from bbb.bbb"
ID
-----------
1
5
9
3 record(s) selected.
[db2inst9@th1 ~]$ db2 rollback
DB20000I The SQL command completed successfully.
[db2inst9@th1 ~]$ db2 +C "select * from bbb.bbb"
ID
-----------
1
5
2 record(s) selected.
[db2inst9@th1 ~]$ db2 +C "delete from bbb.bbb where id=5"
DB20000I The SQL command completed successfully.
[db2inst9@th1 ~]$ db2 +C "select * from bbb.bbb"
ID
-----------
1
1 record(s) selected.
[db2inst9@th1 ~]$ db2 rollback
DB20000I The SQL command completed successfully.
[db2inst9@th1 ~]$ db2 +C "select * from bbb.bbb"
ID
-----------
1
5
2 record(s) selected.
2、实例schema测试
[db2inst9@th1 ~]$ db2 values current schema
1
--------------------------------------------------------------------------------------------------------------------------------
DB2INST9
1 record(s) selected.
[db2inst9@th1 ~]$ db2 +C "select * from t2"
C1 C2
----------- --------------------
0 record(s) selected.
[db2inst9@th1 ~]$ db2 +C "insert into t2 values (1,'aa')"
DB20000I The SQL command completed successfully.
[db2inst9@th1 ~]$ db2 +C "select * from t2"
C1 C2
----------- --------------------
1 aa
1 record(s) selected.
[db2inst9@th1 ~]$ db2 rollback
DB20000I The SQL command completed successfully.
[db2inst9@th1 ~]$ db2 +C "select * from t2"
C1 C2
----------- --------------------
0 record(s) selected.
[db2inst9@th1 ~]$ db2 +C "insert into t2 values (1,'aa')"
DB20000I The SQL command completed successfully.
[db2inst9@th1 ~]$ db2 +C "insert into t2 values (1,'aa')"
DB20000I The SQL command completed successfully.
[db2inst9@th1 ~]$ db2 commit
DB20000I The SQL command completed successfully.
[db2inst9@th1 ~]$ db2 +C "select * from t2"
C1 C2
----------- --------------------
1 aa
1 aa
2 record(s) selected.
[db2inst9@th1 ~]$ db2 +C "delete from t2 where c1=1"
DB20000I The SQL command completed successfully.
[db2inst9@th1 ~]$ db2 +C "select * from t2"
C1 C2
----------- --------------------
0 record(s) selected.
[db2inst9@th1 ~]$ db2 rollback
DB20000I The SQL command completed successfully.
[db2inst9@th1 ~]$ db2 +C "select * from t2"
C1 C2
----------- --------------------
1 aa
1 aa
=========================================================================================================
DB2:自动提交
db2 => set CURRENT SCHEMA aaa
DB20000I The SQL command completed successfully.
db2 => insert into bbb.bbb values (3)
DB20000I The SQL command completed successfully.
db2 => delete from bbb.bbb where id=3
DB20000I The SQL command completed successfully.
db2 => rollback
DB20000I The SQL command completed successfully.
db2 => select * from bbb.bbb
ID
-----------
1
1 record(s) selected.