Skip to content

Instantly share code, notes, and snippets.

@Rondom
Last active December 11, 2015 12:58
Show Gist options
  • Save Rondom/4603813 to your computer and use it in GitHub Desktop.
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/
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