The PostgreSQL Update query is used to modify the existing rows of the column with the new value. If there is where clause mentioned then it will update only those records in which condition is qualifying. The columns that need to be modified should be put in the SET clause. To run the Update query, we should have the UPDATE privilege present on the table.
Following is the syntax of the PostgreSQL Update query.
1. Update Query With Where Clause
In this example, We will use the table PRODUCTS_DETAIL that we have created in create table section and use the Update command to update the column PRODUCT_NAME and set it to DARK CANDY where the PRODUCT_NUMBER is 101.
In the following output, we can see that the column data has been changed from CANDY to DARK CANDY.
2. Update Query Without Where Clause
If there is a requirement to update all rows of one column or multiple columns then, we can use the Update query without mentioning the where clause.
In the below example. we will update all records of column PRODUCT_NAME and make it RICE.
We can verify in the below output that the product_name column value has been set to Rice.