You can execute the describe statement to query information about tables, such as the field names and field types.
Note For more information about the describe statement, see Query the information about a table.
Prerequisites
- An OTSClient instance is initialized. For more information, see Initialization.
- A mapping table is created. For more information, see Create mapping tables.
Parameters
Parameter | Description |
---|---|
query | The SQL statement. Configure the parameter based on the required feature. |
Examples
Execute the describe test_table
statement to query information about the table named test_table.
/// <summary>
/// Query information about a table.
/// </summary>
/// <param name="otsClient"></param>
public static void DescribeTable(OTSClient otsClient)
{
SQLQueryRequest sqlQueryRequest = new SQLQueryRequest("describe test_table");
SQLQueryResponse sqlQueryResponse = otsClient.SQLQuery(sqlQueryRequest);
SQLTableMeta sqlTableMeta = sqlQueryResponse.GetSQLResultSet().GetSQLTableMeta();
Console.WriteLine(JsonConvert.SerializeObject(sqlTableMeta.GetSchema()));
ISQLResultSet resultSet = sqlQueryResponse.GetSQLResultSet();
while (resultSet.HasNext())
{
ISQLRow row = resultSet.Next();
Console.WriteLine(row.GetString(0) + " " + row.GetString(1) + " " + row.GetString(2) + " " +
row.GetString(3) + " " + row.GetString(4) + " " + row.GetString(5));
}
}