Oracle批量删除对象

DECLARE
TYPE name_list IS TABLE OF VARCHAR2(40);
TYPE type_list IS TABLE OF VARCHAR2(20);
TYPE OBJECT_NUM IS NUMBER(5);

TAB_NAME name_list:=name_list();
TAB_TYPE type_list:=type_list();

SQL_STR VARCHAR2(500);
BEGIN
SQL_STR := 'SELECT uo.OBJECT_NAME,uo.OBJECT_TYPE FROM USER_OBJECTS uo WHERE uo.OBJECT_TYPE =''TRIGGER'' AND uo.OBJECT_NAME LIKE ''%_AUDTRG'' ORDER BY uo.OBJECT_TYPE desc';
EXECUTE IMMEDIATE SQL_STR BULK COLLECT INTO TAB_NAME,TAB_TYPE;


FOR i IN TAB_NAME.FIRST.. TAB_NAME.LAST LOOP
SQL_STR := 'DROP ' || TAB_TYPE(i) || ' ' || TAB_NAME(i);
EXECUTE IMMEDIATE sql_str;
END LOOP;

END;

你可能感兴趣的:(oracle,sql)