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

適用於: 是SQL Server (從 2008 開始) 是Azure SQL Database 是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 Server]SQL Server 中的所有資料表和索引都至少包含一個資料分割,不論它們是否進行明確的資料分割都一樣。All tables and indexes in [SQL Server]SQL Server contain at least one partition, whether or not they are explicitly partitioned.

資料行名稱Column name 資料類型Data type 描述Description
partition_idpartition_id bigintbigint 指出資料分割識別碼。Indicates the partition ID. 在資料庫中,這是唯一的。Is unique within a database.
object_idobject_id intint 指出這個資料分割所屬物件的識別碼。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 指出這個資料分割所屬物件內的索引識別碼。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 型樹狀目錄的識別碼。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 檔案群組的識別碼。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 = 資料行存放區:適用於: 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 Server]SQL ServerNote: Full text indexes will be compressed in any edition of [SQL Server]SQL 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.


需要 public 角色的成員資格。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