BEGIN
FOR t IN (SELECT table_name FROM user_tables) LOOP
EXECUTE IMMEDIATE 'DROP TABLE ' || t.table_name || ' CASCADE CONSTRAINTS';
END LOOP;
FOR i IN (SELECT index_name FROM user_indexes) LOOP
EXECUTE IMMEDIATE 'DROP INDEX ' || i.index_name;
END LOOP;
END;
*Explanation:
*
Tables: The script iterates through all tables in the current schema (user_tables) and drops each table using DROP TABLE ... CASCADE CONSTRAINTS to handle dependencies.
Indexes: Similarly, it iterates through all indexes (user_indexes) and drops each one using DROP INDEX.
Top comments (0)