sys.indexes (Transact-SQL)
每个表格对象(例如,表、视图或表值函数)的索引或堆都包含一行。
适用范围:SQL Server(SQL Server 2008 至当前版本),Windows Azure SQL Database(初始版本至当前版本)。 |
列名 |
数据类型 |
说明 |
||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
object_id |
int |
该索引所属对象的 ID。 |
||||||||||||||||
name |
sysname |
索引的名称。 name 只在该对象中是唯一的。 NULL = 堆 |
||||||||||||||||
index_id |
int |
索引的 ID。 index_id 只在该对象中是唯一的。 0 = 堆 1 = 聚集索引 > 1 = 非聚集索引 |
||||||||||||||||
类型 |
tinyint |
索引的类型:
|
||||||||||||||||
type_desc |
nvarchar(60) |
索引类型的说明:
|
||||||||||||||||
is_unique |
bit |
1 = 索引是唯一的。 0 = 索引不是唯一的。 对于聚集列存储索引始终为 0。 |
||||||||||||||||
data_space_id |
int |
该索引的数据空间的 ID。 数据空间是文件组或分区方案。 0 = object_id 是表值函数或内存中索引。 |
||||||||||||||||
ignore_dup_key |
bit |
1 = IGNORE_DUP_KEY 是 ON。 0 = IGNORE_DUP_KEY 是 OFF。 |
||||||||||||||||
is_primary_key |
bit |
1 = 索引是 PRIMARY KEY 约束的一部分。 对于聚集列存储索引始终为 0。 |
||||||||||||||||
is_unique_constraint |
bit |
1 = 索引是 UNIQUE 约束的一部分。 对于聚集列存储索引始终为 0。 |
||||||||||||||||
fill_factor |
tinyint |
> 0 = 创建或重新生成索引时使用的 FILLFACTOR 百分比。 0 = 默认值 对于聚集列存储索引始终为 0。 |
||||||||||||||||
is_padded |
bit |
1 = PADINDEX 是 ON。 0 = PADINDEX 是 OFF。 对于聚集列存储索引始终为 0。 |
||||||||||||||||
is_disabled |
bit |
1 = 禁用索引。 0 = 不禁用索引。 |
||||||||||||||||
is_hypothetical |
bit |
1 = 索引是假设的,不能直接用作数据访问路径。 假设的索引包含列级统计信息。 0 = 索引不是假设的。 |
||||||||||||||||
allow_row_locks |
bit |
1 = 索引允许行锁。 0 = 索引不允许行锁。 对于聚集列存储索引始终为 0。 |
||||||||||||||||
allow_page_locks |
bit |
1 = 索引允许页锁。 0 = 索引不允许页锁。 对于聚集列存储索引始终为 0。 |
||||||||||||||||
has_filter |
bit |
1 = 索引具有一个筛选器,且仅包含符合筛选器定义的行。 0 = 索引不具有筛选器。 |
||||||||||||||||
filter_definition |
nvarchar(max) |
包含在筛选索引中的行子集的表达式。 对于堆或非筛选索引,其值为 NULL。 |
权限
目录视图中仅显示用户拥有的安全对象的元数据,或用户对其拥有某些权限的安全对象的元数据。有关详细信息,请参阅元数据可见性配置。
示例
下面的示例返回 AdventureWorks2012 数据库中 Production.Product 表的所有索引。
SELECT i.name AS index_name
,i.type_desc
,is_unique
,ds.type_desc AS filegroup_or_partition_scheme
,ds.name AS filegroup_or_partition_scheme_name
,ignore_dup_key
,is_primary_key
,is_unique_constraint
,fill_factor
,is_padded
,is_disabled
,allow_row_locks
,allow_page_locks
FROM sys.indexes AS i
INNER JOIN sys.data_spaces AS ds ON i.data_space_id = ds.data_space_id
WHERE is_hypothetical = 0 AND i.index_id <> 0
AND i.object_id = OBJECT_ID('Production.Product');
GO
请参阅
参考
sys.index_columns (Transact-SQL)
sys.xml_indexes (Transact-SQL)
sys.key_constraints (Transact-SQL)
sys.partition_schemes (Transact-SQL)