UPDATE Statement

UPDATE changes the values in existing rows of a table. You set the new column values and use a WHERE clause to choose which rows are affected.

SQL

The WHERE clause is critical: without it, UPDATE changes every single row in the table. Always double-check your condition before running an update.

You can update several columns at once by separating the assignments with commas in the SET clause.

Syntax

UPDATE table_name
SET column1 = value1
WHERE condition;

Examples

SQL

UPDATE users
SET age = 31
WHERE name = 'Alice';

Output:

1 row updated.

Learn it in a lesson

See also

Back to the Dictionary