The DeleteTable operation deletes a table and all of its items. After a DeleteTable request, the specified table is in the DELETING state until DynamoDB completes the deletion. If the table is in the ACTIVE state, you can delete it. If a table is in CREATING or UPDATING states, then DynamoDB returns a ResourceInUseException. If the specified table does not exist, DynamoDB returns a ResourceNotFoundException. If table is already in the DELETING state, no error is returned.
DynamoDB might continue to accept data read and write operations, such as GetItem and PutItem, on a table in the DELETING state until the table deletion is complete. For the full list of table states, see TableStatus.
When you delete a table, any indexes on that table are also deleted.
If you have DynamoDB Streams enabled on the table, then the corresponding stream on that table goes into the DISABLED state, and the stream is automatically deleted after 24 hours.
Use the DescribeTable action to check the status of the table.
Parameters:
-
table_name
(TableArn)
–
The name of the table to delete. You can also provide the Amazon Resource Name (ARN) of the table in this parameter.
Raises:
-
InternalServerError
–
An error occurred on the server side.
-
LimitExceededException
–
There is no limit to the number of daily on-demand backups that can be taken.
For most purposes, up to 500 simultaneous table operations are allowed per account. These operations include CreateTable, UpdateTable, DeleteTable,UpdateTimeToLive, RestoreTableFromBackup, and RestoreTableToPointInTime.
When you are creating a table with one or more secondary indexes, you can have up to 250 such requests running at a time. However, if the table or index specifications are complex, then DynamoDB might temporarily reduce the number of concurrent operations.
When importing into DynamoDB, up to 50 simultaneous import table operations are allowed per account.
There is a soft account quota of 2,500 tables.
GetRecords was called with a value of more than 1000 for the limit request parameter.
More than 2 processes are reading from the same streams shard at the same time. Exceeding this limit may result in request throttling.
-
ResourceInUseException
–
The operation conflicts with the resource's availability. For example:
-
You attempted to recreate an existing table.
-
You tried to delete a table currently in the CREATING state.
-
You tried to update a resource that was already being updated.
When appropriate, wait for the ongoing update to complete and attempt the request again.
-
ResourceNotFoundException
–
The operation tried to access a nonexistent table or index. The resource might not be specified correctly, or its status might not be ACTIVE.
-
UnknownServiceError
–
The service returned an error code this client does not model.
Examples:
To delete a table
This example deletes the Music table.
>>> await client.delete_table(table_name='Music')
Source code in docs_src/capo_dynamodb/_services/async_dynamo_db.py
| async def delete_table(
self,
table_name: "capo_dynamodb.types.table_arn.TableArn",
*,
config_overrides: Optional[AsyncDynamoDBClientConfig] = None,
) -> "capo_dynamodb.types.delete_table_output.DeleteTableOutput":
"""<p>The <code>DeleteTable</code> operation deletes a table and all of its items. After a <code>DeleteTable</code> request, the specified table is in the <code>DELETING</code> state until DynamoDB completes the deletion. If the table is in the <code>ACTIVE</code> state, you can delete it. If a table is in <code>CREATING</code> or <code>UPDATING</code> states, then DynamoDB returns a <code>ResourceInUseException</code>. If the specified table does not exist, DynamoDB returns a <code>ResourceNotFoundException</code>. If table is already in the <code>DELETING</code> state, no error is returned. </p> <note> <p>DynamoDB might continue to accept data read and write operations, such as <code>GetItem</code> and <code>PutItem</code>, on a table in the <code>DELETING</code> state until the table deletion is complete. For the full list of table states, see <a href="https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_TableDescription.html#DDB-Type-TableDescription-TableStatus">TableStatus</a>.</p> </note> <p>When you delete a table, any indexes on that table are also deleted.</p> <p>If you have DynamoDB Streams enabled on the table, then the corresponding stream on that table goes into the <code>DISABLED</code> state, and the stream is automatically deleted after 24 hours.</p> <p>Use the <code>DescribeTable</code> action to check the status of the table. </p>
Args:
table_name: <p>The name of the table to delete. You can also provide the Amazon Resource Name (ARN) of the table in this parameter.</p>
Raises:
capo_dynamodb.errors.internal_server_error.InternalServerError: <p>An error occurred on the server side.</p>
capo_dynamodb.errors.invalid_endpoint_exception.InvalidEndpointException
capo_dynamodb.errors.limit_exceeded_exception.LimitExceededException: <p>There is no limit to the number of daily on-demand backups that can be taken. </p> <p>For most purposes, up to 500 simultaneous table operations are allowed per account. These operations include <code>CreateTable</code>, <code>UpdateTable</code>, <code>DeleteTable</code>,<code>UpdateTimeToLive</code>, <code>RestoreTableFromBackup</code>, and <code>RestoreTableToPointInTime</code>. </p> <p>When you are creating a table with one or more secondary indexes, you can have up to 250 such requests running at a time. However, if the table or index specifications are complex, then DynamoDB might temporarily reduce the number of concurrent operations.</p> <p>When importing into DynamoDB, up to 50 simultaneous import table operations are allowed per account.</p> <p>There is a soft account quota of 2,500 tables.</p> <p>GetRecords was called with a value of more than 1000 for the limit request parameter.</p> <p>More than 2 processes are reading from the same streams shard at the same time. Exceeding this limit may result in request throttling.</p>
capo_dynamodb.errors.resource_in_use_exception.ResourceInUseException: <p>The operation conflicts with the resource's availability. For example:</p> <ul> <li> <p>You attempted to recreate an existing table.</p> </li> <li> <p>You tried to delete a table currently in the <code>CREATING</code> state.</p> </li> <li> <p>You tried to update a resource that was already being updated.</p> </li> </ul> <p>When appropriate, wait for the ongoing update to complete and attempt the request again.</p>
capo_dynamodb.errors.resource_not_found_exception.ResourceNotFoundException: <p>The operation tried to access a nonexistent table or index. The resource might not be specified correctly, or its status might not be <code>ACTIVE</code>.</p>
capo_dynamodb.errors.UnknownServiceError: The service returned an error code this client does not model.
Examples:
To delete a table
This example deletes the Music table.
>>> await client.delete_table(table_name='Music')
"""
async def _handler(
req: "AsyncOperationRequest[capo_dynamodb.types.delete_table_input.DeleteTableInput]",
) -> AsyncOperationResponse[
"capo_dynamodb.types.delete_table_output.DeleteTableOutput"
]:
import capo_dynamodb._operations.dynamo_db_20120810.delete_table
(
output,
http_response,
) = await capo_dynamodb._operations.dynamo_db_20120810.delete_table.async_delete_table(
req.options, req.input
)
return AsyncOperationResponse(output=output, response=http_response)
interceptors_, options_ = self.operation_options(
config_overrides, OperationLogging("DeleteTable")
)
input_: capo_dynamodb.types.delete_table_input.DeleteTableInput = {
"table_name": table_name
}
response = await aexecute_pipeline(
AsyncOperationRequest(input=input_, options=options_),
handler=_handler,
interceptors=list(interceptors_),
)
await response.response.aclose()
return response.output
|