use dbName --要查看的數(shù)據(jù)庫
select db_name(database_id) as N'數(shù)據(jù)庫名稱', object_name(a.object_id) as N'表名', b.name N'索引名稱', user_seeks N'用戶索引查找次數(shù)', user_scans N'用戶索引掃描次數(shù)', last_user_seek N'最后查找時間', last_user_scan N'最后掃描時間', rows as N'表中的行數(shù)' from sys.dm_db_index_usage_stats a join sys.indexes b on a.index_id = b.index_id and a.object_id = b.object_id join sysindexes c on c.id = b.object_id where database_id=db_id('DBName') ---改成要查看的數(shù)據(jù)庫 and object_name(a.object_id) not like 'sys%' order by user_seeks,user_scans,object_name(a.object_id)
|