Changing Existing Data: UPDATE

While the INSERT statement adds new rows to a table, the UPDATE statement changes existing rows. Use it to change values in single rows, groups of rows, or all the rows in a table.

The UPDATE statement specifies the row or rows you want to change and the new data. The new data can be a constant or expression that you specify, or it can be data pulled from other tables.

Here's a simplified version of the UPDATE syntax for updating specified rows with an expression:

UPDATE table_name
SET column_name = expression
[WHERE search_conditions]

Specifying the Table: UPDATE Clause

The UPDATE keyword is followed by the name of a table or view. As in all the data modification statements, you can change the data in only one ...

Get Practical SQL Handbook, The: Using SQL Variants, Fourth Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.