Skip to main content

Posts

Showing posts from September, 2015

Drop It Like It's Not

I just ran the following script: -- TABLES FOR x IN (SELECT table_name FROM user_tables) LOOP   EXECUTE IMMEDIATE('DROP TABLE ' || x.table_name || ' CASCADE CONSTRAINTS'); END LOOP; -- SEQUENCES FOR x IN (SELECT sequence_name FROM user_sequences) LOOP   EXECUTE IMMEDIATE ('DROP SEQUENCE ' || x.sequence_name); END LOOP; -- VIEWS FOR x IN (SELECT view_name FROM user_views) LOOP   EXECUTE IMMEDIATE ('DROP VIEW ' || x.view_name); END LOOP; Basically, drop all tables, views and sequences.  It worked great, cleaning out those objects in my schema without touching any packages, producers or functions.  The was just one problem:  I ran it in the wrong schema. Maybe I didn't have enough coffee, or maybe I just wasn't paying attention, but I essentially wiped out a schema that I really would rather not have.  But I didn't even flinch, and here's why. All tables & views were safely stored in my data model.  All sequence