Amazon.DynamoDBv2.AmazonDynamoDBClient.DeleteTable C# (CSharp) Method

DeleteTable() public method

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.

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 API to check the status of the table.

/// An error occurred on the server side. /// /// The number of concurrent table requests (cumulative number of tables in the CREATING, /// DELETING or UPDATING state) exceeds the maximum allowed /// of 10. /// /// /// /// Also, for tables with secondary indexes, only one of those tables can be in the CREATING /// state at any point in time. Do not attempt to create more than one such table simultaneously. /// /// /// /// The total limit of tables in the ACTIVE state is 250. /// /// /// The operation conflicts with the resource's availability. For example, you attempted /// to recreate an existing table, or tried to delete a table currently in the CREATING /// state. /// /// The operation tried to access a nonexistent table or index. The resource might not /// be specified correctly, or its status might not be ACTIVE. ///
public DeleteTable ( DeleteTableRequest request ) : DeleteTableResponse
request Amazon.DynamoDBv2.Model.DeleteTableRequest Container for the necessary parameters to execute the DeleteTable service method.
return Amazon.DynamoDBv2.Model.DeleteTableResponse
        public DeleteTableResponse DeleteTable(DeleteTableRequest request)
        {
            var marshaller = new DeleteTableRequestMarshaller();
            var unmarshaller = DeleteTableResponseUnmarshaller.Instance;

            return Invoke<DeleteTableRequest,DeleteTableResponse>(request, marshaller, unmarshaller);
        }

Same methods

AmazonDynamoDBClient::DeleteTable ( string tableName ) : DeleteTableResponse

Usage Example

        /// <summary>
        /// Deletes all sample tables
        /// </summary>
        /// <param name="client"></param>
        public static void DeleteSampleTables(AmazonDynamoDBClient client)
        {
            foreach (var table in SAMPLE_TABLE_NAMES)
            {
                Console.WriteLine("Deleting table " + table);
                client.DeleteTable(new DeleteTableRequest { TableName = table });
            }

            int remainingTables;
            do
            {
                Console.WriteLine("While sample tables still exist, sleeping for 5 seconds...");
                Thread.Sleep(TimeSpan.FromSeconds(5));

                Console.WriteLine("Getting list of tables");
                var currentTables = client.ListTables().TableNames;
                remainingTables = currentTables.Intersect(SAMPLE_TABLE_NAMES).Count();
            } while (remainingTables > 0);

            Console.WriteLine("Sample tables deleted");
        }
All Usage Examples Of Amazon.DynamoDBv2.AmazonDynamoDBClient::DeleteTable