SQL> select * from v$version where rownum=1;
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 断开
[[email protected] ~]$ 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
查了一下文档,这是11gR2 sqlplus中新添的内容:http://docs.oracle.com/cd/E11882_01/server.112/e16604/ch_twelve040.htm
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.
Table 12-5 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 on;
当我改成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