DELETE Statement
The DELETE statement removes one or more rows from a table based on a specified condition, while keeping the table's structure intact for future use.
Basic Syntax
DELETE FROM customers
WHERE customer_id = 1;
Deleting All Rows
Omitting the WHERE clause deletes every row in the table, though the table itself still exists afterward:
DELETE FROM customers;
DELETE vs TRUNCATE
DELETE removes rows one at a time and can be filtered with a WHERE clause, while TRUNCATE removes all rows at once and is generally faster, but cannot be filtered.
Just like UPDATE, always verify the WHERE condition with a SELECT first - an unintended DELETE without a WHERE clause can wipe out an entire table's data.