Deleting Data With the DELETE Statement

Previous
Previous
Next
Next

With the SQL DELETE statement, you can delete all or specific rows in a table.

When you delete all the rows in a table, the empty table still exists. If you want to remove the entire table from the database, use the SQL DROP statement. See "Dropping a Table With SQL".

Example: Using the SQL DELETE Statement to Remove Rows From a Table shows how to use DELETE to delete selected rows in the employees table. Note the use of the WHERE clause. Without that clause, all the rows would be deleted.

Using the SQL DELETE Statement to Remove Rows From a Table

DELETE FROM employees WHERE employee_id = 10 OR employee_id = 11;

-- the following query should not find any records
SELECT * FROM employees WHERE employee_id = 10 OR employee_id = 11;

If you accidentally delete rows, you can restore the rows with the ROLLBACK statement. See "Rolling Back a Transaction".


See Also:

Oracle Database SQL Reference for information about the DELETE statement