日期:2014-05-16 浏览次数:20529 次
create or replace procedure drop_all as cursor cur_obj is select uo.OBJECT_NAME, uo.OBJECT_TYPE from user_objects uo where uo.OBJECT_NAME not in ('DROP_ALL') and uo.OBJECT_TYPE not in ('LOB'); /* cursor cur_tablespace is select ut.TABLESPACE_NAME from user_tablespaces ut where ut.TABLESPACE_NAME not in ('SYSTEM', 'SYSAUX', 'UNDOTBS1', 'TEMP', 'USERS');*/ v_obj_name user_objects.OBJECT_NAME%type; v_obj_type user_objects.OBJECT_TYPE%type; /* v_tablespaces_name user_tablespaces.TABLESPACE_NAME%type;*/ sql_str1 varchar2(2000); /* sql_str2 varchar2(2000);*/ begin open cur_obj; loop fetch cur_obj into v_obj_name, v_obj_type; exit when cur_obj%notfound; sql_str1 := 'drop ' || v_obj_type || ' ' || v_obj_name; execute immediate sql_str1; end loop; close cur_obj; /* open cur_tablespace; loop fetch cur_tablespace into v_tablespaces_name; exit when cur_tablespace%notfound; sql_str2 := 'drop tablespace ' || v_tablespaces_name || ' including contents'; execute immediate sql_str2; end loop; close cur_tablespace;*/ end drop_all;