If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > rerorg

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-09-09, 08:24
oracle10gsingh oracle10gsingh is offline
Registered User
 
Join Date: Nov 2007
Posts: 72
rerorg

Hi all ,

i got a script from the internet which filters the tables via calling stored procedure reorgchk and list tables which needs to be reorg

db2 reorgchk current statistics on table all | awk '
/^Table:/ { TAB = $2 }
$NF ~ /\*+/ { printf("%s\n", TAB) }' | sort | uniq

but i have seen this is not filtering the list of tables where it finds * sign ..

can somebody help me with it or provide better solution for it .

Thanks in advance
Reply With Quote
  #2 (permalink)  
Old 12-09-09, 08:32
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
What DB2 version and OS are you using?

Andy
Reply With Quote
  #3 (permalink)  
Old 12-09-09, 08:37
oracle10gsingh oracle10gsingh is offline
Registered User
 
Join Date: Nov 2007
Posts: 72
db2 level is DB2 code release "SQL09015"
O/S is SunOS
Reply With Quote
  #4 (permalink)  
Old 12-09-09, 08:52
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
You can do it with straight SQL:

Ignore the result set from the call of the stored procedure. The call is just to setup the temp table:

call sysproc.reorgchk_tb_stats('T','ALL')
select * from session.tb_stats where reorg <> '---'

Andy
Reply With Quote
  #5 (permalink)  
Old 12-10-09, 06:21
oracle10gsingh oracle10gsingh is offline
Registered User
 
Join Date: Nov 2007
Posts: 72
but this will be only for the current session only. and i capture where it find * it list the name of that table .

i got this error in the end
+ db2 select 1 exa local.cshrc local.login local.profile migration.log reorgchkrpt sqllib sqllib_v81 from session.tb_stats where reorg
+ 0<> ---
SQL0104N An unexpected token "1 exa local.cshrc local.login local.profile
migration." was found following "select ". Expected tokens may include:
"<space>". SQLSTATE=42601
$
Reply With Quote
  #6 (permalink)  
Old 12-10-09, 08:17
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
If you are going to do a select statement like that you will need to do it like this:

db2 "select ... from ... where..."

You need to use the quotes, otherwise the OS will try to interpret some of it and it will usually fail.

Also you columns for the select are not in the table, what are they? (exa local.cshrc local.login local.profile migration.log reorgchkrpt sqllib sqllib_v81)


Andy
Reply With Quote
  #7 (permalink)  
Old 12-10-09, 09:05
oracle10gsingh oracle10gsingh is offline
Registered User
 
Join Date: Nov 2007
Posts: 72
i am not comfortable with this ..as it is not filtering out tables which needs reorg ..can somebody help me ..
Reply With Quote
  #8 (permalink)  
Old 12-10-09, 09:20
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
Do it this way. Put the following into a DB2 script file (fix where appropriate):

connect to mydb;
call sysproc.reorgchk_tb_stats('T','ALL');
export to /mydir/reorg_tables.csv of del select * from session.tb_stats where reorg <> '---';
disconnect all

The all you will need to do is execute this and the tables that need reorg will be in the file:

db2 -tvsf reorg_script.sql


Andy
Reply With Quote
  #9 (permalink)  
Old 12-14-09, 07:52
oracle10gsingh oracle10gsingh is offline
Registered User
 
Join Date: Nov 2007
Posts: 72
Hi andy,

thanks for your help its working for me ..the result set is like this ."MONSCHEMA","T_LOGSPACE_MON",7797,0,114,114,-1,0,0,0,100,"-*-"
"MONSCHEMA","T_TBSPACE_MON",127761,0,3654,5848 ,-1,0,0,0,62,"-**"
"UDBADM ","AUDIT_SUMMARY",0,0,0,374,-1,0,0,0,0,"-**"
"UDBADM ","CALL_EVNT_SOR_DATA_OLD",0,0,0,161447,-1,0,0,0,0,"-**"
"UDBADM ","HOLD_WP",0,0,0,444,-1,0,0,0,0,"-**"
"UDBADM ","SSO_TOKEN",0,0,0,96,-1,0,0,0,0,"-**"
"UDBBDE ","ATTR",176000,0,798,798,-1,0,0,0,100,"-*-"
"UDBBDE ","DRH",0,0,0,2975,-1,0,0,0,0,"-**"
"UDBBDE ","FCL_DEL",87000,0,858,3886,-1,0,0,0,22,"-**"
"UDBBDE ","HOLD_CR_TKT",0,0,0,1112,-1,0,0,0,0,"-**"
"UDBBDE ","HOLD_MRTG_DEL",0,0,0,2023,-1,0,0,0,0,"-**"
"UDBBDE ","HOLD_WRKOT",73113,0,685,855,-1,0,0,0,80,"-**"
"UDBBDE ","HOLD_WRKOT_ALL",184000,0,1705,2355,-1,0,0,0,72,"-**"
"UDBBDE ","HWP",109734,0,3328,3328,-1,0,0,0,100,"-*-"
"UDBBDE ","HWP2",4000,0,65,5201,-1,0,0,0,1,"-**"
~


now the probem is i want only the table name .not every thing
Reply With Quote
  #10 (permalink)  
Old 12-14-09, 09:05
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
Then change the "Select *" to select whatever columns you want.

Andy
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On