Created
June 15, 2012 01:27
-
-
Save steegi/2934101 to your computer and use it in GitHub Desktop.
Script to drop all tables in a DB2 database
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/bin/sh | |
# Since there is no simple drop all tables from a database command in DB2, | |
# this script uses a few unix utilities to accomplish the same result | |
# Note that it assumes that your session is already connected to the database | |
# and that the schema from which you want to drop the tables has the same name | |
# as your current user. | |
db2 "Select 'DROP TABLE', TABLE_NAME from sysibm.tables WHERE TABLE_SCHEMA = UPPER('$USER')" | grep DROP | db2 | |
# When you need to drop tables from another schema then the current user (SCTID) | |
db2 "Select 'DROP TABLE', TABLE_SCHEMA, '.', TABLE_NAME from sysibm.tables WHERE TABLE_SCHEMA = 'SCTID'" | grep DROP | db2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment