DynamoDB - Delete Items

Deleting an element in DynamoDB requires only the table name and element key. It is also highly recommended to use a conditional, which will be necessary to avoid deleting the wrong elements.
As usual, you can use the GUI console, Java, or any other necessary tool to accomplish this task.
Delete Items Using the GUI Console
Go to console. On the navigation bar on the left, select Tables . Then select the table name and the Elements tab .
Select the items you want to remove and select Actions | Delete
The Delete Items dialog box will appear as shown in the following screenshot. Select "Delete" to confirm.
How to remove elements using Java?
Using Java in item deletion operations simply involves creating a DynamoDB client instance and calling the deleteItem method with the item's key.
You can see the following example where this has been explained in detail.
DynamoDB dynamoDB = new DynamoDB ( new AmazonDynamoDBClient ( new ProfileCredentialsProvider ())); Table table = dynamoDB . getTable ( "ProductList" ); DeleteItemOutcome outcome = table . deleteItem ( "IDnum" , 151 );
You can also specify options to protect against incorrect deletion. Just use ConditionExpression .
For example -
Map < String , Object > expressionAttributeValues ​​= new HashMap < String , Object >(); expressionAttributeValues ​​. put ( ":val" , false ); DeleteItemOutcome outcome = table . deleteItem ( "IDnum" , 151 , "Ship = :val" , null , // doesn't use ExpressionAttributeNames expressionAttributeValues ​​);
Below is a larger example for better understanding.
Note. The following example can use a previously created data source. Before attempting to execute, acquire the supporting libraries and create the necessary data sources (tables with the required characteristics or other referenced sources).
This example also uses the Eclipse IDE, an AWS credential file, and the AWS Toolkit in an Eclipse AWS Java project.