[20190721]12CR2 max_idle_time 2.txt

来源:这里教程网 时间:2026-03-03 13:59:22 作者:

[20190721]12CR2 max_idle_time 2.txt --//昨天测试max_idle_time,我自己有点不理解oracle为什么会加入这样的参数。 --//首先这个参数仅仅在system级别上测试,而不是在session级别,缺乏灵活性。 --//查看官方文档如下: https://docs.oracle.com/en/database/oracle/oracle-database/18/refrn/MAX_IDLE_TIME.html#GUID-9E26A81D-D99E-4EA8-88DE-77AF68482A20 1.184 MAX_IDLE_TIME MAX_IDLE_TIME specifies the maximum number of minutes that a session can be idle. After that point, the session is automatically terminated. Property                Description ---------------------------------------------- Parameter type         Integer Default value          0 Modifiable             ALTER SYSTEM Modifiable in a PDB    Yes Range of values        0 to the maximum integer. The value of 0 indicates that there is no limit. Basic                  No Oracle RAC             Different instances can use different values. ---------------------------------------------- --//补充测试有事务的情况。 1.环境: SCOTT@test01p> @ ver1 PORT_STRING                    VERSION        BANNER                                                                               CON_ID ------------------------------ -------------- -------------------------------------------------------------------------------- ---------- IBMPC/WIN_NT64-9.1.0           12.2.0.1.0     Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production              0 SCOTT@test01p> alter system set max_idle_time=1 scope=memory; System altered. --//退出再进入。 2.测试一: SCOTT@test01p> select sysdate from dual ; SYSDATE ------------------- 2019-07-21 07:35:28 --//等30秒后。中间乱按一些字符在删除(或者直接输入以上命令),等2分钟之后执行(不要超过2分30秒执行): SCOTT@test01p> select sysdate from dual ; SYSDATE ------------------- 2019-07-21 07:37:33 --//可以发现并没有断开。继续中间在界面上按鼠标按钮。等2分钟之后执行: SCOTT@test01p> select sysdate from dual ; select sysdate from dual * ERROR at line 1: ORA-03113: end-of-file on communication channel Process ID: 2604 Session ID: 251 Serial number: 62541 --//可以开始记时从有键盘输入算起。超时最小要2*MAX_IDLE_TIME才会终止连接。 3.测试二,如果有事务情况如下: SCOTT@test01p> create table t as select level id from dual connect by level<=10; Table created. SCOTT@test01p> update t set id=id+1; 10 rows updated. SCOTT@test01p> select sysdate from dual ; SYSDATE ------------------- 2019-07-21 07:49:17 SCOTT@test01p> host sleep 120 SCOTT@test01p> select sysdate from dual ; select sysdate from dual * ERROR at line 1: ORA-03113: end-of-file on communication channel Process ID: 908 Session ID: 181 Serial number: 31136 --//重新登录: SCOTT@test01p> select * from t;         ID ----------          1          2          3          4          5          6          7          8          9         10 10 rows selected. --//事务回滚了。

相关推荐