Deletes 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 deleting the data table.
If a secondary index exists on the data table, it is automatically deleted along with the data table.
After a data table and its secondary indexes 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 |
|
|
|
Yes |
The name of the data table to delete. |
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. Error: %s" % e)
References
-
Note: This link points to the Go SDK reference. Refer to the Python SDK documentation for the equivalent Python method.