PL/SQL Delete

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

Syntax:

DELETE FROM table; -- delete all records
DELETE FROM table WHERE condition; -- delete single or multiple records;

Example 1:

DELETE FROM employees; -- delete all records
DELETE FROM employees WHERE name='Olivia' and id=7900 ; -- delete single record;
DELETE FROM employees WHERE dept_id=10; -- delete single or multiple records;

Example 2:

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