Modifying Existing Data with the UPDATE Statement
The purpose of the UPDATE statement is to change the values of existing records. The syntax is |
UPDATE table_name SET columnname1 = value1 [, columname2 = value2]... WHERE search_condition
This statement checks the WHERE clause first. For all records in the given table in which the WHERE clause evaluates to TRUE, the corresponding value is updated.
Example 11.4
This example illustrates the use of the UPDATE statement:
SQL> UPDATE COLLECTION 2 SET WORTH = 900 3 WHERE ITEM = 'STRING'; 1 row updated.
To confirm the change, the query
SQL> SELECT * FROM COLLECTION 2 WHERE ITEM = 'STRING';
yields ...
Get Sams Teach Yourself SQL in 21 Days, 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.