UPDATE

Name

UPDATE  --  Modifies the values of column data within a table.

Synopsis

UPDATE table SET col = expression [, ...]
    [ FROM fromlist ]
    [ WHERE condition ]
  

Parameters

table

Use this parameter to specify the name of an existing table to update.

column

Use this parameter to specify the name of a column to update in the table you specified.

expression

This parameter takes the expression or value that you want assigned to the specified column.

fromlist

A PostgreSQL extension of the UPDATE command is the ability to use column values from other tables within the WHERE condition; to do this correctly, you must use this parameter to list the tables you will be pulling column values from.

condition

Use this parameter to state the WHERE condition for UPDATE to use. This can be any valid expression.

Results

UPDATE #

This message is displayed if the UPDATE was successful. The # will be equivalent to the number of rows that were modified as a result of the UPDATE. If # is zero, then no rows were updated.

Description

Use the UPDATE command to modify column values of all rows that match your WHERE condition. You can also use this command to update the values of array columns, including single elements, a range, or the entire array. To update only the table specified, pass the >ONLY parameter, otherwise all sub-tables will be updated as well.

NotePermissions
 

You must have write access to any columns you are attempting to modify, and read access to any columns referenced within your WHERE statement.

Examples

The following example will subtract five from the total stock number for the book with the specified ISBN.

booktown=# UPDATE STOCK SET STOCK = STOCK -5 WHERE isbn = '0385121679';
UPDATE 1