DELETE

Name

DELETE  --  Removes rows from a table.

Synopsis

DELETE FROM [ONLY] table [ WHERE condition ]
  

Parameters

table

Use this parameter to provide the name of the table you are deleting rows from.

condition

Use this parameter to specify the condition rows are checked for before they are qualified to be deleted. Essentially the is is a SELECT query; refer to SELECT for more information on how to construct this query.

Results

DELETE count

This message is displayed if deletion of qualifying rows is successful. This also displays the number of rows that were deleted. If the number is 0, no rows qualified for deletion.

Description

Use DELETE to remove rows from a table. Only rows that qualify a condition supplied with the WHERE clause will be deleted. To delete all rows from a table, do not specify a WHERE clause. This does not delete the table, it merely empties it.

NoteThe TRUNCATE Command
 

Use TRUNCATE to empty a table more effectively.

Use the ONLY clause to indicate you do not wish to remove qualifying rows from the specified table's sub-tables.

Examples

The following example removes all shipped orders that were both placed by the customer ID 21 and shipped before March 30th, 2001:

  DELETE FROM shipped_orders 
      WHERE cust_id = 21
        AND ship_date < '3/30/2001';