Skip to content

LOOKUP predicate DELETE

LOOKUP DELETE supports general WHERE predicates as well as primary key equality. Every matching row is deleted.

Syntax

DELETE FROM table_name
 WHERE predicate;

Omitting WHERE deletes all rows in the LOOKUP table.

Supported Predicate Examples

-- Ordinary column predicate
DELETE FROM device_lookup
WHERE status = 'EXPIRED';

-- Date and range predicates
DELETE FROM device_lookup
WHERE updated_at < TO_DATE('2026-01-01 00:00:00')
   OR score < 10;

-- JSON path predicates
DELETE FROM device_lookup
WHERE meta->'$.region' = 'kr'
  AND JSON_EXTRACT_INTEGER(meta, '$.level') < 2;

Supported Predicates

PredicateSupported
pk_col = valueYes
non_pk_col = valueYes
<, <=, >, >=, <>Yes
BETWEENYes
IN, NOT INYes
LIKE, NOT LIKEYes
AND, OR, NOTYes
IS NULL, IS NOT NULLYes
TO_DATE(…) date predicatesYes
JSON ->, JSON_EXTRACT_*, JSON_IS_VALIDYes
Delete all rows without WHEREYes

Operational Considerations

General-predicate DELETE removes every matching row. For production data, verify the target scope with the same predicate before execution.

SELECT COUNT(*)
FROM device_lookup
WHERE status = 'EXPIRED';

DELETE FROM device_lookup
WHERE status = 'EXPIRED';

Related Documentation

Last updated on