06.索引-非聚集索引(2)-堆表
删除聚集索引
DROP INDEX CIX_Employee001_Id ON Employee001
索引情况
SELECT
database_id,
index_id,
index_type_desc,
index_depth,
index_level,
page_count
FROM sys.dm_db_index_physical_stats(DB_ID('IndexDB'),OBJECT_ID('Employee001'),null,null,null)
TRUNCATE TABLE DBCCIndResult
INSERT INTO DBCCIndResult EXEC('DBCC IND(IndexDB,Employee001,-1)')
SELECT *
FROM DBCCIndResult
WHERE PageType=2
AND IndexID =3
找到根
查看根页
DBCC TRACEON(3604)
DBCC PAGE (IndexDB, 1, 442, 3);
这时 由于没有聚集索引了,所以也就没有Id(Key),取而代之的是HEAP RID 也就是RID 行定位器
这个指针(RID)由页里行的(文件号:页号:槽号,file identifier :page number :slot number)组成
可以通过下面的方式 查看
DECLARE@HeapRidBINARY(8)
SET @HeapRid = 0xB800000001003E00
SELECT
CONVERT (VARCHAR(5),
CONVERT(INT, SUBSTRING(@HeapRid, 6, 1)
+ SUBSTRING(@HeapRid, 5, 1)))
+ ':'
+ CONVERT(VARCHAR(10),
CONVERT(INT, SUBSTRING(@HeapRid, 4, 1)
+ SUBSTRING(@HeapRid, 3, 1)
+ SUBSTRING(@HeapRid, 2, 1)
+ SUBSTRING(@HeapRid, 1, 1)))
+ ':'
+ CONVERT(VARCHAR(5),
CONVERT(INT, SUBSTRING(@HeapRid, 8, 1)
+ SUBSTRING(@HeapRid, 7, 1)))
AS 'Fileid:Pageid:Slot'
查询