日期:2014-05-17 浏览次数:20522 次
/*----------------------------------------------------------------------
*auther:Poofly
*date:2010.3.14
*VERSION:
Microsoft SQL Server 2008 (RTM) - 10.0.1600.22 (Intel X86)
Jul 9 2008 14:43:34
Copyright (c) 1988-2008 Microsoft Corporation
Enterprise Evaluation Edition on Windows NT 6.1 <X86> (Build 7600: )
*转载请注明出处
*更多精彩内容,请进http://blog.csdn.net/feixianxxx
------------------------------------------------------------------------*/
--建表(表源技术内幕)
CREATE TABLE NC_Heap_Nodupes (
id int NOT NULL ,
str1 char (5) NOT NULL ,
str2 char (600) NULL );
GO
--在str1上建立非聚集索引
CREATE UNIQUE INDEX idxNC_heap ON NC_Heap_Nodupes (str1);
GO
--插入数据
DECLARE @i int;
SET @i = 1240;
WHILE @i < 1300 BEGIN
INSERT INTO NC_Heap_Nodupes
SELECT @i, cast(@i AS char), cast(@i AS char);
SET @i = @i + 1;
END;
GO
--执行DBCC将结果插入表并显示相关页号
TRUNCATE TABLE sp_table_pages;
INSERT INTO sp_table_pages
EXEC ('dbcc ind ( poofly, NC_Heap_Nodupes, -1)' );
SELECT PageFID, PagePID, IndexID, IndexLevel, PageType
FROM sp_table_pages
WHERE IndexLevel >= 0;
/*
PageFID PagePID IndexID IndexLevel PageType
------- ----------- ------- ---------- --------
5 52 0 0 1 --pagetype 1 数据分页2索引分页
5 54 2 0 2 --IndexID 0为堆 1为聚集索引2-250为非聚集索引
5 952 0 0 1
5 953 0 0 1
5 954 0 0 1
5 955 0 0 1
5 956 0 0