ORA-01940:無法刪除當前已連結的使用者

來源:互聯網
上載者:User

(1)查看使用者的串連狀況

select username,sid,serial# from v$session

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

如下結果:

username          sid                serial#

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

NETBNEW          146             18183
NETBNEW          516              21573
NETBNEW          531              9
WUZHQ             532              4562

(2)找到要刪除使用者的sid,和serial,並刪除

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

如:你要刪除使用者'ZNWY',可以這樣做:

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。

由此可見,WUZHQ這個使用者的session已經被殺死。此時可以安全刪除使用者。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.