Dropping all tables from a DB2 schema

05 March,2014 by Tom Collins

Use this query to select and drop all tables of a schema. 

Note: this query constructs a sql statement for every table , e.g DROP TABLE MYTEST.mytable; .

 

--example SCHEMA = MYTEST
 db2 -x "select 'DROP TABLE '||rtrim(tabschema)||'.'||rtrim(tabname) ||’;’  from syscat.tables where tabschema = 'MYTEST'"

If you’re intention is to drop all the tables and the schema, an alternative approach is to use the ADMIN_DROP_SCHEMA  procedure . Read DB2 - ADMIN_DROP_SCHEMA to drop a schema

Read More

DB2 Database objects overviews - DBA DB2

DB2 SET CURRENT SCHEMA - DBA DB2

 

 

Author: Rambler(http://www.dba-db2.com)

Share:

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been saved. Comments are moderated and will not appear until approved by the author. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.

Working...

Post a comment on Dropping all tables from a DB2 schema

Comments are moderated, and will not appear until the author has approved them.


dba-db2.com | DB2 Performance Tuning | DBA DB2:Everything | FAQ | Contact | Copyright