Unfortunately the BOL is a little vague on this, but index_id = 0
on sys.indexes
or sys.partitions
appears to refer to the table itself where there is no clustered index on the table. True - or am I missing something?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Does index_id=0 in sys.indexes refer to the table itself?
No, For heap based tables it will always exist and it refers to the IAM (Index Allocation Map). For tables with clustered indexes it will not exist.
Notice the "type_desc" is HEAP on these indexes, there is a really good blog entry about the Index Allocation Map.
So, Heap tables (ones with no clustered index) will always have one index with entry index_id = 0
, and tables with clustered indexes will always have an entry with index_id = 1
.