Miscellaneous Ramblings on Hacking

May 19, 2013

Querying SQL Server (and DB2) for table sizes

Filed under: Uncategorized — Zack Bethem @ 4:30 pm

Found this gem and I MUST save it for future reference.

http://www.mssqltips.com/tip.asp?tip=1177

For the DB2 equivalent:

select t.tabname, t.tabschema, type
, (DATA_OBJECT_P_SIZE + INDEX_OBJECT_P_SIZE + LONG_OBJECT_P_SIZE + LOB_OBJECT_P_SIZE + XML_OBJECT_P_SIZE)/1024 as TOTAL_SIZE_IN_MB
from syscat.tables as t, sysibmadm.admintabinfo as a
where t.tabname=a.tabname and t.tabname like 'UAC_%'
order by (DATA_OBJECT_P_SIZE + INDEX_OBJECT_P_SIZE + LONG_OBJECT_P_SIZE + LOB_OBJECT_P_SIZE + XML_OBJECT_P_SIZE) desc
fetch first 20 rows only

Advertisements

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: