PostgreSQL – UPDATE

PostgreSQL has an UPDATE statement that is used to update or modify an existing data in the table.

Syntax:
UPDATE table
SET column1 = value1,
    column2 = value2, ...
WHERE
    condition;

Let’s analyze the above syntax:

  • First step is to specify the table where the changes are supposed to be made.
  • Then we list the columns whose value is to be updated using the SET clause.
  • The final step is to determine which rows you want to update exactly using the WHERE clause.

Let’s set up a sample database and table for the demonstration of UPDATE statement.