All Products
Search
Document Center

Tablestore:Query the names of mapping tables

Last Updated:Jun 11, 2024

You can execute the SHOW TABLES statement to query the names of mapping tables in the current database.

Note

For more information about the SHOW TABLES statement, see List mapping table names.

Prerequisites

Parameters

Parameter

Description

query

The SQL statement. Configure the parameter based on the required feature.

Examples

The following sample code provides an example on how to execute the SHOW TABLES statement to list the names of mapping tables.


func showTable(client *tablestore.TableStoreClient) {
    // Create an SQL request. 
    request := &tablestore.SQLQueryRequest{Query: "show tables"}

    // Obtain the response to the SQL request. 
    response, err := client.SQLQuery(request)
    if err != nil {
        panic(err)
    }

    // Obtain the schema of the returned results of the SQL request. 
    columns := response.ResultSet.Columns()
    fmt.Printf("response table schema: [%v:%v]\n", columns[0].Name,columns[0].Type.String())

    // Use SQL ResultSet to obtain all returned results of the SQL request. 
    fmt.Println("response resultset:")
    resultSet := response.ResultSet
    for resultSet.HasNext() {
        row := resultSet.Next()
        tableName, err := row.GetString(0)
        if err != nil {
            panic(err)
        }
        fmt.Println(tableName)
    }
}

Sample response:

Note

The $instanceName parameter indicates the name of the current instance. The value of the parameter varies based on the actual situation.

response table schema: [Tables_in_$instanceName:STRING]
response resultset:
test_table

References

After you query the names of the mapping tables, perform operations based on your business requirements.

  • To use a mapping table to query data that meets specific conditions, execute the SELECT statement. For more information, see Query data.

  • To query details of a mapping table such as field names and field types, execute the DESCRIBE statement. For more information, see Query information about a table.

  • To update the attribute column of a mapping table after an attribute column of the data table is changed, execute the ALTER TABLE statement. For more information, see Update attribute columns of mapping tables.

  • To delete a mapping table, execute the DROP MAPPING TABLE statement. For more information, see Delete mapping tables.