Search
 
SCRIPT & CODE EXAMPLE
 

SQL

drop all tables db2

select 'drop index "' || TRIM(INDSCHEMA) || '"."' || TRIM(INDNAME) || '";'
  from SYSCAT.INDEXES
  where UNIQUERULE = 'D'
  and INDSCHEMA = (select current schema from SYSIBM.SYSDUMMY1);

select 'alter table "' || TRIM(TABSCHEMA) || '"."' || TRIM(TABNAME) || '" drop foreign key "' || TRIM(CONSTNAME) || '";'
  from SYSCAT.TABCONST
  where TYPE = 'F'
  and TABSCHEMA = (select current schema from SYSIBM.SYSDUMMY1)

select 'alter table "' || TRIM(TABSCHEMA) || '"."' || TRIM(TABNAME) || '" drop unique "' || TRIM(INDNAME) || '";'
  from SYSCAT.INDEXES
  where UNIQUERULE = 'U'
  and INDSCHEMA = (select current schema from SYSIBM.SYSDUMMY1);

select 'alter table "' || TRIM(TABSCHEMA) || '"."' || TRIM(TABNAME) || '" drop primary key;'
  from SYSCAT.INDEXES
  where UNIQUERULE = 'P'
  and INDSCHEMA = (select current schema from SYSIBM.SYSDUMMY1);

select 'drop table "' || TRIM(TABSCHEMA) || '"."' || TRIM(TABNAME) || '";'
  from SYSCAT.TABLES
  where TYPE = 'T'
  and TABSCHEMA = (select current schema from SYSIBM.SYSDUMMY1);

select 'drop view "' || TRIM(TABSCHEMA) || '"."' || TRIM(TABNAME) || '";'
  from SYSCAT.TABLES
  where TYPE = 'V'
  and TABSCHEMA = (select current schema from SYSIBM.SYSDUMMY1);
Comment

PREVIOUS NEXT
Code Example
Sql :: mssql xml 
Sql :: get relation data in mysql using query to excel 
Sql :: query to generate query to drop primary keys or foreign key in ms sql server 
Sql :: make a socket server to detect changes in mysql 
Sql :: add column to all tables after first column mysql 
Sql :: Which SQL statement would you use to remove a view called EMP_DEPT_VU from your schema? 
Sql :: sql delete where x or y or z 
Sql :: postgres type equivalent to timespan c# 
Sql :: SQL MAX() and MIN() with Strings 
Sql :: mysql command line top 10 
Sql :: mysql remote connection macos 
Sql :: alter domain sql 
Sql :: difference between ltrim and rtrim in sql server 
Sql :: sql server: concatinate column value without trailing or leading comma 
Sql :: sql server udf performance 
Sql :: trigger value from maltiple table to single table mysql 
Sql :: T-SQL - Where Used List (Table/View) 
Sql :: how to create a new shema using query languaage 
Sql :: Character Limitation in sp_executesql sql server 
Sql :: mysql missin expression near on 
Sql :: what is unsigned mysql 
Sql :: postgres create table like another table 
Sql :: get enginge db mysql 
Sql :: c# select mssql 
Sql :: run all sql file from folder postgres command line 
Sql :: goto in SQL server in production 
Sql :: okta postgresql 
Sql :: cursor.execute (sql, value) ValueError: operation parameter must be str 
Sql :: sqlite3 create table from another table 
Sql :: alasql delete column 
ADD CONTENT
Topic
Content
Source link
Name
8+4 =