Delete From (Delta Lake on Databricks)
DELETE FROM [db_name.]table_name [AS alias] [WHERE predicate]
Delete the rows that match a predicate. When no predicate is provided, delete all rows.
WHERE
Filter rows by predicate.
The WHERE
predicate supports subqueries, including IN
, NOT IN
, EXISTS
, NOT EXISTS
, and scalar subqueries. The following types of subqueries are not supported:
- Nested subqueries, that is, an subquery inside another subquery
NOT IN
subquery inside anOR
, for example,a = 3 OR b NOT IN (SELECT c from t)
In most cases, you can rewrite NOT IN
subqueries using NOT EXISTS
. We recommend using
NOT EXISTS
whenever possible, as DELETE
with NOT IN
subqueries can be slow.