我需要在特定时间drop一个oracle的user,但是如果有人用该user登录中,就会drop失败。
希望有一个自动执行的脚本/程序,检测是否有会话存在,若有,则断开它们,然后drop该user。
请问如何检测会话存在与否并断开?

解决方案 »

  1.   

    1.select * from v$session
    where username=drop_user_name
    如果有则
    2.alter system kill session 'C.sid,C.serial#'
    3.drop user drop_user_name
      

  2.   

    1. alter system kill session
    2. Oracle自带的orakill,可以同时释放使用的资源Usage:  orakill sid thread  where sid    = the Oracle instance to target
            thread = the thread id of the thread to kill  The thread id should be retrieved from the spid column of a query such as:        select spid, osuser, s.program from
            v$process p, v$session s where p.addr=s.paddr