«

»

Jun 06

Generating DB2 RUNSTATS SQL

This SQL will generate a set of RUNSTATS commands for the tables in your database that have no RUNSTATS values recorded.


select 'CALL SYSPROC.ADMIN_CMD(''RUNSTATS ON TABLE '|| trim(tabschema) || '.' || tabname || ' ON ALL COLUMNS AND INDEXES ALL ALLOW READ ACCESS'');'
from syscat.tables
where stats_time is null
and tabschema not like 'SYS%'
order by tabschema,tabname;

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>