zoukankan      html  css  js  c++  java
  • oracle_解锁表_解锁用户

    1、解锁用户

    以dba身份登录   sqlplus / as sysdba

     alter user scott account unlock;

    2、解锁表

    alter   system   kill   session

    <!----1.查出锁定object的session的信息以及被锁定的object名------------------------------------>

    SELECT l.session_id sid, s.serial#, l.locked_mode,l.oracle_username,  l.os_user_name,s.machine, s.terminal, o.object_name, s.logon_time  

    FROM v$locked_object l, all_objects o, v$session s  

    WHERE l.object_id = o.object_id

     AND l.session_id = s.sid  

    ORDER BY sid, s.serial# ;

    <!---------------------2.查出锁定表的session的 sid, serial#,os_user_name, machine name, terminal和

    执行的语句 --比上面那段多出sql_text和action ----------------------------------------------------------->

    SELECT l.session_id sid, s.serial#, l.locked_mode, l.oracle_username, s.user#,  l.os_user_name,s.machine, s.terminal,a.sql_text, a.action

     FROM v$sqlarea a,v$session s, v$locked_object l  

    WHERE l.session_id = s.sid

     AND s.prev_sql_addr = a.address  

    ORDER BY sid, s.serial#;  

    <!-------------------------3.查出锁定表的sid, serial#,os_user_name, machine_name, terminal,锁的type,mode ------------------------------------------------------------>

    SELECT s.sid, s.serial#, s.username, s.schemaname, s.osuser, s.process, s.machine,  s.terminal, s.logon_time, l.type

     FROM v$session s, v$lock l

     WHERE s.sid = l.sid  

    AND s.username IS NOT NULL  

    ORDER BY sid;    

     <!--------杀锁命令---------->  

      alter system kill session 'sid,serial#';    

      alter system kill session '3,21395';

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

    alter system kill session 'sid,serial#'  SELECT /*+ rule */ s.username,  decode(l.type,'TM','TABLE LOCK',  'TX','ROW LOCK',  NULL) LOCK_LEVEL,  o.owner,o.object_name,o.object_type,  s.sid,s.serial#,s.terminal,s.machine,s.program,s.osuser  

    FROM v$session s,v$lock l,dba_objects o

     WHERE l.sid = s.sid

     AND l.id1 = o.object_id(+)  AND s.username is NOT NULL

  • 相关阅读:
    CentOS7配置RAID10
    CentOS7配置RAID5笔记
    CentOS7改主机名hostname
    CentOS7设置光盘镜像为本地yum源
    VMware安装Windows Server 2008
    VMware安装CentOS7
    xss漏洞介绍
    pakichu-暴力破解
    搭建xcode9的IOS开发环境
    dvwa之xss
  • 原文地址:https://www.cnblogs.com/cphmvp/p/3302269.html
Copyright © 2011-2022 走看看