SQLServer统计数据库各表空间大小和数据量
程序员文章站
2022-04-14 20:38:23
...
SQLServer统计数据库各表空间大小和数据量
with temp as (
select convert(char(8), getdate(), 112) as date_id,
tablename N'table_name',
max(used_G) as "use_space_G",
max(rows) as row_nums,
getdate() as insert_time
from (select object_name(id) tablename,
8 * reserved / 1024 reserved,
(8 * dpages / 1024.0/1024.0) used_G,
8 * (reserved - dpages) / 1024 unused,
8 * dpages / 1024 - rows / 1024 * minlen / 1024 free,
rows
from sysindexes a) as b
group by tablename
)
select date_id,table_name,use_space_G,row_nums,insert_time
from temp
where use_space_G>0.01
order by row_nums desc
上一篇: 如何生成两组相互独立的服从标准正态分布的随机数(推导过程)
下一篇: 不知道如何把php数组传js