SQL DELETE Statement

The SQL DELETE statement is used to delete one or more rows from a table. The DELETE statement is used to remove unwanted data from a table and is a powerful tool for maintaining the integrity of a database.

Orders Table:

OrderIDCustomerID
110
220
330

To delete a row from the Orders table, we can use the following DELETE statement:

1DELETE FROM Orders 2WHERE OrderID = 2;

Orders Table after delete query:

OrderIDCustomerID
110
330

As we can see from the output, the DELETE statement deletes the row with OrderID = 2. The WHERE clause is used to specify which row(s) should be deleted. In this case, only the row with OrderID = 2 is deleted.

It's important to note that deleting data from a table is a permanent operation and the data cannot be recovered once it is deleted. Therefore, it's always a good idea to take a backup of the data before performing a DELETE operation.