Skip to content

Instantly share code, notes, and snippets.

@bhdrk
Last active August 29, 2015 14:01
Show Gist options
  • Save bhdrk/43cb8a6a0191e0c0ec18 to your computer and use it in GitHub Desktop.
Save bhdrk/43cb8a6a0191e0c0ec18 to your computer and use it in GitHub Desktop.
Oracle PL/SQL drop all database tables
BEGIN
FOR cur IN (SELECT * FROM DBA_TABLES WHERE OWNER = '<YOUR DATABASE NAME>')
LOOP
BEGIN
EXECUTE IMMEDIATE 'DROP TABLE ' || cur.OWNER || '.' || cur.TABLE_NAME || ' CASCADE CONSTRAINT';
DBMS_OUTPUT.PUT_LINE('SUCCESS: DROP ' || cur.TABLE_NAME);
EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('FAILED: DROP ' || cur.TABLE_NAME || ' ' || SQLERRM);
END;
END LOOP;
END;
@bhdrk
Copy link
Author

bhdrk commented May 26, 2014

to see DMBS_OUTPUT in SqlDeveloper, click to Veiw > Dmbs Output in menu bar. After press Ctrl+N and select your connection on "Select Connection" popup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment