The DELETE Operation
The DELETE
statement deletes one or more rows within a table. Like the INSERT
operations, DELETE
also works only on a single table at a time. A deletion operation should be performed very carefully because deletion is permanent. Many database tools require you to add a WHERE
clause to the DELETE FROM
statement. When performing these deletion operations, which require a WHERE
clause, and you would like to delete all the rows in a table, you could work around this by using a condition that is true for all the rows in the table.
For example, say you have an employee with empno
1234
who is no longer associated with the company. In such cases your query would look like the following:
DELETE FROM employees WHERE empno = 1234;
If you would like to remove the top 5 rows from the employees
table, we would use the following query:
DELETE FROM employees LIMIT 5;