DELETE
The DELETE
statement deletes map entries that match the condition in a given WHERE
clause.
This statement is not atomic. If it fails, a part of the rows might be deleted and another part might remain in the table. |
Syntax Summary
This code block is a quick reference with all the parameters that you can use with the DELETE
statement.
See some practical examples.
DELETE FROM table_name [ [ AS ] alias ]
[ WHERE condition ]
Parameters
The DELETE
statement accepts the following parameters.
You must provide a table_name
parameter.
Parameter | Description | Example |
---|---|---|
|
The table name to delete rows from. |
|
|
An optional clause that, if given, indicates the conditions that rows must satisfy to be deleted. |
Examples
This section lists some example SQL queries that show you how to use the DELETE
statement.
Delete Entries by Keys or Values
Currently, only IMap mappings support deleting rows.
For example, in a map that contains Employee
objects as values with the following structure:
Name |
Type |
|
|
|
|
|
|
|
|
You can delete the entries based on the age
field where the age is less than 18:
DELETE FROM employees WHERE age < 18;
Whether you can access nested fields like this in objects depends on how your map entries are serialized:
-
For Java objects (
Serializable
,DataSerializable
,IdentifiedDataSerializable
), you must add the object’s class to the classpath of the member you are sending the query to. -
For
Portable
/Compact(BETA)
objects, you do not need to add the object’s class to the classpath of the member, unless you want to use parameterized queries to compare one object against another.