TL;DR – SQL DELETE is an irreversible command which deletes data records from a table. To select specific records to delete, use the WHERE clause.
Contents
The syntax for SQL DELETE
Example
DELETE FROM mytable_name
WHERE condition;
Examples using a demo database
The Developers table
ID | Name | City | Country |
---|---|---|---|
1 | Tom Kurkutis | New York | USA |
2 | Ana Fernandez | London | UK |
3 | Antonio Indigo | Paris | France |
4 | Aarav Kaelin | Delhi | India |
5 | Andrew Tumota | Miami | USA |
6 | Basma Zlata | Miami | USA |
Deleting a single record
Example
DELETE FROM Developers
WHERE Name='Antonio Indigo';
The result
ID | Name | City | Country |
---|---|---|---|
1 | Tom Kurkutis | New York | USA |
2 | Ana Fernandez | London | UK |
3 | Aarav Kaelin | Delhi | India |
4 | Andrew Tumota | Miami | USA |
5 | Basma Zlata | Miami | USA |
Deleting all the data but keeping the table
Example
DELETE * FROM Developers;