计算数据库表的行大小 [英] calculate row size of database table

查看:69
本文介绍了计算数据库表的行大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用sql server 2005数据库.我想知道如何计算数据库表每一行的大小(kb/mb/gb).

I am using sql server 2005 database. I would like to know how can I calculate the size(kb/mb/gb) of each row of a database table.

推荐答案

我不是发明这个(我不是很好)-但是我不记得我从哪里得到的:
I didn''t invent this (I''m not that good) - but I can''t remember where I got it:
SELECT a.name,sum(a.max_length)as Bytes
FROM (
            SELECT ST.NAME,SC.MAX_LENGTH
            FROM SYS.COLUMNS sc inner join sys.tables st on sc.object_id = st.object_id
            UNION ALL
            SELECT ST.NAME,SC.MAX_LENGTH
            FROM SYS.INDEXES SI INNER JOIN SYS.TABLES ST ON SI.OBJECT_ID = ST.OBJECT_ID
            inner join sys.columns sc on sc.object_id = st.object_id
            inner join sys.index_columns sic on sc.object_id = sic.object_id
            and sc.column_id = sic.column_id ) a
group by a.name
order by a.name 

返回表名称和行大小(近似值)的数据集

It returns a dataset of table name and row size (approximate)


这篇关于计算数据库表的行大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆