Dropping connected users in Oracle database

后端 未结 12 1766
执念已碎
执念已碎 2020-12-12 21:49

I want to drop some users in Oracle DB using sqlplus but I am getting error:

SQL> DROP USER test CASCADE;
DROP USER test CASCADE
*
ERROR at line 1:
ORA-01         


        
相关标签:
12条回答
  • 2020-12-12 22:47

    Solution :

    login as sysdaba:

    sqlplus  / as sysdba
    

    then:

    sql>Shutdown immediate;
    
    sql>startup restrict;
    
    sql>drop user TEST cascade;
    

    If you want to re-activate DB normally either reset the server or :

    sql>Shutdown immediate;
    
    sql>startup;
    

    :)

    0 讨论(0)
  • 2020-12-12 22:47

    Do a query:

    SELECT * FROM v$session s;

    Find your user and do the next query (with appropriate parameters):

    ALTER SYSTEM KILL SESSION '<SID>, <SERIAL>';

    0 讨论(0)
  • 2020-12-12 22:47

    I was trying to follow the flow described here - but haven't luck to completely kill the session.. Then I fond additional step here:
    http://wyding.blogspot.com/2013/08/solution-for-ora-01940-cannot-drop-user.html

    What I did:
    1. select 'alter system kill session ''' || sid || ',' || serial# || ''';' from v$session where username = '<your_schema>'; - as described below.
    Out put will be something like this:
    alter system kill session '22,15' immediate;
    2. alter system disconnect session '22,15' IMMEDIATE ; - 22-sid, 15-serial - repeat the command for each returned session from previous command
    3. Repeat steps 1-2 while select... not return an empty table
    4. Call drop user...

    What was missed - call alter system disconnect session '22,15' IMMEDIATE ; for each of session returned by select 'alter system kill session '..

    0 讨论(0)
  • 2020-12-12 22:48

    Users are all capitals in v$session (and data dictionary views). If you match with capitals you should find your session to kill.

    SELECT s.sid, s.serial#, s.status, p.spid 
      FROM v$session s, v$process p 
     WHERE s.username = 'TEST' --<<<--
      AND p.addr(+) = s.paddr
     /
    

    Pass actual SID and SERIAL# values for user TEST then drop user...:

    ALTER SYSTEM KILL SESSION '<SID>, <SERIAL>'
    /
    
    0 讨论(0)
  • 2020-12-12 22:48

    This can be as simple as:

    SQL> ALTER SYSTEM ENABLE RESTRICTED SESSION;
    
    SQL> DROP USER test CASCADE;
    
    SQL> ALTER SYSTEM DISABLE RESTRICTED SESSION;
    
    0 讨论(0)
  • 2020-12-12 22:49

    go to services in administrative tools and select oracleserviceSID and restart it

    0 讨论(0)
提交回复
热议问题