PostgreSQL · Command
UPDATE
UPDATE changes selected columns in rows that meet a condition. It can calculate values from existing columns, other tables, or subqueries, and can return results with RETURNING.
Last updated
Syntax
[ WITH [ RECURSIVE ] with_query [, ...] ] UPDATE [ ONLY ] table_name [ * ] [ [ AS ] alias ] SET { column_name = { expression | DEFAULT } | ( column_name [, ...] ) = [ ROW ] ( { expression | DEFAULT } [, ...] ) | ( column_name [, ...] ) = ( sub-SELECT ) } [, ...] [ FROM from_item [, ...] ] [ WHERE condition | WHERE CURRENT OF cursor_name ] [ RETURNING [ WITH ( { OLD | NEW } AS output_alias [, ...] ) ] { * | output_expression [ [ AS ] output_name ] } [, ...] ]In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.
SubscribeRelated
WITHFROMRETURNINGWHERE CURRENT OFDEFAULTSELECT