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

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

Prerequisites

Usage notes

Tablestore SDK for Java V5.13.0 or later supports the SQL query feature. Before you use the SQL query feature, make sure that Tablestore SDK for Java V5.13.0 or later is obtained. For more information about the version history of Tablestore SDK for Java, see Tablestore SDK for Java.

Parameters

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

Example

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

private static void showTable(SyncClient client) {
    // Create a SQL request. 
    SQLQueryRequest request = new SQLQueryRequest("show tables");

    // Obtain the response to the SQL request. 
    SQLQueryResponse response = client.sqlQuery(request);
    // Obtain the schema of the returned results of the SQL query statement. 
    SQLTableMeta tableMeta = response.getSQLResultSet().getSQLTableMeta();
    System.out.println("response table schema: " + tableMeta.getSchema());

    // Use SQL ResultSet to obtain all returned results of the SQL query statement. 
    System.out.println("response resultset:");
    SQLResultSet resultSet = response.getSQLResultSet();
    while (resultSet.hasNext()) {
        SQLRow row = resultSet.next();
        System.out.println(row.getString(0));
    }

    // Use the SQLUtils function to parse the response to obtain the list of table names. 
    System.out.println("response sqlutils resultset:");
    List<String> tables = SQLUtils.parseShowTablesResponse(response);
    for (String table : tables) {
        System.out.print(table + ", ");
    }
}
Sample output:
response table schema: [Tables_in_$instanceName:STRING]
response resultset:
test_table
response sqlutils resultset: test_table,