Dynamodb 简明教程
DynamoDB - Delete Table
在本章中,我们将讨论如何删除表格以及删除表格的不同方法。
In this chapter, we will discuss regarding how we can delete a table and also the different ways of deleting a table.
表删除是一个简单的操作,只需要表名就可以进行。使用 GUI 控制台、Java 或其他任何选项执行此任务。
Table deletion is a simple operation requiring little more than the table name. Utilize the GUI console, Java, or any other option to perform this task.
Delete Table using the GUI Console
通过首先访问控制台执行删除操作:
Perform a delete operation by first accessing the console at −
从导航窗格中选择 Tables ,并从表列表中选择要删除的表,如下图所示。
Choose Tables from the navigation pane, and choose the table desired for deletion from the table list as shown in the following screeenshot.

最后,选择 Delete Table 。选择“删除表”后,会出现一个确认对话框。然后,你的表就被删除了。
Finally, select Delete Table. After choosing Delete Table, a confirmation appears. Your table is then deleted.
Delete Table using Java
使用 delete 方法删除表。下面给出示例以更好地解释该概念。
Use the delete method to remove a table. An example is given below to explain the concept better.
import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient;
import com.amazonaws.services.dynamodbv2.document.DynamoDB;
import com.amazonaws.services.dynamodbv2.document.Table;
public class ProductsDeleteTable {
public static void main(String[] args) throws Exception {
AmazonDynamoDBClient client = new AmazonDynamoDBClient()
.withEndpoint("http://localhost:8000");
DynamoDB dynamoDB = new DynamoDB(client);
Table table = dynamoDB.getTable("Products");
try {
System.out.println("Performing table delete, wait...");
table.delete();
table.waitForDelete();
System.out.print("Table successfully deleted.");
} catch (Exception e) {
System.err.println("Cannot perform table delete: ");
System.err.println(e.getMessage());
}
}
}