Skip to content

Instantly share code, notes, and snippets.

@kekru
Last active October 23, 2016 16:01
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 kekru/746ebb5eb7fff27210a4928d331642fe to your computer and use it in GitHub Desktop.
Save kekru/746ebb5eb7fff27210a4928d331642fe to your computer and use it in GitHub Desktop.

#DB2
##Create drop statements for all tables:
select 'drop table '||rtrim(tabschema)||'.'||rtrim(tabname)||';' from syscat.tables where tabschema = 'MYSCHEMA';

#Oracle ##Delete all sequences and tables http://stackoverflow.com/questions/2549718/dropping-all-user-tables-sequences-in-oracle

BEGIN

  --Bye Sequences!
  FOR i IN (SELECT us.sequence_name
              FROM USER_SEQUENCES us) LOOP
    EXECUTE IMMEDIATE 'drop sequence '|| i.sequence_name ||'';
  END LOOP;

  --Bye Tables!
  FOR i IN (SELECT ut.table_name
              FROM USER_TABLES ut) 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