oracle 删除表 视图 序列等

http://blog.csdn.net/muchenfengye/article/details/49684233



--删除序列
declare cursor cur is select 'drop  sequence ' ||  sequence_name as a from  user_sequences;
begin
for i in cur loop
execute immediate i.a;
end loop;
end;

--删除表
declare cursor cur is select 'drop  table ' ||   table_name as a from   user_tables;
begin
for i in cur loop
execute immediate i.a;
end loop;
end;

--删除视图
declare cursor cur is select 'drop  view ' ||   view_name as a from   user_views;
begin
for i in cur loop
execute immediate i.a;
end loop;
end;


--删除存储过程
declare cursor cur is select 'drop  procedure ' ||  object_name as a from   user_objecst where object_type='PROCEDURE';
begin
for i in cur loop
execute immediate i.a;
end loop;
end;

--删除方法
declare cursor cur is select 'drop  function ' ||  object_name as a from   user_objects where object_type='FUNCTION';
begin
for i in cur loop
execute immediate i.a;
end loop;
end;

--删除包
declare cursor cur is select 'drop  package' ||  object_name as a from   user_objects where object_type='PACKAGE';
begin
for i in cur loop
execute immediate i.a;
end loop;
end;

--删除所有
declare cursor cur is select 'drop '||  object_type || ' ' ||  object_name || '   cascade constraints' as a from  user_objects where object_type not in ('INDEX', 'LOB');
begin
for i in cur loop
execute immediate i.a;
end loop;
end;


你可能感兴趣的:(oracle)