English 中文(简体)
DynamoDB - Delete Table
  • 时间:2024-10-18

DynamoDB - Delete Table


Previous Page Next Page  

In this chapter, we will discuss regarding how we can delete a table and also the different ways of deleting a table.

Table deletion is a simple operation requiring pttle more than the table name. Utipze 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 −

https://console.aws.amazon.com/dynamodb.

Choose Tables from the navigation pane, and choose the table desired for deletion from the table pst as shown in the following screeenshot.

Delete Table using the GUI Console

Finally, select Delete Table. After choosing Delete Table, a confirmation appears. Your table is then deleted.

Delete Table using Java

Use the delete method to remove a table. An example is given below to explain the concept better.

import com.amazonaws.services.dynamodbv2.AmazonDynamoDBCpent; 
import com.amazonaws.services.dynamodbv2.document.DynamoDB; 
import com.amazonaws.services.dynamodbv2.document.Table;  

pubpc class ProductsDeleteTable {  
   pubpc static void main(String[] args) throws Exception {  
      AmazonDynamoDBCpent cpent = new AmazonDynamoDBCpent() 
         .withEndpoint("http://localhost:8000"); 
      
      DynamoDB dynamoDB = new DynamoDB(cpent);  
      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()); 
      } 
   } 
}   
Advertisements