系統目錄 Views (Transact-sql)System Catalog Views (Transact-SQL)

適用於: 是SQL Server 是Azure SQL Database 是Azure Synapse Analytics (SQL DW) 是平行處理資料倉儲 APPLIES TO: yesSQL Server yesAzure SQL Database yesAzure Synapse Analytics (SQL DW) yesParallel Data Warehouse

目錄檢視會傳回 SQL Server Database EngineSQL Server Database Engine 所用的資訊。Catalog views return information that is used by the SQL Server Database EngineSQL 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 Agent 目錄資料的相關資訊。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. 我們建議您不要在生產環境*程式碼中使用catalog_view_name的語法 SELECT, 因為傳回的資料行數目可能會變更並中斷您的應用程式。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)
Database Mail 檢視(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