Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 11.0.1 (Français) » SQL Anywhere Server - Programming » SQL Anywhere Data Access APIs » SQL Anywhere .NET 2.0 API reference » iAnywhere.Data.SQLAnywhere namespace (.NET 2.0) » SAConnection class » GetSchema methods

 

GetSchema(String, String[]) method

Returns schema information for the data source of this SAConnection object and, if specified, uses the specified string for the schema name and the specified string array for the restriction values.

Syntax
Visual Basic

Public Overrides Function GetSchema( _
   ByVal collection As String, _
   ByVal restrictions As String() _
) As DataTable
C#

public override DataTable GetSchema(
   string  collection,
   string [] restrictions
);
Return value

A DataTable that contains schema information.

Remarks

These methods are used to query the database server for various metadata. Each type of metadata is given a collection name, which must be passed to receive that data. The default collection name is MetaDataCollections.

You can query the SQL Anywhere SQL Anywhere .NET Data Provider to determine the list of supported schema collections by calling the GetSchema method with no arguments, or with the schema collection name MetaDataCollections. This will return a DataTable with a list of the supported schema collections (CollectionName), the number of restrictions that they each support (NumberOfRestrictions), and the number of identifier parts that they use (NumberOfIdentifierParts).

Collection

Metadata

Columns Returns information on all columns in the database.
DataSourceInformation Returns information about the database server.
DataTypes Returns a list of supported data types.
ForeignKeys Returns information on all foreign keys in the database.
IndexColumns Returns information on all index columns in the database.
Indexes Returns information on all indexes in the database.
MetaDataCollections Returns a list of all collection names.
ProcedureParameters Returns information on all procedure parameters in the database.
Procedures Returns information on all procedures in the database.
ReservedWords Returns a list of reserved words used by SQL Anywhere.
Restrictions Returns information on restrictions used in GetSchema.
Tables Returns information on all tables in the database.
UserDefinedTypes Returns information on all user-defined data types in the database.
Users Returns information on all users in the database.
ViewColumns Returns information on all columns in views in the database.
Views Returns information on all views in the database.

These collection names are also available as read-only properties in the SAMetaDataCollectionNames class.

The results returned can be filtered by specifying an array of restrictions in the call to GetSchema.

The restrictions available with each collection can be queried by calling:

GetSchema( "Restrictions" )

If the collection requires four restrictions, then the restrictions parameter must be either NULL, or a string with four values.

To filter on a particular restriction, place the string to filter by in its place in the array and leave any unused places NULL. For example, the Tables collection has three restrictions: Owner, Table, and TableType.

To filter the Table collection by table_name:

GetSchema( "Tables", new string[ ] { NULL, "my_table", NULL } ) 

This returns information on all tables named my_table.

GetSchema( "Tables", new string[ ] { "DBA", "my_table", NULL } )

This returns information on all tables named my_table owned by the user DBA.

The following is a summary of the columns returned by each collection. If the number of rows returned in a collection can be reduced by specifying a restriction on a column, the restriction name for that column is shown in parenthesis. The order in which restrictions are specified is the order in which they are presented in the lists below.

Columns collection
DataSourceInformation collection
DataTypes collection
ForeignKeys collection
IndexColumns collection
Indexes collection
MetaDataCollections collection
ProcedureParameters collection
Procedures collection
ReservedWords collection
Restrictions collection
Tables collection
UserDefinedTypes collection
Users collection
ViewColumns collection
Views collection
See also