sp_helpartition [ <table_name> [, { null | <indexname> | "all" }[, <partitionname> ][, "terse" | "help" ] ] ]
<table_name>
是当前数据库中表的名称。
null
指定有关要列出的基表分区的信息。
<indexname>
是当前表中索引的名称。将显示有关此索引的信息。
"all"
指定要列出所有的索引分区信息。
<partitionname>
是基表或索引中的分区名称。
"terse"
sp_help 显示降低的输出,包括:
"help"
显示 sp_helpartition 的使用信息。
返回有关 titles 表中的数据分区的概要和详细信息。
sp_helpartition titles
go
name type partition_type partitions partition_keys
--------- ---------- -------------- ----------- --------------
titles base table range 5 total_sales
(1 row affected)
partition_name partition_id pages row_count segment create_date
-------------- ------------ ----- --------- --------- -------------------
smallsales 1440005130 1 5 titleseg1 Sep 26 2005 5:44PM
smallsales2 1456005187 1 0 titleseg2 Sep 26 2005 5:44PM
smallsales3 1472005244 1 2 titleseg3 Sep 26 2005 5:44PM
mediumsales4 1488005301 1 8 titleseg4 Sep 26 2005 5:44PM
bigsales5 1504005358 1 3 titleseg5 Sep 26 2005 5:44PM
<h2>Partition_Conditions</h2>
VALUES <= (1000)
VALUES <= (2000)
VALUES <= (3000)
VALUES <= (10000)
VALUES <= (25000)
Avg_pages Max_pages Min_pages Ratio(Max/Avg) Ratio(Min/Avg)
----------- ---------- ---------- ------------------ --------------------
1 1 1 1.000000 1.000000
(return status = 0)
返回有关 titles 表的概要分区信息和有关 smallsales 数据分区的详细信息。
sp_helpartition titles, null, smallsales
name type partition_type partitions partition_keys
--------- ---------- -------------- ----------- --------------
titles base table range 5 total_sales
(1 row affected)
partition_name partition_id pages row_count segment create_date
-------------- ------------- ------ --------- --------- ------------------
smallsales 1440005130 1 5 titleseg1 Sep 26 2005 5:44PM
<h2>Partition_Conditions</h2>
VALUES <= (1000)
(return status = 0)
首先在 my_titles 表上创建非聚簇索引 ncidx_local,然后返回有关 my_titles 的概要分区信息和有关 ncidx_local 上的分区 ncip4 的详细信息:
create nonclustered index ncidx_local on my_titles(title_id) local index
(ncip1, ncip2, ncip3, ncip4, ncip5)
go
sp_helpartition my_titles, ncidx_local, ncip4
go
name type partition_type partitions partition_keys
----------- ----------- -------------- ----------- --------------
ncidx_local local index range 5 total_sales
(1 row affected)
partition_name partition_id pages row_count segment create_date
-------------- ------------ ----- --------- ------- ---------------------
ncip4 1584005643 1 8 default Sep 26 2005 6:06PM
<h2>Partition_Conditions</h2>
VALUES <= (10000)
(return status = 0)
显示 syspartition 分区的简短输出:
sp_helpartition syspartitions, null, null, "terse"
partition_type : roundrobin
no_of_partitions : 1
partition_keys : NULL
(return status = 0)
显示所有对象的相关分区信息:
sp_helpartition null, null, null, "help"
概要信息显示每个分区的页数、最小和最大页数以及平均页数和最大或最小页数之间的比率。
a) "all" 而非索引名称或 null – sp_helpartition 将列出指定表和基表的每个索引的表级别和索引级别分区信息。
b) 如果指定特定索引 – sp_helpartition 将列出该索引的索引级别信息。如果分区名称:
1)未指定 – sp_helpartition 将显示索引中所有分区的分区级别信息,并显示分区的概要信息。
2) 已指定 – sp_helpartition 将只显示该分区的分区级别信息。
c) 只指定了表名称 – sp_helpartition 将显示基表的表级别索引信息以及基表中所有分区的分区级别信息。
d) 如果指定了 Null 而未指定索引名称,同时还指定了分区名称 – sp_helpartition 将显示基表的表级别分区信息以及指定分区的分区级别信息(但没有摘要信息)。
在“页数”列中报告的值可能与实际值不同。若要确定该计数是否准确,请运行 sp_statistics 和 sp_helpartition 以比较数据页计数。sp_statistics 提供的计数始终是精确的。