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 first published in December 2001

Dig deeper on DB2 UDB (universal databases)

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

-ADS BY GOOGLE

SearchEnterpriseLinux

SearchDataCenter

Close