DELETE

The SQL DELETE Statement

DELETE removes existing records.

DELETE FROM table_name WHERE condition;

Note: If you omit WHERE, all records are deleted. The table itself (structure, columns, indexes) stays.

Delete Rows

Example

Delete products that are out of stock:

DELETE FROM Products
WHERE Stock = 0;

Running SELECT ProductID, ProductName, Stock FROM Products; afterwards shows:

Result: 5 rows

ProductIDProductNameStock
1Basmati Rice 5kg120
2Green Tea 100 bags300
3Olive Oil 1L80
5Espresso Beans 1kg45
6Almonds 500gNULL

Delete All Records

DELETE FROM Customers;

This removes every row but keeps the table. To remove the table completely, use DROP TABLE.

DELETE vs TRUNCATE vs DROP

DELETETRUNCATEDROP
TypeDMLDDLDDL
Removeschosen rows (WHERE)all rowsthe whole table
Table structure kept?yesyesno
Can roll back?yesdepends on databasedepends on database
Fires triggers?yesnono
Speed on big tablesslow (row by row, logged)fastfast
Resets identity/auto-increment?noyes (most databases)n/a