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 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.