How to generate dynamic RUNSTATS statements

Here is a handy trick to dynamically generate RUNSTATS STMTS using the SQL CONCAT and STRIP functions.

Here is a handy trick to dynamically generate RUNSTATS STMTS using the SQL CONCAT and STRIP functions.

Run this SQL in SPUFI, cut and paste the generated output for subsequent processing by DSNUTILB.

-- THIS SQL STATEMENT WILL DYNAMICALLY GENERATE 
-- RUNSTATS STATEMENTS 
-- FOR ALL TABLESPACES MATCHING THE SEARCH CRITERIA 
------------------------------------------------------------------------ 
SELECT DISTINCT 'RUNSTATS TABLESPACE ' 
CONCAT STRIP(DBNAME,TRAILING) 
CONCAT '.' 
CONCAT NAME 
CONCAT ' TABLE ALL INDEX ALL UPDATE ALL' 
FROM SYSIBM.SYSTABLESPACE 
WHERE DBNAME = 'DSQDBCTL' 
; 

For More Information


This was last published in December 2001

Dig Deeper on DB2 UDB (universal databases)

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.

-ADS BY GOOGLE

SearchEnterpriseLinux

SearchDataCenter

Close