SQL Basics | DML: Data Manipulation Language | DELETE
You can delete some data directly from a database. Use DELETE to delete data.
DELETE syntax
DELETE FROM "table_name"
WHERE "condition";
DELETE example
Consider the following example table.
store_information table
| store_name | sales | txn_date |
|---|---|---|
| Los Angeles | 1500 | Jan-05-2018 |
| San Diego | 250 | Jan-07-2018 |
| Los Angeles | 300 | Jan-08-2018 |
| Boston | 700 | Jan-08-2018 |
To delete all data for Los Angeles, use the following SQL statement.
DELETE FROM store_information
WHERE store_name = 'Los Angeles';
After running this SQL, the table becomes as follows.
| store_name | sales | txn_date |
|---|---|---|
| San Diego | 250 | Jan-07-2018 |
| Boston | 700 | Jan-08-2018 |