exitcommit
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
今天做實驗時,用的是sqlplus,插入一條資料後,沒有提交誤關了sqlplus,重新登入後,發現這條資料已經插入了,下面模擬這個過程:
SQL> create table tt(id number);
表已建立。
SQL> insert into tt values(3);
已建立 1 行。
SQL> exit
從 Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options 斷開
[oracle@localhost ~]$ sqlplus hr/hr
SQL*Plus: Release 11.2.0.1.0 Production on 星期日 5月 17 00:09:23 2015
Copyright (c) 1982, 2009, Oracle. All rights reserved.
連線到:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> select * from tt;
ID
----------
3
SET EXITC[OMMIT] {ON | OFF}
Specifies whether the default EXIT behavior is COMMIT or ROLLBACK.
The default setting is ON, which means that work is committed on exit, whether you expected it to be committed or not. Set EXITCOMMIT OFF to rollback work on exit.
shows the exit action associated with combinations of SET commands (AUTOCOMMIT & EXITCOMMIT) and the EXIT command.
Table 12-5 Exit Behavior: AUTOCOMMIT, EXITCOMMIT, EXIT
AUTOCOMMIT | EXITCOMMIT | EXIT | Exit Behavior |
---|---|---|---|
ON |
ON |
- |
COMMIT |
ON |
OFF |
- |
COMMIT |
OFF |
ON |
- |
COMMIT |
OFF |
OFF |
- |
ROLLBACK |
ON |
ON |
COMMIT |
COMMIT |
ON |
ON |
ROLLBACK |
COMMIT |
ON |
OFF |
COMMIT |
COMMIT |
ON |
OFF |
ROLLBACK |
COMMIT |
OFF |
ON |
COMMIT |
COMMIT |
OFF |
ON |
ROLLBACK |
ROLLBACK |
OFF |
OFF |
COMMIT |
COMMIT |
OFF |
OFF |
ROLLBACK |
ROLLBACK |
當我改成set exitcommit off:
SQL> select * from tt;
ID
----------
3
SQL> insert into tt values(0);
已建立 1 行。
SQL> EXIT
從 Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options 斷開
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> select * from tt;
ID
----------
3
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29876893/viewspace-1658054/,如需轉載,請註明出處,否則將追究法律責任。