Tag Archives: database

统计数据库空间的使用情况sql脚本

下面这个脚本用来获取数据库每张表/索引的空间使用情况。 with pa as ( SELECT p.object_id,p.index_id,a.type_desc as pagetype_desc,a.total_pages,a.used_pages,a.data_pages FROM sys.partitions p JOIN sys.allocation_units a ON p.partition_id = a.container_id ), indexes as ( select object_id,index_id,object_name(object_id) as tbname , name as indexname,type_desc as tbtype_desc from sys.indexes where object_id > =100 ), result as ( select i.*,p.pagetype_desc,p.total_pages,p.used_pages,p.data_pages from pa p inner join indexes i on p.object_id=i.object_id and… Read More »