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

适用于: 是SQL Server 是Azure SQL 数据库 是Azure Synapse Analytics(SQL 数据仓库)是并行数据仓库 APPLIES TO: YesSQL Server YesAzure SQL Database YesAzure Synapse Analytics (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 catalog_view_name FROM,因为返回的列数可能会更改并中断你的应用程序。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.

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

另请参阅See Also