日期:2014-05-18 浏览次数:20644 次
drop table testUniqueCluster
drop table testNonUniqueCluster
CREATE TABLE testUniqueCluster
(
name CHAR(900),
remark CHAR(1100)
)
CREATE UNIQUE CLUSTERED INDEX ix_testUniqueCluster
ON testUniqueCluster(name)
INSERT INTO testUniqueCluster VALUES('B','BBB1')
INSERT INTO testUniqueCluster VALUES('A','AAA1')
CREATE TABLE testNonUniqueCluster
(
name CHAR(900),
remark CHAR(1100)
)
CREATE CLUSTERED INDEX ix_testNonUniqueCluster
ON testNonUniqueCluster(name)
INSERT INTO testNonUniqueCluster VALUES('B','BBB2')
INSERT INTO testNonUniqueCluster VALUES('B','BBB1')
INSERT INTO testNonUniqueCluster VALUES('A','AAA1')
SELECT c.name,a.type_desc,
total_pages,used_pages,data_pages,
testdb.dbo.f_get_page(first_page) first_page_address,
testdb.dbo.f_get_page(root_page) root_address,
testdb.dbo.f_get_page(first_iam_page) IAM_address
FROM sys.system_internals_allocation_units a,sys.partitions b,sys.objects c
WHERE a.container_id=b.partition_id and b.object_id=c.object_id
AND c.name in ('testUniqueCluster','testNonUniqueCluster')
TRUNCATE TABLE tablepage;
INSERT INTO tablepage EXEC ('DBCC IND(testdb,testUniqueCluster,1)');
INSERT INTO tablepage EXEC ('DBCC IND(testdb,testNonUniqueCluster,1)');
SELECT
b.name table_name,
CASE WHEN c.type=0 THEN '堆'
WHEN c.type=1 THEN '聚集'
WHEN c.type=2 THEN '非聚集'
ELSE '其他'
END index_type,
c.name index_name,
PagePID,IAMPID,ObjectID,IndexID,Pagetype,IndexLevel,
NextPagePID,PrevPagePID
FROM tablepage a,sys.objects b,sys.indexes c
WHERE A.ObjectID=b.object_id
AND A.ObjectID=c.object_id
AND a.IndexID=c.index_id