Skip to content

Instantly share code, notes, and snippets.

@lucansky
Last active August 29, 2015 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lucansky/97ccfac1ab2d414d15b6 to your computer and use it in GitHub Desktop.
Save lucansky/97ccfac1ab2d414d15b6 to your computer and use it in GitHub Desktop.
IDS drop all sequences and tables
-- source: http://stackoverflow.com/questions/2549718/dropping-all-user-tables-sequences-in-oracle
DECLARE
login varchar2(8);
BEGIN
-- Change value according to your username
login := 'XLUCAN01';
-- Remove all sequences
FOR i IN (SELECT us.sequence_name, us.sequence_owner
FROM ALL_SEQUENCES us WHERE sequence_owner = LOGIN) LOOP
EXECUTE IMMEDIATE 'drop sequence '|| i.sequence_name ||'';
END LOOP;
-- Remove all tables
FOR i IN (SELECT ut.table_name
FROM ALL_TABLES ut WHERE owner = LOGIN) LOOP
EXECUTE IMMEDIATE 'drop table '|| i.table_name ||' CASCADE CONSTRAINTS ';
END LOOP;
END;
/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment