检索数据库架构信息Retrieving Database Schema Information

从数据库获取架构信息通过架构发现过程来完成。Obtaining schema information from a database is accomplished with the process of schema discovery. 架构发现允许应用程序请求托管提供程序查找并返回有关给定数据库的数据库架构的信息(也称为元数据)。Schema discovery allows applications to request that managed providers find and return information about the database schema, also known as metadata, of a given database. 不同的数据库架构元素(例如表、列和存储过程)通过架构集合进行公开。Different database schema elements such as tables, columns, and stored-procedures are exposed through schema collections. 每个架构集合包含所使用的提供程序特定的各种架构信息。Each schema collection contains a variety of schema information specific to the provider being used.

每个 .NET Framework 托管提供程序都实现连接类中的GetSchema方法, GetSchema方法返回的架构信息DataTable采用的形式。Each of the .NET Framework managed providers implement the GetSchema method in the Connection class, and the schema information that is returned from the GetSchema method comes in the form of a DataTable. GetSchema方法是一种重载方法,该方法提供了用于指定要返回的架构集合以及限制返回的信息量的可选参数。The GetSchema method is an overloaded method that provides optional parameters for specifying the schema collection to return, and restricting the amount of information returned.

用于 OLE DB、ODBC、Oracle 和 SqlClient 的 .NET Framework 数据提供程序提供了一个GetSchemaTable方法,该方法可返回描述DataReader的列元数据的 DataTable。The .NET Framework Data Providers for OLE DB, ODBC, Oracle, and SqlClient provide a GetSchemaTable method that returns a DataTable describing the column metadata of the DataReader.

适用于 OLE DB 的 .NET Framework 数据提供程序还使用 GetOleDbSchemaTable 对象的 OleDbConnection 方法来公开架构信息。The .NET Framework Data Provider for OLE DB also exposes schema information by using the GetOleDbSchemaTable method of the OleDbConnection object. 作为参数, GetOleDbSchemaTable采用OleDbSchemaGuid标识要返回的架构信息的,以及对那些返回列的限制数组。As arguments, GetOleDbSchemaTable takes an OleDbSchemaGuid that identifies the schema information to return, and an array of restrictions on those returned columns. GetOleDbSchemaTable返回用DataTable请求的架构信息填充的。GetOleDbSchemaTable returns a DataTable populated with the requested schema information.

本节内容In This Section

GetSchema 和架构集合GetSchema and Schema Collections
介绍GetSchema方法以及如何使用它来从数据库中检索和限制架构信息。Describes the GetSchema method and how it can be used to retrieve and restrict schema information from a database.

架构限制Schema Restrictions
介绍可用于GetSchema的架构限制。Describes schema restrictions that can be used with GetSchema.

公共架构集合Common Schema Collections
描述所有 .NET Framework 托管提供程序均支持的所有通用架构集合。Describes all of the common schema collections supported by all of the .NET Framework managed providers.

SQL Server 架构集合SQL Server Schema Collections
描述适用于 SQL Server 的 .NET Framework 提供程序支持的架构集合。Describes the schema collection supported by the .NET Framework provider for SQL Server.

Oracle 架构集合Oracle Schema Collections
描述适用于 Oracle 的 SQL Server .NET Framework 提供程序支持的架构集合。Describes the schema collection supported by the .NET Framework provider for Oracle.

ODBC 架构集合ODBC Schema Collections
描述 ODBC 驱动程序的架构集合。Describes the schema collections for ODBC drivers.

OLE DB 架构集合OLE DB Schema Collections
描述 OLE DB 提供程序的架构集合。Describes the schema collections for OLE DB providers.

参考Reference

GetSchema
描述DbConnection类的GetSchema方法。Describes the GetSchema method of the DbConnection class.

GetSchema
描述OdbcConnection类的GetSchema方法。Describes the GetSchema method of the OdbcConnection class.

GetSchema
描述OleDbConnection类的GetSchema方法。Describes the GetSchema method of the OleDbConnection class.

GetSchema
描述OracleConnection类的GetSchema方法。Describes the GetSchema method of the OracleConnection class.

GetSchema
描述SqlConnection类的GetSchema方法。Describes the GetSchema method of the SqlConnection class.

GetSchemaTable
描述DbDataReader类的GetSchemaTable方法。Describes the GetSchemaTable method of the DbDataReader class.

GetSchemaTable
描述OdbcDataReader类的GetSchemaTable方法。Describes the GetSchemaTable method of the OdbcDataReader class.

GetSchemaTable
描述OleDbDataReader类的GetSchemaTable方法。Describes the GetSchemaTable method of the OleDbDataReader class.

GetSchemaTable
描述OracleDataReader类的GetSchemaTable方法。Describes the GetSchemaTable method of the OracleDataReader class.

GetSchemaTable
描述SqlDataReader类的GetSchemaTable方法。Describes the GetSchemaTable method of the SqlDataReader class.

请参阅See also