Sunday, March 8, 2009

Drop All tables in Oracle using SQL Statement

Sometime for developer want drop all table, it might be quite troublesome. Most of us will direct delete the "Schema" to drop all tables.

Here is the SQL Script:
Begin

for c in (select table_name from user_tables) loop
execute immediate ('drop table '||c.table_name||' cascade constraints);
end loop;
End;

Take note!!
1. You need to log in to that user which you wanted to drop the tables
2. Keep in mind, If run, it will not able to rollback

No comments:

Post a Comment

-->Please Share your experience with me<--