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

Create a free website or blog at WordPress.com.