How to delete all items the table in a Dynamodb

Viewed 7919

I tried to delete all items using the PartiQL in AWS, but i receive that message

delete from myfile


An error occurred during the execution of the command.
ValidationException: Where clause does not contain a mandatory equality on all key attributes

enter image description here

2 Answers

I've got this error when I queried the filters with double quotes ("), but they are single quotes (') even though the fields themselves are double quotes.

Here's the WRONG way (the one i've got the same error as you):

DELETE FROM "TABLE_A" WHERE "PK" = "<PK_A>" AND "SK" < "2022-03-27T14:10:00.000Z"

Here's the RIGHT way(at least the way it worked for me):

DELETE FROM "TABLE_A" WHERE "PK" = '<PK_A>' AND "SK" < '2022-03-27T14:10:00.000Z'

Seems pretty straight forward...

ValidationException: Where clause does not contain a mandatory equality on all key attributes

If you look at the docs

The syntax is

DELETE FROM table
WHERE condition [RETURNING returnvalues]

and furthermore

condition (Required)
The selection criteria for the item to be deleted; this condition must resolve to a single primary key value.

If you want to delete all records in DDB, delete the table and recreate it.

Related