Generating DROP TABLES for ORACLE - One Statement

I forget it over and over again, now its here archived :-). The following statement generates DROP TABLE statements which really cleanup the Oracle database:

select 'drop table '||table_name||' CASCADE CONSTRAINTS;' from USER_TABLES

It is very useful for development (JPA will generate the tables for you again), and production (speeds up the performance) :-).

Nice thing: USER_TABLES and Oracle's dictionary is conceptually similar to reflection in Java.

NEW: Online Workhop Effective WebApps without Frameworks is also coming to: MUC Airport.

Airport MUC workshops: Web (SPA, PWAs, Offline, Desktop, Mobile) Applications Essentials and Effective Web Applications. No migrations. #usetheplatform

Podcast: and newsletter:

A book about rethinking Java EE Patterns


Well performance decreases a little bit while doing this as user SYSTEM - so take care ;-)

Posted by Dirk on December 16, 2008 at 02:51 PM CET #

In MySQL, this is much easier:


Posted by Michael Kuhlmann on December 18, 2008 at 12:06 PM CET #

Manual trackback: same query for dropping sequences.
Cheers :-).

Posted by Baptiste on December 22, 2008 at 10:38 AM CET #

Very helpfull :)

Posted by on February 23, 2012 at 08:22 AM CET #

Post a Comment:
  • HTML Syntax: NOT allowed
Online Workshops
...the last 150 posts
...the last 10 comments