sys.partitions (Transact-SQL)sys.partitions (Transact-SQL)

适用于: 是SQL Server(从 2008 开始)是Azure SQL 数据库是Azure SQL 数据仓库是并行数据仓库APPLIES TO: yesSQL Server (starting with 2008) yesAzure SQL Database yesAzure SQL Data Warehouse yesParallel Data Warehouse

数据库中的所有表和大部分类型的索引的每个分区各对应一行。Contains a row for each partition of all the tables and most types of indexes in the database. 在此视图中不包含全文索引、 空间和 XML 等特殊索引类型。Special index types such as Full-Text, Spatial, and XML are not included in this view. SQL ServerSQL Server 中的所有表和索引都至少包含一个分区,无论它们是否已进行显式分区均为如此。All tables and indexes in SQL ServerSQL Server contain at least one partition, whether or not they are explicitly partitioned.

列名Column name 数据类型Data type DescriptionDescription
partition_idpartition_id bigintbigint 指示分区 ID。Indicates the partition ID. 是在数据库中唯一。Is unique within a database.
object_idobject_id intint 指示此分区所属的对象的 ID。Indicates the ID of the object to which this partition belongs. 每个表或视图都至少包含一个分区。Every table or view is composed of at least one partition.
index_idindex_id intint 指示此分区所属的对象内的索引的 ID。Indicates the ID of the index within the object to which this partition belongs.

0 = 堆0 = heap
1 = 聚集的索引1 = clustered index
2 或更高 = 非聚集索引2 or greater = nonclustered index
partition_numberpartition_number intint 所属索引或堆中的从 1 开始的分区号。Is a 1-based partition number within the owning index or heap. 对于未分区的表和索引,此列的值为 1。For non-partitioned tables and indexes, the value of this column is 1.
hobt_idhobt_id bigintbigint 指示包含此分区的行的数据堆或 B 树的 ID。Indicates the ID of the data heap or B-tree that contains the rows for this partition.
rowsrows bigintbigint 指示此分区中的大约行数。Indicates the approximate number of rows in this partition.
filestream_filegroup_idfilestream_filegroup_id smallintsmallint 适用范围SQL Server 2012 (11.x)SQL Server 2012 (11.x)SQL Server 2017SQL Server 2017Applies to: SQL Server 2012 (11.x)SQL Server 2012 (11.x) through SQL Server 2017SQL Server 2017.

指示在此分区上存储的 FILESTREAM 文件组的 ID。Indicates the ID of the FILESTREAM filegroup stored on this partition.
data_compressiondata_compression tinyinttinyint 指示每个分区的压缩状态:Indicates the state of compression for each partition:

0 = NONE0 = NONE
1 = ROW1 = ROW
2 = PAGE2 = PAGE
3 = COLUMNSTORE:适用范围:SQL Server 2012 (11.x)SQL Server 2012 (11.x)通过 SQL Server 2017SQL Server 20173 = COLUMNSTORE : Applies to: SQL Server 2012 (11.x)SQL Server 2012 (11.x) through SQL Server 2017SQL Server 2017
4 = COLUMNSTORE_ARCHIVE:适用范围:SQL Server 2014 (12.x)SQL Server 2014 (12.x)通过 SQL Server 2017SQL Server 20174 = COLUMNSTORE_ARCHIVE : Applies to: SQL Server 2014 (12.x)SQL Server 2014 (12.x) through SQL Server 2017SQL Server 2017

注意: 全文索引将压缩的任何版本中SQL ServerSQL ServerNote: Full text indexes will be compressed in any edition of SQL ServerSQL Server.
data_compression_descdata_compression_desc nvarchar(60)nvarchar(60) 指示每个分区的压缩状态。Indicates the state of compression for each partition. 行存储表的可能值为 NONE、ROW 和 PAGE。Possible values for rowstore tables are NONE, ROW, and PAGE. 列存储表的可能值为 COLUMNSTORE 和 COLUMNSTORE_ARCHIVE。Possible values for columnstore tables are COLUMNSTORE and COLUMNSTORE_ARCHIVE.


要求 公共 角色具有成员身份。Requires membership in the public role. 有关详细信息,请参阅 Metadata Visibility ConfigurationFor more information, see Metadata Visibility Configuration.

请参阅See Also

对象目录视图 (Transact-SQL) Object Catalog Views (Transact-SQL)
目录视图 (Transact-SQL) Catalog Views (Transact-SQL)
查询 SQL Server 系统目录常见问题解答Querying the SQL Server System Catalog FAQ