查看数据库单表大小
EXEC sp_spaceused 'TB_DATA'
查询效果:
![在这里插入图片描述](https:
use 库名
create table test(
name varchar(50),
rows int,
reserved varchar(20),
data varchar(20),
index_size varchar(20),
unused varchar(20)
)
insert into test
exec sp_MSforeachtable "exec sp_spaceused '?'"
select * from test order by cast(replace(reserved,'KB','') as int) DESC
查询效果:
![在这里插入图片描述](https://img-blog.csdnimg.cn/20200412185437711.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80Mzg5MjQ3Mw==,size_16,color_FFFFFF,t_70)
Enjoy you!