Adam Bien's Weblog
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.
Posted at 11:00AM Dec 16, 2008 by Adam Bien in Java EE 5 Architectures And Idioms | Comments[3] | Views/Hits: 3553
*NEW* Workshop: "Real World Java EE 6/7 Bootstrap" and book: Real World Java EE Night Hacks--Dissecting the Business Tier Tweet Follow @AdamBien



Well performance decreases a little bit while doing this as user SYSTEM - so take care ;-)
Posted by Dirk on December 16, 2008 at 01:51 PM CET #
In MySQL, this is much easier:
DROP DATABASE xyz; CREATE DATABASE xyz
Posted by Michael Kuhlmann on December 18, 2008 at 11:06 AM CET #
Manual trackback: same query for dropping sequences.
Cheers :-).
Posted by Baptiste on December 22, 2008 at 09:38 AM CET #