The DELETE statement in SQL is used to remove data from a table. The basic syntax of the DELETE statement is:
DELETE FROM table_name WHERE condition;
The table_name is the name of the table from which you want to delete data. The
condition is an optional clause that specifies the rows that you want to delete. If you omit the
condition clause, all rows in the table will be deleted.
For example, the following statement will delete all rows from the customers table:
DELETE FROM customers;
The following statement will delete all rows from the customers table where the
country column is equal to "USA":
DELETE FROM customers WHERE country = 'USA';
You can also use the DELETE statement to delete multiple rows from a table by specifying a list of row IDs in the
condition clause. For example, the following statement will delete the rows with IDs 1, 2, and 3 from the
customers table:
DELETE FROM customers WHERE id IN (1, 2, 3);
The DELETE statement is a powerful tool that can be used to remove data from a table. It is important to use it carefully, as it can be irreversible.
Here are some additional things to keep in mind when using the DELETE statement:
The DELETE statement is a DML (Data Manipulation Language) statement. DML statements are not reversible, so it is important to make sure that you are deleting the correct data.
If you are deleting data from a table that is joined to other tables, you may need to use the
WHERE clause to specify the rows that you want to delete from each table.
The DELETE statement can be used to delete data from a view, but it cannot be used to delete data from a stored procedure.
Markdown for AI
A clean, structured version of this page for AI assistants and LLMs.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
The DELETE statement in SQL is used to remove data from a table. The basic syntax of the DELETE statement is:
The
table_nameis the name of the table from which you want to delete data. Theconditionis an optional clause that specifies the rows that you want to delete. If you omit theconditionclause, all rows in the table will be deleted.For example, the following statement will delete all rows from the
customerstable:The following statement will delete all rows from the
customerstable where thecountrycolumn is equal to "USA":You can also use the DELETE statement to delete multiple rows from a table by specifying a list of row IDs in the
conditionclause. For example, the following statement will delete the rows with IDs 1, 2, and 3 from thecustomerstable:The DELETE statement is a powerful tool that can be used to remove data from a table. It is important to use it carefully, as it can be irreversible.
Here are some additional things to keep in mind when using the DELETE statement:
WHEREclause to specify the rows that you want to delete from each table.