K
K
Kvert0072014-10-10 11:57:30
Oracle
Kvert007, 2014-10-10 11:57:30

How to delete multiple schemas in oracle db?

Actually, you need to delete a lot of schemas from the database, a query like

Drop user "[email protected]","[email protected]" cascade;

doesn't work. says that QL Error: ORA-00921: unexpected end of SQL statement encountered
How to delete a list of schemas at once and not individually?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladimir, 2014-10-10
@azrail_dev

Palm a collection of schemas and run through it with forall

D
dchernov, 2014-10-22
@dchernov

commands can be formed with
select 'Drop user '||username||' cascade;' from dba_users where account_status = 'OPEN';
The condition can be omitted if all schemes are needed at all, and not just active ones ... from the resulting list, it remains to remove those that do not need to be dropped :)
You can make a script
set serveroutput on
set head off
set echo off
set feedback off
--set term off
spool drop.sql
select 'Drop user '||username||' cascade;' from dba_users where account_status = 'OPEN';
spool off
exit
by executing it in sqlplus you will get a ready-made script that also needs to be cleaned (leave schemas that do not need to be deleted) and then just execute.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question