zoukankan      html  css  js  c++  java
  • ORA-01940无法删除当前已连接用户

    1)查看用户的连接状况

    select username,sid,serial# from v$session

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

    如下结果:

    username          sid                serial#

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

    NETBNEW          513              22974
    NETBNEW          514              18183
    NETBNEW          516              21573
    NETBNEW          531              9
    WUZHQ             532              4562

    (2)找到要删除用户的sid,和serial,并删除

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

    如:你要删除用户'WUZHQ',可以这样做:

    alter system kill session'532,4562'

    (3)删除用户

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

    drop user username cascade

    (**)如果在drop 后还提示ORA-01940:无法删除当前已链接的用户,说明还有连接的session,可以通过查看session的状态来确定该session是否被kill 了,用如下语句查看:

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

    select saddr,sid,serial#,paddr,username,status from v$session where username is not null

    结果如下(以我的库为例):

     saddr                     sid           serial#            paddr              username              status

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

    564A1E28              513           22974            569638F4        NETBNEW             ACTIVE
    564A30DC              514          18183            569688CC        NETBNEW            INACTIVE
    564A5644              516           21573            56963340        NETBNEW            INACTIVE
    564B6ED0              531           9                   56962D8C        NETBNEW            INACTIVE
    564B8184              532          4562               56A1075C        WUZHQ                KILLED

    status 为要删除用户的session状态,如果还为inactive,说明没有被kill掉,如果状态为killed,说明已kill。

  • 相关阅读:
    几个论坛上看到的2015小米笔试题
    Line(扩展欧几里得)
    MapReduce编程之倒排索引
    annotation(@Retention@Target)详解
    【JEECG技术文档】JEECG平台对外接口JWT应用文档V3.7.2
    jeecg 模糊查询
    jeecg下实现自动默认模糊查询
    The packaging for this project did not assign a file to the build artifact
    Maven添加本地Jar包
    maven 如何引入本地jar包
  • 原文地址:https://www.cnblogs.com/wushuang0608/p/8405250.html
Copyright © 2011-2022 走看看