SQL DELETE

Introduction

Syntax

DELETE Syntax

The DELETE statement deletes all the rows from the named table that satisfy the search condition. If no WHERE clause is specified, all tuples in the named table are deleted. (This is dangerous!)

        
DELETE FROM [ owner.]table-name
...    [WHERE search-condition]

        

Examples

DELETE All member Tuples
          
DELETE FROM member

        

Deletes all tuples from the member table. Whoops!

DELETE a Single member Tuple
          
DELETE FROM member
  WHERE memberId = 5

Deletes the tuple from the member table for member 5. Because of the ON DELETE CASCADE clauses in the pub table (see Table Creation Examples) the publications authored by member 5 and their publications are be deleted.

DELETE a Range of borrowed Tuples
          
DELETE FROM borrowed
  WHERE dateReturned < '1995-01-01'

        

Deletes all borrowing records where the book was returned before January 1st, 1995. (Cleaning out the old records).