我整理了一个删除触发器,表,索引和序列的脚本。
BEGIN
/*Delete All Triggers */
FOR i in (select trigger_name,owner
from dba_triggers ) LOOP
EXECUTE IMMEDIATE 'DROP TRIGGER '||i.owner||'.'||i.trigger_name;
END LOOP;
/*Delete All Indexes*/
FOR ind IN
(SELECT index_name FROM user_indexes WHERE table_name = 'my_table' AND index_name NOT IN
(SELECT unique index_name FROM user_constraints WHERE
table_name = 'my_table' AND index_name IS NOT NULL))
LOOP
execute immediate 'DROP INDEX '||ind.index_name;
END LOOP;
/*Delete All Tables*/
FOR c IN (SELECT table_name FROM user_tables) LOOP
EXECUTE IMMEDIATE ('DROP TABLE ' || c.table_name || ' CASCADE CONSTRAINTS');
END LOOP;
/*Delete all Sequences*/
FOR s IN (SELECT sequence_name FROM user_sequences) LOOP
EXECUTE IMMEDIATE ('DROP SEQUENCE ' || s.sequence_name);
END LOOP;
END;
我想知道是否有特定的顺序我应该这样做?还有什么我需要考虑的吗?