You can execute the SHOW TABLES statement to query the names of tables in the current database.
Note For more information about the show tables statement, see List table names.
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. Specify the parameter based on the required feature. |
Example
Execute the show tables
statement to list the names of tables.
def show_tables(client):
query = 'show tables'
rowlist, _, _ = client.exe_sql_query(query)
ret = []
for row in rowlist:
ret.append(row.attribute_columns)
print(ret)
The following output is returned:
Note
The instance_name
parameter in the response indicates the name of the Tablestore instance. The actual value returned prevails.
[[('Tables_in_instance_name', 'exampletable')],
[('Tables_in_instance_name', 'test_table')]]