PL/SQL Update

The Update statement is part of Data Manipulation Language and allows the user to update a single record or multiple records in a table.

Syntax:

UPDATE table SET column1 = new_value1;

UPDATE table SET 
	column1 = value1, 
	column2 = value2, 
	column3 = value3, ... 
WHERE condition;




Example 1:

UPDATE employees SET salary = 100;

UPDATE employees 
SET salary = 2000, 
	city_name='London' 
WHERE dept_id=10;

Example 2:

UPDATE employees e
   SET e.city_id = (SELECT c.city_id 
					FROM cities c 
					WHERE c.city_name='London')
 WHERE EXISTS (SELECT d.dept_id 
				FROM departments d 
				WHERE d.dept_id=e.dept_id 
				AND d.dept_id=10);