You can execute the show tables statement to list the names of tables in the current instance.

Note For more information about the show tables statement, see List table names.

Prerequisites

Parameters

Parameter Description
query The SQL statement. Configure the parameter based on the required feature.

Examples

Execute the show tables statement to list the names of tables.

/// <summary>
/// List the names of tables in an instance. 
/// </summary>
/// <param name="otsClient"></param>
public static void ShowTable(OTSClient otsClient)
{
    SQLQueryRequest sqlQuery = new SQLQueryRequest("show tables");

    SQLQueryResponse sqlQueryResponse = otsClient.SQLQuery(sqlQuery);

    SQLTableMeta sqlTableMeta = sqlQueryResponse.GetSQLResultSet().GetSQLTableMeta();
    Console.WriteLine(JsonConvert.SerializeObject(sqlTableMeta.GetSchema()));

    ISQLResultSet resultSet = sqlQueryResponse.GetSQLResultSet();
    while (resultSet.HasNext())
    {
        ISQLRow row = resultSet.Next();
        Console.WriteLine(JsonConvert.SerializeObject(row.GetString(0)));
    }

    List<string> tables = SQLUtils.ParseShowTablesResponse(sqlQueryResponse);
    foreach (string table in tables)
    {
        Console.WriteLine("Table: {0}", table);
    }
}