Updating Rows with UPDATE

The UPDATE statement changes the values in a table’s existing rows. You can use UPDATE to update:

  • All rows in a table

  • Specific rows in a table

To update rows, you specify:

  • The table to update

  • The names of the columns to update and their new values

  • An optional search condition that specifies which rows to update

The important characteristics of UPDATE are:

  • UPDATE takes an optional WHERE clause that specifies which rows to update. Without a WHERE clause, UPDATE changes all the rows in the table.

  • UPDATE is dangerous because it’s easy to omit the WHERE clause mistakenly (and update all rows) or misspecify the WHERE search condition (and update the wrong rows). It’s wise to run a SELECT statement that uses the same WHERE clause ...

Get SQL: Visual QuickStart Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.