Index Columns
The IndexColumns schema collection lists the indexes and their corresponding columns. By filtering on indexes, you can write more selective queries with faster query response times.
Retrieving Index Column Information
To retrieve this schema collection, call the GetSchema method of the Office365Connection class. You can restrict the results by table name. The following example retrieves the column and sequence number for each index of the Microsoft Office 365 table Events.
C#
String connectionString = "InitiateOAuth=GETANDREFRESH;OAuthClientId=MyApplicationId;OAuthClientSecret=MySecretKey;CallbackURL=http://localhost:33333;"; using (Office365Connection conn = new Office365Connection(connectionString)) { conn.Open(); DataTable databaseSchema = conn.GetSchema("IndexColumns", new string[] {"Events"}); foreach (DataRow row in databaseSchema.Rows) { Console.WriteLine(row["COLUMN_NAME"]); Console.WriteLine(row["ORDINAL_POSITION"]); } }
VB.NET
Dim connectionString As String = "InitiateOAuth=GETANDREFRESH;OAuthClientId=MyApplicationId;OAuthClientSecret=MySecretKey;CallbackURL=http://localhost:33333;" Using conn As New Office365Connection(connectionString) conn.Open() Dim databaseSchema As DataTable = conn.GetSchema("IndexColumns", New String() {"Events"}) For Each row As DataRow In databaseSchema.Rows Console.WriteLine(row["COLUMN_NAME"]) Console.WriteLine(row["ORDINAL_POSITION"]) Next End Using
Columns Returned
The IndexColumns schema collection returns the following columns:
Column Name | Data Type | Description |
INDEX_CATALOG | System.String | The name of the database containing the index. |
INDEX_SCHEMA | System.String | The name of the schema containing the index. |
TABLE_NAME | System.String | The name of the table containing the index. |
INDEX_NAME | System.String | The name of the index. |
COLUMN_NAME | System.String | The name of the column associated with the index. |
ORDINAL_POSITION | System.Int32 | The sequence number of the column. |
SORT_ORDER | System.Int32 | Returns A for ascending and D for descending. |