Last active
December 11, 2015 12:58
-
-
Save Rondom/4603813 to your computer and use it in GitHub Desktop.
Empty Oracle schemas without deleting the schema and recreating it.
http://technology.amis.nl/2004/11/08/sql-script-to-empty-outcleanse-a-user-schema/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT 'drop ' ||object_type || ' '|| owner||'.' || object_name || ';' | |
FROM dba_objects | |
WHERE owner in ('USER1', 'USER2') | |
AND object_type not in ( 'PACKAGE BODY', 'INDEX', 'TABLE', 'TRIGGER', 'UNDEFINED') | |
UNION | |
SELECT 'drop ' || object_type || ' ' || owner||'.'||object_name || ' cascade constraints;' | |
FROM dba_objects | |
WHERE owner in ('USER1', 'USER2') | |
AND object_type = 'TABLE'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment