Thread: Script Library
View Single Post
  #17 (permalink)  
Old 01-21-09, 07:13
dr_te_z dr_te_z is offline
Registered User
 
Join Date: Jan 2009
Location: Zoetermeer, Holland
Posts: 555
Just generate a reorg/runstats script for all you tables:
Code:
select varchar 
	(
			'title '
		|| 	lcase(rtrim(a.table_name))
		||	space ( 40 - length(a.table_name)) 
		||	'&& db2 -v reorg table '
		|| 	rtrim(a.table_schema)
		||	'.'
		|| 	rtrim(a.table_name)
		||	space ( 40 - length(a.table_name))
		||	case c.pagesize	when 04096	then 'use tmp04 '
					when 08192	then 'use tmp08 ' 
					when 16384	then 'use tmp16 ' 
							else 'use tmp32 '
			end
		||	'resetDictionary'
		||	space ( 40 - length(a.table_name))  
		||	' && db2 -v runstats on table '
		|| 	rtrim(a.table_schema)
		||	'.'
		|| 	rtrim(a.table_name)
		||	space (1)
		||	'on all columns and indexes all' 
	,384) as one_liner
from sysibm.tables   		a
join sysibm.systables 		b on b.name	= a.table_name
join sysibm.systablespaces	c on c.tbspace	= b.tbspace
where 		a.table_type			= ucase('base table')
and		a.table_name not in 	('no_not_this_table'
					,'no_not_that_table')
order by 	a.table_schema
	,	a.table_name	;
Reply With Quote