UPDATE
SQL - Language Statements
UPDATE
update rows of a table
UPDATE [ ONLY ] table SET column = expression [, ...]
[ FROM fromlist ]
[ WHERE condition ]
Description
UPDATE changes the values of the specified
columns in all rows that satisfy the condition. Only the columns to
be modified need appear as columns in the statement.
By default, UPDATE will update rows in the
specified table and all its subtables. If you wish to only update
the specific table mentioned, you must use the ONLY>
clause.
You must have the UPDATE privilege on the table
to update it, as well as the SELECT
privilege to any table whose values are read in the condition.
Parameters
table
The name (optionally schema-qualified) of the table to update.
column
The name of a column in table.
expression
An expression or value to assign to the column.
fromlist
A list of table expressions, allowing columns from other tables
to appear in the WHERE> condition.
condition
A value expression that returns a value of type
boolean that determines the rows which are to be
updated.
Diagnostics
UPDATE count
Message returned if successful. The value count is the number of rows
updated. If count
is 0, no rows were updated.
Examples
Change the word Drama> to Dramatic> in the
column kind> of the table films:
UPDATE filme SET kind = 'Dramatic' WHERE kind = 'Drama';
Compatibility
This command conforms to the SQL standard. The
FROM clause is a PostgreSQL extension.