Skip to content
Daniël van Eeden edited this page Mar 13, 2024 · 4 revisions

SQL standard specifies the following DELETE syntax:

DELETE FROM { table_name | ONLY "(" table_name ")" } [[AS] alias]
  [WHERE condition | WHERE CURRENT OF cursor_name]

This base syntax is pretty well supported (except in Spark):

BigQuery:

DELETE [FROM] table_name [alias]
  WHERE condition

DB2:

DELETE FROM { table_name | ONLY "(" table_name ")" | "(" fullselect ")" }
  [[AS] correlation_clause]
  [INCLUDE include_columns]
  [assignment_clause]
  [WHERE condition | WHERE CURRENT OF cursor_name]
  [WITH {RR | RS | CS | UR}]

Hive:

DELETE FROM table_name
  [WHERE condition]

MariaDB:

DELETE [LOW_PRIORITY] [QUICK] [IGNORE] FROM table_name
  [PARTITION "(" partition_list ")"]
  [FOR PORTION OF period FROM expr1 TO expr2]
  [FROM from_clause]
  [USING using_clause]
  [WHERE condition]
  [ORDER BY ...]
  [LIMIT row_count]
  [RETURNING returning_clause]

MySQL:

DELETE [LOW_PRIORITY] [QUICK] [IGNORE] FROM table_name [[AS] alias]
  [PARTITION "(" partition_list ")"]
  [WHERE condition]
  [ORDER BY ...]
  [LIMIT row_count]

N1QL:

DELETE FROM table_name
  [USE [PRIMARY] KEYS expr]
  [WHERE condition]
  [LIMIT expr]
  [RETURNING returning_clause]

PL/SQL:

DELETE [hint] FROM { table_name | ONLY "(" table_name ")" } [alias]
  [WHERE condition]
  [[RETURN | RETURNING] returning_clause]
  [LOG ERRORS error_logging_clause]

PostgreSQL:

[WITH [RECURSIVE] with_clause]
DELETE FROM [ONLY] table_name [ * ] [[AS] alias]
  [USING from_items]
  [WHERE condition | WHERE CURRENT OF cursor_name]
  [RETURNING returning_clause]

Redshift:

[WITH [RECURSIVE] with_clause]
DELETE [FROM] table_name
  [USING from_items]
  [WHERE condition]

SingleStoreDB:

DELETE FROM table_name
  [WHERE expr]
  [LIMIT count]

DELETE table_name FROM table_references
  [WHERE expr]
  [LIMIT count]

Snowflake:

DELETE FROM table_name
  [USING from_items]
  [WHERE condition]

Spark:

No support for DELETE

SQLite:

[WITH [RECURSIVE] with_clause]
DELETE FROM table_name
  [FROM from_clause]
  [WHERE condition]
  [RETURNING returning_clause]

TiDB:

DELETE [LOW_PRIORITY] [QUICK] [IGNORE] FROM table_name [[AS] alias]
  [PARTITION "(" partition_list ")"]
  [WHERE condition]
  [ORDER BY ...]
  [LIMIT row_count]

Transact-SQL:

[WITH with_clause]
DELETE [TOP ( expression ) [PERCENT]] FROM table_name
  [FROM from_clause]
  [WHERE condition | WHERE CURRENT OF [GLOBAL] cursor_name]
  [OPTION query_hints]

Trino:

DELETE FROM table_name [WHERE condition]
Clone this wiki locally