方法一、在sqlnet.ora中设置参数

如需要设置客户端空闲10分钟即被中断,则在sqlnet.ora的末尾添加SQLNET.EXPIRE_TIME=10注:sqlnet.ora文件的路径在$ORACLE_HOME/network/admin下。方法二、Oracle Profile中设置

生产库上执行如下操作:

SQL> col name format a15

SQL> col value format a10

查询resource limit是否开启:

SQL> SELECT name, value FROM gv$parameter WHERE name = 'resource_limit';

NAMEVALUE

--------------- ----------

resource_limitFALSE

如果没有,则开启这个参数:

SQL> ALTER SYSTEM SET RESOURCE_LIMIT=TRUE;

System altered.

SQL> SELECT name, value FROM gv$parameter WHERE name = 'resource_limit';

NAMEVALUE

--------------- ----------

resource_limitTRUE

创建空闲10分钟中止空闲例程的Profile:

SQL>CREATE PROFILE app_user LIMIT IDLE_TIME10;

Profile created.

设置用户的Profile:

SQL>alter user mzh profile app_user;

也可以修改已存在的Profile中的IDLE_TIME:

SQL>ALTER PROFILE DEFAULT LIMIT IDLE_TIME10;

通过本地连接串(通过监听)访问数据库:

C:\Windows\SysWOW64>sqlplus "mzh/mzh"@LOCAL_11G_localhost

SQL*Plus: Release 11.2.0.1.0 Production on星期一9月5 16:41:43 2011

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

连接到:

Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select * from dual;

D

-

X

等待1分钟再执行:

SQL> select * from dual;

select * from dual

*

第1行出现错误:

ORA-02396:超出最大空闲时间,请重新连接