Drop een users schema

drop een geheel schema maar niet de user

set echo off
set verify off
set feed off
set pages 0
set lines 132
accept scheme prompt 'Enter schema to clean up its objects, or ^C to abort :'
spool dropschema.sql
select 'alter table '||owner||'.'||table_name||' drop constraint '||
       constraint_name||' cascade;'
from dba_constraints
where owner = upper('&schnme')
 and constraint_type in ('U','P')
/
select 'truncate table '||owner||'.'||table_name||';'
from dba_tables where owner = upper('&schnme');
/
select 'drop '||object_type||' '||owner||'.'||object_name||';'
from dba_objects o
where owner = upper('&schnme')
and not exists (select 'k' from dba_constraints
                 where owner = upper ('&schnme')
                 and constraint_name = o.object_name)
order by object_id  desc
/
spool off

prompt
prompt Reconnect as DBA and run
prompt generated dropschema.sql to drop
prompt all objects including contents from schema &schnme
prompt
set echo on
-- disconnect

 

Advertentie

>

Poll

Voorkeur
 

Wie is er aanwezig

We hebben 306 gasten online