PostgreSQL UPDATE

PostgreSQL UPDATE query is used to update column values of a table. You can apply WHERE condition to apply UPDATE only on those values that satisfy the condition in WHERE clause.

The syntax of UPDATE query is:

</>
Copy
 UPDATE table_name
	SET column1 = value1, column2 = value2, columnN = valueN
	WHERE condition;

where value of column1 is set to value1, value of column2 is set to vaule2, and so on as defined in the SET clause.

PostgreSQL UPDATE Single Column for a Single Row

To update a single row, you have to provide a condition in WHERE clause where only one row is selected. In this case, the condition is usually based on the column which is unique.

Consider the following students table.