What is Delete data
Just as the INSERT statement always adds whole rows to a table, the DELETE statement always removes entire rows.
Use DELETE to remove specific rows
DELETE operates on a set of rows, either defined by a condition in a WHERE clause or defined in a join. The WHERE clause in a DELETE statement has the same structure as a WHERE clause in a SELECT statement.
Note
It’s important to keep in mind that a DELETE without a corresponding WHERE clause will remove all the rows from a table. Use the DELETE statement with caution.
The following code shows the basic syntax of the DELETE statement:
SQLCopy
DELETE [FROM] <TableName>
WHERE <search_conditions>;
The following example uses the DELETE statement to remove all products from the specified table that have been discontinued. There’s a column in the table called discontinued and for products that are no longer available, the column has a value of 1.
SQLCopy
DELETE FROM Production.Product
WHERE discontinued = 1;