-
-
Save kashiash/bc2946ac8068ff5d3d957561baae1c55 to your computer and use it in GitHub Desktop.
IBM DB2 RunStat and ReOrg
This file contains hidden or 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
| --ReOrg and RunStat for IBM DB2 | |
| --All Programs > IBM DB2 > DB2COPY1 (Default) > Command Line Tools > Command Window - Administrator | |
| -- Connect to Database | |
| db2 connect to <DATABASE NAME> | |
| -- Generate output for RunStat on Tables | |
| db2 -x "SELECT 'RUNSTATS ON TABLE ' || TRIM(TABSCHEMA) || '.' || TRIM(TABNAME) || ' AND INDEXES ALL;' FROM SYSCAT.TABLES WHERE TYPE = 'T' AND TABSCHEMA NOT LIKE 'SYS%' ORDER BY TABSCHEMA, TABNAME" > db2_runstats.sql.out | |
| -- Use the genereated file for RunStat on Tables. | |
| db2 -tvf db2_runstats.sql.out | |
| -- Generate output for ReOrg on Tables | |
| db2 -x "SELECT 'REORG TABLE ' || TRIM(TABSCHEMA) || '.' || TRIM(TABNAME) || ';' FROM SYSCAT.TABLES WHERE TYPE = 'T' AND TABSCHEMA NOT LIKE 'SYS%' ORDER BY TABSCHEMA, TABNAME" > db2_reorg.sql.out | |
| -- Use the genereated file for Runstat | |
| db2 -tvf db2_reorg.sql.out | |
| -- Use the genereated file for Runstat again. | |
| db2 -tvf db2_runstats.sql.out | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment