Adam Bien's Weblog

Tuesday Dec 16, 2008

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.


[my tweets]  Rss My book: Real World Java EE - Rethinking Best Practices

Kommentare:

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

Gesendet von Dirk am December 16, 2008 at 01:51 PM CET #

In MySQL, this is much easier:

DROP DATABASE xyz; CREATE DATABASE xyz

Gesendet von Michael Kuhlmann am December 18, 2008 at 11:06 AM CET #

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

Gesendet von Baptiste am December 22, 2008 at 09:38 AM CET #

Senden Sie einen Kommentar:
  • HTML Syntax: Ausgeschaltet
Interviews/About
My Recent Book
Java One 2009
CommunityOne East N.Y.C
JavaONE 2008 Interview
Search
...the last 150 posts
...the last 10 comments
greenfire.dev.java.net
Links
my.netbeans.org
Visitors
License