スキーマからオブジェクトを削除したいのですが、削除してはならないすべてのオブジェクトをテーブルに保存しました。テーブルにない他のすべてのオブジェクトを削除する必要があります。私は動作していない次のコードを持っています誰かがここで私を助けることができます。私はネットを検索しましたが、私の場合とは関係のない「すべてのオブジェクトを削除」が1つだけあります。
DECLARE
stringa VARCHAR2(100);
stringb VARCHAR2(1000) := '';
CURSOR cur IS
SELECT *
FROM user_objects;
BEGIN
FOR c IN cur LOOP
BEGIN
stringa := '';
BEGIN
SELECT tab_name
INTO stringb
FROM zretain_list;
IF c.object_type = 'VIEW' THEN
stringa := 'drop view '
|| c.object_name;
EXECUTE IMMEDIATE stringa;
ELSIF c.object_type = 'TABLE'
AND c.object_name != stringb THEN
stringa := 'drop table "'
|| c.object_name
|| '" cascade constraints';
EXECUTE IMMEDIATE stringa;
ELSIF c.object_type = 'SEQUENCE' THEN
stringa := 'drop sequence '
|| c.object_name;
EXECUTE IMMEDIATE stringa;
ELSIF c.object_type = 'PACKAGE' THEN
stringa := 'drop package '
|| c.object_name;
EXECUTE IMMEDIATE stringa;
ELSIF c.object_type = 'TRIGGER' THEN
stringa := 'drop trigger '
|| c.object_name;
EXECUTE IMMEDIATE stringa;
ELSIF c.object_type = 'PROCEDURE' THEN
stringa := 'drop procedure '
|| c.object_name;
EXECUTE IMMEDIATE stringa;
ELSIF c.object_type = 'FUNCTION' THEN
stringa := 'drop function '
|| c.object_name;
EXECUTE IMMEDIATE stringa;
ELSIF c.object_type = 'SYNONYM' THEN
stringa := 'drop synonym '
|| c.object_name;
EXECUTE IMMEDIATE stringa;
ELSIF c.object_type = 'INDEX' THEN
stringa := 'drop index '
|| c.object_name;
EXECUTE IMMEDIATE stringa;
ELSIF c.object_type = 'PACKAGE BODY' THEN
stringa := 'drop PACKAGE BODY '
|| c.object_name;
EXECUTE IMMEDIATE stringa;
ELSIF c.object_type = 'DATABASE LINK' THEN
stringa := 'drop database link '
|| c.object_name;
EXECUTE IMMEDIATE stringa;
END IF;
EXCEPTION
WHEN OTHERS THEN
NULL;
-- PURGE recyclebin
END;
END;
END LOOP;
END;
/