您的位置:首页 > 数据库 > Oracle

Oracle 11gR2中SQL*Plus中的新设置exitcommit

2017-04-05 16:57 435 查看
--Oracle 11gR2中SQL*Plus中的新设置exitcommit

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.

--默认情况下exitcommit为ON状态
SCOTT@PROD1> show exitcommit
exitcommit ON

--创建表进行对比实验
SCOTT@PROD1> create table t (id number);

Table created.

--插入数据后直接exit退出,发现退出时完成了自动commit
SCOTT@PROD1> insert into t values (1);

1 row created.

SCOTT@PROD1> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@ocm1 ~]$ sqlplus scott/tiger

SQL*Plus: Release 11.2.0.3.0 Production on Wed Apr 5 16:48:58 2017

Copyright (c) 1982, 2011, Oracle.  All rights reserved.

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SCOTT@PROD1> select * from t;

ID
----------
1

--清空数据,并把exitcommit参数置为OFF
SCOTT@PROD1> truncate table t;

Table truncated.

SCOTT@PROD1> set exitcommit off
SCOTT@PROD1> show exitcommit
exitcommit OFF

--插入数据后直接exit退出,发现退出时完成了自动rollback
SCOTT@PROD1> insert into t values (1);

1 row created.

SCOTT@PROD1> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@ocm1 ~]$ sqlplus scott/tiger

SQL*Plus: Release 11.2.0.3.0 Production on Wed Apr 5 16:49:32 2017

Copyright (c) 1982, 2011, Oracle.  All rights reserved.

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SCOTT@PROD1> select * from t;

no rows selected
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  oracle