APPX Software Library

Chapter 5: SQL Statements

5.6 DELETE

Description

Deletes zero, one or more rows from the specified table that satisfy the search condition specified in the WHERE clause. If the optional WHERE clause is not specified, then the DELETE statement deletes all rows of the specified table.

Syntax

DELETE FROM [owner_name.] { table_name | view_name }
          [ WHERE search_condition ];

Notes

  • The FROM clause of a subselect statement in the search condition, if any, can refer only to the table being deleted.
  • If the table has primary/candidate keys, and if there exists references from other tables to the rows to be deleted, the statement is rejected.

Example

DELETE FROM customer
               WHERE customer_name = 'RALPH' ;

Authorization

The user executing this statement must have any of the following privileges:

  • DBA privilege.
  • Ownership of the table.
  • DELETE permission on the table.

If the target is a view, then the DELETE privilege is required on the target base table referred to in the view definition.

SQL Compliance

SQL-92, ODBC Extended SQL grammar

Environment

Embedded SQL, interactive SQL, ODBC applications

Search Conditions