1、用dba角色的用户登陆,进行解锁,先设置具体时间格式,以便查看具体时间
SQL> alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss'; Session altered.
2、查看具体的被锁时间
SQL> select username,lock_date from dba_users where username='TEST';
USERNAME LOCK_DATE TEST 2009-03-10 08:51:03
3、解锁
SQL> alter user test account unlock;
User altered.
4、查看是那个ip造成的test用户被锁
查看$ORACLE_HOME/network/admin/log/listener.log日志
10-MAR-2009 08:51:03 * (CONNECT_DATA=(SID=lhoms)(SERVER=DEDICATED)(CID=(PROGRAM=oracle)(HOST=omstestdb)(USER=oraoms))) * (ADDRESS=(PROTOCOL=tcp)(HOST=10.69.1.11)(PORT=49434)) * establish * lhoms * 0
10-MAR-2009 08:51:03 * (CONNECT_DATA=(SID=lhoms)(SERVER=DEDICATED)(CID=(PROGRAM=oracle)(HOST=omstestdb)(USER=oraoms))) * (ADDRESS=(PROTOCOL=tcp)(HOST=10.69.1.11)(PORT=49435)) * establish * lhoms * 0
这样可知是上面10.69.1.11的ip尝试多次失败登陆造成的被锁 注: 一般数据库默认是10次尝试失败后锁住用户
1、查看FAILED_LOGIN_ATTEMPTS的值
select * from dba_profiles where RESOURCE_NAME = 'FAILED_LOGIN_ATTEMPTS';
2、修改为30次
alter profile default limit FAILED_LOGIN_ATTEMPTS 30;
3、修改为无限次(为安全起见,不建议使用)
alter profile default limit FAILED_LOGIN_ATTEMPTS unlimited;
Oracle数据库操作中,我们有时会用到锁表查询以及解锁和kill进程等操作,那么这些操作是怎么实现的呢?本文我们主要就介绍一下这部分内容。
(1)锁表查询的代码有以下的形式:
select count(*) from v$locked_object;
select * from v$locked_object;
(2)查看哪个表被锁
select b.owner,b.object_name,a.session_id,a.locked_mode from v$locked_object a,dba_objects b where b.object_id = a.object_id;
(3)查看是哪个session引起的
select b.username,b.sid,b.serial#,logon_time from v$locked_object a,v$session b where a.session_id = b.sid order by b.logon_time;
(4)杀掉对应进程
执行命令:alter system kill session'1025,41';
其中1025为sid,41为serial#.
查询那个程序导致的
SELECT v.program,v.* FROM v$session v where serial# = '9' and sid = 586
文章来源:https://www.cnaaa.net,转载请注明出处:https://www.cnaaa.net/archives/11621