drop all tables db2

Solutions on MaxInterview for drop all tables db2 by the best coders in the world

showing results for - "drop all tables db2"
Malia
17 Mar 2016
1select 'drop index "' || TRIM(INDSCHEMA) || '"."' || TRIM(INDNAME) || '";'
2  from SYSCAT.INDEXES
3  where UNIQUERULE = 'D'
4  and INDSCHEMA = (select current schema from SYSIBM.SYSDUMMY1);
5
6select 'alter table "' || TRIM(TABSCHEMA) || '"."' || TRIM(TABNAME) || '" drop foreign key "' || TRIM(CONSTNAME) || '";'
7  from SYSCAT.TABCONST
8  where TYPE = 'F'
9  and TABSCHEMA = (select current schema from SYSIBM.SYSDUMMY1)
10
11select 'alter table "' || TRIM(TABSCHEMA) || '"."' || TRIM(TABNAME) || '" drop unique "' || TRIM(INDNAME) || '";'
12  from SYSCAT.INDEXES
13  where UNIQUERULE = 'U'
14  and INDSCHEMA = (select current schema from SYSIBM.SYSDUMMY1);
15
16select 'alter table "' || TRIM(TABSCHEMA) || '"."' || TRIM(TABNAME) || '" drop primary key;'
17  from SYSCAT.INDEXES
18  where UNIQUERULE = 'P'
19  and INDSCHEMA = (select current schema from SYSIBM.SYSDUMMY1);
20
21select 'drop table "' || TRIM(TABSCHEMA) || '"."' || TRIM(TABNAME) || '";'
22  from SYSCAT.TABLES
23  where TYPE = 'T'
24  and TABSCHEMA = (select current schema from SYSIBM.SYSDUMMY1);
25
26select 'drop view "' || TRIM(TABSCHEMA) || '"."' || TRIM(TABNAME) || '";'
27  from SYSCAT.TABLES
28  where TYPE = 'V'
29  and TABSCHEMA = (select current schema from SYSIBM.SYSDUMMY1);
30