系统目录视图 (Transact-sql)System Catalog Views (Transact-SQL)

适用对象: yesSQL ServeryesAzure SQL 数据库yesAzure SQL 数据仓库yes并行数据仓库APPLIES TO: yesSQL Server yesAzure SQL Database yesAzure SQL Data Warehouse yesParallel Data Warehouse

目录视图返回 SQL Server 数据库引擎SQL Server Database Engine使用的信息。Catalog views return information that is used by the SQL Server 数据库引擎SQL Server Database Engine. 建议您使用目录视图这一最常用的目录元数据界面,它可为您提供最有效的方法来获取、转换并显示此信息的自定义形式。We recommend that you use catalog views because they are the most general interface to the catalog metadata and provide the most efficient way to obtain, transform, and present customized forms of this information. 所有用户可用的目录元数据都通过目录视图来显示。All user-available catalog metadata is exposed through catalog views.

备注

目录视图不包含有关复制、备份、数据库维护计划或 SQL ServerSQL Server 代理目录数据的信息。Catalog views do not contain information about replication, backup, database maintenance plan, or SQL ServerSQL Server Agent catalog data.

某些目录视图从其他目录视图继承行。Some catalog views inherit rows from other catalog views. 例如, sys.databases目录视图继承自sys.databases目录视图。For example, the sys.tables catalog view inherits from the sys.objects catalog view. sys.objects 目录视图称为基本视图,而 sys.tables 视图称为派生视图。The sys.objects catalog view is referred to as the base view, and the sys.tables view is called the derived view. sys.tables 目录视图返回专用于表的列,同时还返回 sys.objects 目录视图返回的所有列。The sys.tables catalog view returns the columns that are specific to tables and also all the columns that the sys.objects catalog view returns. sys.objects 目录视图返回表之外的对象(例如,存储过程和视图)的行。The sys.objects catalog view returns rows for objects other than tables, such as stored procedures and views. 创建表之后,表的元数据将在两个视图中返回。After a table is created, the metadata for the table is returned in both views. 尽管两个目录视图返回有关表的不同级别的信息,但在此表的元数据中只有一个具有一个名称和一个 object_id 的项。Although the two catalog views return different levels of information about the table, there is only one entry in metadata for this table with one name and one object_id. 这可以总结如下:This can be summarized as follows:

  • 基本视图包含列的子集和行的超集。The base view contains a subset of columns and a superset of rows.
  • 派生视图包含列的超集和行的子集。The derived view contains a superset of columns and a subset of rows.

重要

SQL ServerSQL Server 的未来版本中,MicrosoftMicrosoft 可能会通过在列列表的末尾添加列来扩充任何系统目录视图的定义。In future releases of SQL ServerSQL Server, MicrosoftMicrosoft may augment the definition of any system catalog view by adding columns to the end of the column list. 建议不要在生产代码中使用*语法 SELECT FROM catalog_view_name , 因为返回的列数可能会更改并中断你的应用程序。We recommend against using the syntax SELECT * FROM sys.catalog_view_name in production code because the number of columns returned might change and break your application.

SQL ServerSQL Server 中的目录视图具有如下类别:The catalog views in SQL ServerSQL Server have been organized into the following categories:

Always On 可用性组目录视图(transact-sql)Always On Availability Groups Catalog Views (Transact-SQL) 用于(错误)目录视图(的消息 transact-sql))Messages (for Errors) Catalog Views (Transact-SQL))
Azure SQL Database 目录视图Azure SQL Database Catalog Views 对象目录视图(transact-sql)Object Catalog Views (Transact-SQL)
更改跟踪目录视图(transact-sql)Change Tracking Catalog Views (Transact-SQL) 分区函数目录视图(transact-sql)Partition Function Catalog Views (Transact-SQL)
CLR 程序集目录(视图 transact-sql)CLR Assembly Catalog Views (Transact-SQL) 基于策略的管理视图 (Transact-SQL)Policy-Based Management Views (Transact-SQL)
数据收集器(视图 transact-sql)Data Collector Views (Transact-SQL) Resource Governor 目录视图(transact-sql)Resource Governor Catalog Views (Transact-SQL)
数据空间(transact-sql)Data Spaces (Transact-SQL) 查询存储目录视图 (Transact-SQL)Query Store Catalog Views (Transact-SQL)
数据库邮件视图(transact-sql)Database Mail Views (Transact-SQL) 标量类型目录视图(transact-sql)Scalar Types Catalog Views (Transact-SQL)
数据库镜像见证服务器目录(视图 transact-sql)Database Mirroring Witness Catalog Views (Transact-SQL) 架构目录视图(transact-sql)Schemas Catalog Views (Transact-SQL)
数据库和文件目录视图(transact-sql)Databases and Files Catalog Views (Transact-SQL) 安全性目录视图 (Transact-SQL)Security Catalog Views (Transact-SQL)
终结点目录(视图 transact-sql)Endpoints Catalog Views (Transact-SQL) Service Broker 目录视图 (Transact-SQL)Service Broker Catalog Views (Transact-SQL)
扩展事件目录视图 (Transact-SQL)Extended Events Catalog Views (Transact-SQL) 服务器范围内的配置目录(视图 transact-sql)Server-wide Configuration Catalog Views (Transact-SQL)
扩展属性目录视图 (Transact-SQL)Extended Properties Catalog Views (Transact-SQL) 空间数据目录视图Spatial Data Catalog Views
外部操作目录视图(transact-sql)External Operations Catalog Views (Transact-SQL) SQL 数据仓库和并行数据仓库目录视图SQL Data Warehouse and Parallel Data Warehouse Catalog Views
Filestream 和 FileTable 目录视图(transact-sql)Filestream and FileTable Catalog Views (Transact-SQL) Stretch Database 目录视图(transact-sql)Stretch Database Catalog Views (Transact-SQL)
全文搜索和语义搜索目录视图(transact-sql)Full-Text Search and Semantic Search Catalog Views (Transact-SQL) XML 架构(Xml 类型系统)目录视图(transact-sql)XML Schemas (XML Type System) Catalog Views (Transact-SQL)
链接服务器目录视图(transact-sql)Linked Servers Catalog Views (Transact-SQL)

请参阅See Also