sql关于索引及索引碎片的整理

查询索引碎片

--QUERY INDEX FRAGMENTATION INFO AGAIN 

SELECT DB_NAME(V1.database_id) as 'Database Name', 

OBJECT_NAME(V1.object_id) as 'Table Name', v2.name as 'Index Name',

V1.index_id as "Index ID", V1.avg_fragmentation_in_percent as 'Average Percent Fragmentation' 

FROM sys.dm_db_index_physical_stats(DB_ID(),NULL,NULL,NULL,'DETAILED') AS V1 

JOIN sys.indexes AS V2 ON V1.object_id=V2.object_id and V1.index_id=V2.index_id

 

查看表中的索引信息

DBCC SHOWCONTIG (表名)

你可能感兴趣的:(sql)