Delete

The SQL DELETE statement is used to delete records from a database table. It allows you to remove one or more rows from a table that match a specific condition.

Syntax

The basic syntax of the DELETE statement is as follows:

DELETE FROM table_name 
WHERE condition;

Here, table_name refers to the name of the table from which you want to delete records. The WHERE clause is optional and is used to specify a condition that must be met in order for the rows to be deleted. If you omit the WHERE clause, all rows in the table will be deleted.

Example

For example, if you have a table called customers and you want to delete all records for customers with a certain last name, you can use the following SQL statement:

DELETE FROM customers 
WHERE last_name = 'Smith';

This statement will delete all records from the customers table where the last_name column contains the value ‘Smith’.

It is important to note that the DELETE statement is a powerful tool and should be used with caution. Always make sure that you have a backup of your data before deleting any records from a table. Additionally, be sure to double-check your WHERE clause to ensure that you are only deleting the records that you intend to delete.