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

SQL standard specifies the following UPDATE syntax:

UPDATE { table_name | ONLY "(" table_name ")" } [[AS] alias]
  SET set_clause_list
  [WHERE condition | WHERE CURRENT OF cursor_name]

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

BigQuery:

UPDATE table_name [[AS] alias]
  SET set_clause_list
  [FROM from_clause]
  WHERE condition

DB2:

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

Hive:

UPDATE table_name
  SET set_clause_list
  [WHERE condition]

MariaDB:

UPDATE [LOW_PRIORITY] [IGNORE] table_name
  [PARTITION "(" partition_list ")"]
  [FOR PORTION OF period FROM expr1 TO expr2]
  SET set_clause_list
  [WHERE condition]
  [ORDER BY ...]
  [LIMIT row_count]

MySQL:

UPDATE [LOW_PRIORITY] [IGNORE] table_name
  SET set_clause_list
  [WHERE condition]
  [ORDER BY ...]
  [LIMIT row_count]

N1QL:

UPDATE table_name
  [USE [PRIMARY] KEYS expr]
  [SET set_clause_list]
  [UNSET unset_clause_list]
  [WHERE condition]
  [LIMIT expr]
  [RETURNING returning_clause]

PL/SQL:

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

PostgreSQL:

[WITH [RECURSIVE] with_clause]
UPDATE [ONLY] table_name [ * ] [[AS] alias]
  SET set_clause_list
  [FROM from_clause]
  [WHERE condition | WHERE CURRENT OF cursor_name]
  [RETURNING returning_clause]

Redshift:

[WITH [RECURSIVE] with_clause]
UPDATE table_name [[AS] alias]
  SET set_clause_list
  [FROM from_clause]
  [WHERE condition]

SingleStoreDB:

UPDATE table_name
  [[LEFT|RIGHT] JOIN [table_valued_expression] [ON condition]]
  SET set_clause_list
  [WHERE condition]
  [LIMIT count]

Snowflake:

UPDATE table_name
SET set_clause_list
[FROM from_clause]
[WHERE condition]

Spark:

No support for UPDATE

SQLite:

[WITH [RECURSIVE] with_clause]
UPDATE [OR action] table_name
  SET set_clause_list
  [FROM from_clause]
  [WHERE condition]
  [RETURNING returning_clause]

action:
  ABORT | FAIL | IGNORE | REPLACE | ROLLBACK

TiDB:

UPDATE [LOW_PRIORITY] [IGNORE] table_name
  SET set_clause_list
  [WHERE condition]
  [ORDER BY ...]
  [LIMIT row_count]

Transact-SQL:

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

Trino:

UPDATE table_name
  SET [(column = expression [, ... ])]
  [WHERE condition]
Clone this wiki locally