Evaluate Weigh the pros and cons of technologies, products and projects you are considering.

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


Dig Deeper on DB2 UDB (universal databases)

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchDataCenter

Close