Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dropping connected users in Oracle database

Tags:

oracle

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-01940: cannot drop a user that is currently connected 

I followed the link in SO to find out the sessions - Dropping a connected user from an Oracle 10g database schema

But when I ran the command I am not getting any results:

SQL> select sid,serial# from v$session where username = 'test';  no rows selected 

Please help me how to drop users in this case.

like image 460
Chaitanya Avatar asked Mar 27 '13 17:03

Chaitanya


People also ask

Can not drop a user that is currently connected Oracle?

Cause: An attempt was made to drop a user that was currently logged in. Action: Make sure the user is logged out, then re-execute the command. The ORA-01940 can always be cured by bouncing the source and replicated instance. First, double-check to ensure that the user is not connected to the current instance.

What is drop user cascade?

The Oracle DROP USER CASCADE command drops a user and all owned objects. The user will not be dropped and an error message will be returned if you a user owns objects and you fail to use the Oracle DROP USER CASCADE command.

How can we disable a user in Oracle?

To disable a user account, select it in the User List, and then select Disable from the User Actions drop-down menu. On the displayed Disable page, select the resource accounts to disable, and then click OK. Waveset displays the results of disabling the Waveset user account and all associated resource accounts.

How do I drop a user table?

Show activity on this post. BEGIN FOR c IN (SELECT table_name FROM user_tables) LOOP EXECUTE IMMEDIATE ('DROP TABLE "' || c. table_name || '" CASCADE CONSTRAINTS'); END LOOP; FOR s IN (SELECT sequence_name FROM user_sequences) LOOP EXECUTE IMMEDIATE ('DROP SEQUENCE ' || s.


Video Answer


1 Answers

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>' / 
like image 200
Art Avatar answered Oct 21 '22 09:10

Art