|
-
execute this script you can also modify it as per your requirment
set heading off
set trimspool on
set feedback off
set echo off
set termout off
set pagesize 1000
declare
cursor cur_table_name is
select distinct table_name
from user_constraints;
V_Tablename varchar2(100);
begin
open cur_table_name;
loop
fetch cur_table_name into V_Tablename;
exit when cur_table_name%notfound;
declare
cursor cur_constraints is
select CONSTRAINT_NAME
from user_constraints where CONSTRAINT_TYPE='R'
and table_name=V_Tablename;
V_Constraint_name varchar2(100);
begin
open cur_constraints;
loop
fetch cur_constraints into V_Constraint_name;
Exit when cur_constraints%notfound;
EXECUTE IMMEDIATE 'alter table ' || V_Tablename ||
' drop constraint '||V_Constraint_name;
end loop;
close cur_constraints;
end;
end loop;
close cur_table_name;
end;
/
declare
cursor cur_alltable_name is
select table_name
from cat where table_type='TABLE';
V_AllTables varchar2(100);
begin
open cur_alltable_name;
loop
fetch cur_alltable_name into V_AllTables;
exit when cur_alltable_name%notfound;
EXECUTE IMMEDIATE 'drop table '|| V_AllTables;
end loop;
close cur_alltable_name;
end;
/
declare
cursor cur_sequence_name is
select table_name
from cat where table_type='SEQUENCE';
V_AllTables varchar2(100);
begin
open cur_sequence_name;
loop
fetch cur_sequence_name into V_AllTables;
exit when cur_sequence_name%notfound;
EXECUTE IMMEDIATE 'drop sequence '|| V_AllTables;
end loop;
close cur_sequence_name;
end;
/
declare
cursor cur_function_name is
select distinct name
from user_source where type='FUNCTION';
V_AllTables varchar2(100);
begin
open cur_function_name;
loop
fetch cur_function_name into V_AllTables;
exit when cur_function_name%notfound;
DBMS_OUTPUT.PUT_LINE(V_AllTables);
EXECUTE IMMEDIATE 'drop function '|| V_AllTables;
end loop;
close cur_function_name;
end;
/
declare
cursor cur_procedure_name is
select distinct name
from user_source where type='PROCEDURE';
V_AllTables varchar2(100);
begin
open cur_procedure_name;
loop
fetch cur_procedure_name into V_AllTables;
exit when cur_procedure_name%notfound;
EXECUTE IMMEDIATE 'drop procedure '|| V_AllTables;
end loop;
close cur_procedure_name;
end;
/
declare
cursor cur_procedure_name is
select distinct name
from user_source where type='PACKAGE BODY';
V_AllTables varchar2(100);
begin
open cur_procedure_name;
loop
fetch cur_procedure_name into V_AllTables;
exit when cur_procedure_name%notfound;
EXECUTE IMMEDIATE 'drop PACKAGE BODY '|| V_AllTables;
end loop;
close cur_procedure_name;
end;
/
declare
cursor cur_procedure_name is
select distinct name
from user_source where type='PACKAGE';
V_AllTables varchar2(100);
begin
open cur_procedure_name;
loop
fetch cur_procedure_name into V_AllTables;
exit when cur_procedure_name%notfound;
EXECUTE IMMEDIATE 'drop PACKAGE '|| V_AllTables;
end loop;
close cur_procedure_name;
end;
/
declare
cursor cur_view is
select view_name
from user_views;
V_AllTables varchar2(100);
begin
open cur_view;
loop
fetch cur_view into V_AllTables;
exit when cur_view%notfound;
EXECUTE IMMEDIATE 'drop view '|| V_AllTables;
end loop;
close cur_view;
end;
/
set heading on
set feedback on
set echo on
set termout on
SHAILENDRA
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|