Delete Statement in SQL
? DELETE Statement in SQL
The DELETE statement is used to remove one or more rows from a table based on a condition.
? Syntax
DELETE FROM table_nameWHERE condition;The
WHEREclause specifies which rows to delete.If you omit the
WHEREclause, all rows in the table will be deleted.
? Examples
1. Delete specific rows
Delete employees with age less than 25:
DELETE FROM employeesWHERE age < 25;2. Delete a single row by ID
DELETE FROM employeesWHERE id = 101;3. Delete all rows (use with caution!)
DELETE FROM employees;? Notes
DELETEremoves rows but keeps the table structure intact.Use transactions (
BEGIN,COMMIT,ROLLBACK) to safely delete rows.For faster deletion of all rows, consider
TRUNCATE TABLE.
If you want, I can provide details on DELETE with joins, cascading deletes, or examples in different SQL dialects!