Bewerken

Delen via


Retrieving database schema information

Applies to: .NET Framework .NET .NET Standard

Download ADO.NET

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.

The Microsoft SqlClient Data Provider for SQL Server implements the GetSchema method in the SqlConnection class, and the schema information that is returned from the GetSchema method comes in the form of a DataTable. 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. The SqlClient data provider also provides a GetSchemaTable method that returns a DataTable describing the column metadata of the SqlDataReader.

In this section

GetSchema and schema collections
Describes the GetSchema method and how it can be used to retrieve and restrict schema information from a database.

Schema restrictions
Describes schema restrictions that can be used with GetSchema.

Common schema collections
Describes all of the common schema collections supported by all of the .NET managed providers.

SQL Server schema collections
Describes the additional schema collections supported by the Microsoft SqlClient Data Provider for SQL Server.

Reference

GetSchema
Describes the GetSchema method of the DbConnection class.

GetSchema
Describes the GetSchema method of the SqlConnection class.

GetSchemaTable
Describes the GetSchemaTable method of the DbDataReader class.

GetSchemaTable
Describes the GetSchemaTable method of the SqlDataReader class.

See also