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 > 30 largest tables in DB2

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-12-05, 15:18
cougartrace cougartrace is offline
Registered User
 
Join Date: Oct 2005
Posts: 26
30 largest tables in DB2

Hi all,

Can someone help with a query to help me find the 30 largest tables in a DB2 UDB database?
Reply With Quote
  #2 (permalink)  
Old 10-12-05, 22:01
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
First you need execute the runstats command on each table. See the Command Reference manual. You should also use the "indexes all" option.

Then, to get the size, query the syscat.tables view and look at the NPAGES times the pagesize (from the syscat.tablespaces). This will give you the number of bytes, which includes page overhead and freespace.

You can also get the number of rows via the CARD column. See the SQL Reference Volumne 1 appendix for a description of all the columns in the syscat views which are the DB2 Catalog.
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
Reply With Quote
  #3 (permalink)  
Old 10-14-05, 15:01
rvsc36 rvsc36 is offline
Registered User
 
Join Date: Jan 2004
Location: Phoenix, AZ
Posts: 42
To add, after reviewing the catalog tables, if you wanted just the largest tables by row count, you could run a query similar to this one:

Select name, card from sysibm.systables where card > 1000000 order by card desc
Reply With Quote
  #4 (permalink)  
Old 10-15-05, 09:21
Peter.Vanroose Peter.Vanroose is offline
Registered User
 
Join Date: Sep 2004
Location: Belgium
Posts: 1,079
... or of course with something like
Code:
SELECT name, card FROM sysibm.systables
ORDER BY card DESC
FETCH FIRST 30 ROWS ONLY
__________________
--_Peter Vanroose,
__IBM Certified Database Administrator, DB2 9 for z/OS
__IBM Certified Application Developer
__ABIS Training and Consulting
__http://www.abis.be/
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