Requete SQL delete row from table where

Sql: How to Delete Obsolete SQL Data - 2021

Over time, data can become obsolete and lose its usefulness. You may want to remove this stale data from the SQL table. Unneeded data in a table slows performance, consumes memory, and can confuse users. You may want to transfer older data to an archive table and then switch the archive offline. In the unlikely event that you ever need this data again, you can restore it.

In the meantime, the daily processing will not be slowed down. Whether or not you choose to archive stale data, you will eventually get to the point where you want to delete that data. SQL allows rows to be removed from database tables using the DELETE statement.

You can delete all rows in a table with an unqualified DELETE statement, or you can limit the deletion to only selected rows by adding a WHERE clause. The syntax is similar to that of a SELECT statement, except that you do not specify any columns. When you want to delete a table row, you probably want to remove all of the data in that row's columns.

Suppose your customer David Taylor has just moved to Switzerland and is no longer buying from you. You can remove it from your CUSTOMER table with the following statement:

DELETE FROM CUSTOMER WHERE first name = 'David' AND last name = 'Taylor';

Suppose you only have one customer named David Taylor. The intended deletion is performed in this statement. If you have two or more customers who share the name David Taylor, you can add additional conditions to the WHERE clause to ensure that you only delete the customer that you want to remove. If you don't add a WHERE clause, all customers named David Taylor will be deleted.