DELETE Statement

Removes records from a specified table.

 

Syntax

 

DELETE FROM table [WHERE ...]

 

The DELETE statement has these parts:

 

Part

Description

table

The name of the table from which records are deleted.

 

Remarks

 

The DELETE statement is especially useful when we want to delete many records. Unlike the UPDATE statement that can operate on queries, the DELETE statement can only delete records from tables.

 

To drop an entire table use the DROP TABLE statement. If we delete the table, however, the structure is lost. In contrast, when we use DELETE, only the data is deleted; the table structure and all of the table properties, such as column formatting and transfer rules, remain intact.

 

The DELETE statement deletes entire records, not just data in specific columns. If we want to delete values in a specific column, we use the UPDATE statement.

 

The DELETE statement is an action query and cannot be used from within the Manifold ODBC driver.

 

Important

 

After we remove records using a DELETE query, we can't undo the operation. If we want to know which records were deleted, first examine the results of a SELECT query that uses the same criteria, and then run the DELETE query.

 

Maintain backup copies of data at all times. If we delete the wrong records, we can retrieve them from our backup copies.

 

Example

 

Delete all records for employees whose title is Trainee:

 

DELETE FROM [Employees] WHERE [Title] = "Trainee";