DB2 Version 9.7 for Linux, UNIX, and Windows

DB2Connection.GetSchema () Method

Returns a DataTable that contains metadata for the data source that is associated with a DB2Connection instance.

Namespace:
IBM®.Data.DB2®
Assembly:
IBM.Data.DB2 (in IBM.Data.DB2.dll)

Syntax

[Visual Basic]
Public Overrides Function GetSchema As DataTable
[C#]
public override DataTable GetSchema ()
[C++]
public:
virtual DataTable^ GetSchema () override
[JScript]
public override function GetSchema () : DataTable

Return value

A DataTable instance, which contains metadata for the data source associated with this DB2Connection instance. Returned DataTable instance contains:
  • String values of DB2MetaDataCollectionNames enumeration supported by the connection.
  • Number of restriction values that can be specified for each metadata collection. Output example of collection name and associated number of restrictions are shown in table 1.
    Table 1. Output example of collection name and associated number of restrictions
    CollectionName NumberOfRestrictions
    DataSourceInformation 0
    TablePrivileges 3
    ColumnPrivileges 4
    Restrictions 0
    Columns 4
    ProcedureParameters 5
    MetaDataCollections 0
    Indexes 5
    Procedures 4
    DataTypes 0
    Catalogs 0
    PrimaryKeys 3
    Tables 4
    ForeignKeys 6
    ReservedWords 0
    Schemas 0

Example

[C#] The following line of C# code demonstrates how to retrieve the available metadata for the data source that is associated with a DB2Connection instance. The application can use the module name as one of the restrictions.

[C#]
    DataTable table2 = conn.GetSchema();
Example of values returned by the GetSchema method are as follows:
TABLE_SCHEMA=ADMINISTRATOR
TABLE_SCHEMA=NULLID
-
-
TABLE_SCHEMA=SYSSTAT

Version information

Last update
This topic was last updated for: IBM DB2 Version 9.7, Fix Pack 2
.NET Framework version
Supported in: 2.0 , 3.0, 3.5, and 4.0
IBM Data Server Client
Supported in: IBM DB2 Version 9 or later
IBM Data Server
Supported in: IBM DB2 Version 9 or later