Using the set clause with update

The set clause specifies columns and the changed values. The where clause determines which rows are to be updated. If you do not have a where clause, the specified columns of all the rows are updated with the values provided in the set clause.

NoteBefore trying the examples in this section, make sure you know how to reinstall the pubs2 database. See the Installation Guide and Configuration Guide for your platform for instructions.

For example, if all the publishing houses in the publishers table move their head offices to Atlanta, Georgia, update the table using:

update publishers 
set city = "Atlanta", state = "GA"

In the same way, you can change the names of all the publishers to NULL with:

update publishers 
set pub_name = null

You can use computed column values in an update. To double all the prices in the titles table, use:

update titles 
set price = price * 2

Since there is no where clause, the change in prices is applied to every row in the table.