Updating Data
• SQL provides the UPDATE statement for changing data in a table. By using a single UPDATE statement, you can change one, some, or all rows in a table. The UPDATE statement uses the following syntax:
UPDATE table_name
SET column_1 = expression_1, column_2 = expression_2,
. . . , column_n = expression_n
[WHERE predicates] ;
EXAMPLE:
UPDATE table_name
SET column1 = value1, column2 = value2, . . .
WHERE condition;
THE UPDATE STATEMENT
• The WHERE clause is optional. This clause specifies the rows that you’re updating. If you don’t use a WHERE clause, all the rows in the table are updated. The SET clause specifies the new values for the columns that you’re changing.
UPDATE person
SET street = '1225 Tremont St.',
city = 'Boston',
state = 'MA',
country = 'USA',
postal_code = '02138'
WHERE person_id = 1;