Personal tools
You are here: Home DB2 How To's How to drop all tables and Views from a specific schema
Navigation
Log in


Forgot your password?
 
Document Actions

How to drop all tables and Views from a specific schema

dropping all tables and views from a specific SCHEMA, SYSPROC.ADMIN_DROP_SCHEMA




Dropping all tables, views and the own schema:



CALL SYSPROC.ADMIN_DROP_SCHEMA('SCHNAME', NULL, 'ERRORSCHEMA', 'ERRORTABLE')

Replace  'SCHNAME' to schema name, example for DEPT schema :

CALL SYSPROC.ADMIN_DROP_SCHEMA('DEPT', NULL, 'ERRORSCHEMA', 'ERRORTABLE');


Dropping all tables



db2 -x "select 'drop table ' || rtrim(tabschema) || '.' || rtrim(tabname) || ' '  
|| ';'from syscat.tables where type = 'T' and tabschema='<schema_name>'"


Dropping all Views


db2 -x "select 'drop table ' || rtrim(tabschema) || '.' || rtrim(tabname) || ' '  
|| ';'from syscat.tables where type = 'V' and
tabschema='<schema_name>'"


Dropping all Views and all Tables


db2 -x "select 'drop table ' || rtrim(tabschema) || '.' || 
rtrim(tabname) || ' '  || ';'from syscat.tables where tabschema='<schema_name>'"
Security Awareness
Would you like your company to implement gamification into your security awareness program?





Polls