Previous |
Next |
The UPDATE
statement updates (changes the values of) a set of existing table rows.
A simple form of the UPDATE
statement has this syntax:
UPDATE table_name SET column_name = value [, column_name = value]... [ WHERE condition ];
Each value
must be valid for its column_name
. Therefore, before you update a column, you must know what its valid values are. To get this information using SQL Developer, see Tutorial: Viewing EMPLOYEES Table Properties and Data. To get this information using SQL*Plus, use this statement:
DESCRIBE table_name;
If you include the WHERE
clause, the statement updates column values only in rows that satisfy condition
.
The UPDATE
statement in the following example updates the value of the SALARY
column in the row that was inserted into the EMPLOYEES
table in About the INSERT Statement, before the salary of the employee was known.
Using the UPDATE Statement to Add Data
UPDATE EMPLOYEES
SET SALARY = 8500
WHERE LAST_NAME = 'Keats';
Result:
1 row updated.
The UPDATE
statement in the following example updates the commission percentage for every employee in department 80.
Using the UPDATE Statement to Update Multiple Rows
UPDATE EMPLOYEES SET COMMISSION_PCT = COMMISSION_PCT + 0.05 WHERE DEPARTMENT_ID = 80;
Result:
36 rows updated.
Oracle Database SQL Language Reference for information about the UPDATE
statement
Oracle Database SQL Language Reference for information about data types