Delete a data table from a Tablestore instance by using the Tablestore SDK for Python.
Usage notes
If a search index exists on the data table, delete the search index before you delete the data table.
If a secondary index exists on the data table, the secondary index is automatically deleted when you delete the data table.
After a data table and its secondary index are deleted, they cannot be recovered. Proceed with caution.
Prerequisites
A Tablestore client is initialized. For more information, see Initialize a Tablestore client.
Method
def delete_table(self, table_name)Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
table_name | str | Yes | The name of the data table. |
Sample code
The following example deletes a data table named test_table.
from tablestore import OTSClient
# Initialize the client. For details, see "Initialize a Tablestore client".
# client = OTSClient(...)
try:
client.delete_table('test_table')
print("Delete table succeeded.")
except Exception as e:
print("Delete table failed. %s" % e)References
Note: This link points to the Go SDK reference. Refer to the Python SDK documentation for the equivalent Python method.