Skip to content

Instantly share code, notes, and snippets.

@lennonjesus
Created June 13, 2013 19:31
Show Gist options
  • Save lennonjesus/5776629 to your computer and use it in GitHub Desktop.
Save lennonjesus/5776629 to your computer and use it in GitHub Desktop.
Script to drop all table in a oracle database
-- drop all tables in current schema
declare
table_name varchar2(30);
cursor usertables is select * from user_tables where table_name not like 'BIN$%';
begin
for next_row in usertables
loop
execute immediate 'drop table ' || next_row.table_name || ' cascade constraints';
end loop;
-- drop all sequences
FOR i IN (SELECT sequence_name FROM user_sequences)
LOOP
EXECUTE IMMEDIATE('DROP SEQUENCE ' || user || '.' || i.sequence_name);
END LOOP;
end;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment