1: create table tmp(
2: name varchar(50),
3: rows int,
4: reserved varchar(50),
5: data varchar(50),
6: index_size varchar(50),
7: unused varchar(50)
8: );
9:
10: insert into tmp (
11: name, rows, reserved, data, index_size, unused
12: ) exec sp_MSforeachtable @command1="sp_spaceused '?'";
13:
14: select * from tmp where name <> 'tmp' order by data desc ;
15:
16: drop table tmp ;
- rows:行数
- reserved:数据库为该表分配的空间
- data:数据实际使用的空间,reserved肯定>=data
- index_size:索引使用的空间
- unused:为数据库中的对象保留但尚未使用的空间总量,大致等于reserved - data - index_size的值