Update rows of a table.

Table of contents


UPDATE table_ident [ [AS] table_alias ] SET
    { column_ident = expression } [, ...]
  [ WHERE condition ]
  [ RETURNING { * | output_expression [ [ AS ] output_name ] | relation.* } [, ...] ]


UPDATE changes the values of the specified columns in all rows that satisfy the condition. Only the columns to be modified need be mentioned in the SET clause; columns not explicitly modified retain their previous values.

The optional RETURNING clause for UPDATE causes the query to return the specified values from each row that was updated. Any expression using the table’s columns can be computed. The new (post-update) values of the table’s columns are used. The syntax of the RETURNING list is identical to that of the output list of SELECT.



The identifier (optionally schema-qualified) of an existing table.


A substitute name for the target table.

When an alias is provided, it completely hides the actual name of the table. For example, given UPDATE foo AS f, the remainder of the UPDATE statement must refer to this table as f not foo.


The name of a column in the table identified by table_ident. It is also possible to use object subscript to address the inner fields of an object column.


An expression to assign to the column.


An expression that returns a value of type boolean. Only rows for which this expression returns true will be updated.


An expression to be computed and returned by the UPDATE command after each row is updated. The expression can use any column names of the table or * to return all columns. System columns can also be returned.


A name to use for the result of the output expression.