DELETE statement
496
DELETE statement
Use this statement to delete rows from the database.
DELETE [ FIRST | TOP
n
]
… [FROM] [
owner
.]
table-name
… [FROM
table-list
]
… [WHERE
search-condition
]
Must have DELETE permission on the table.
None.
"TRUNCATE TABLE statement" on page 631
"INSERT statement" on page 554
"INPUT statement" on page 550
"FROM clause" on page 532
The DELETE statement deletes all the rows from the named table that satisfy
the search condition. If no WHERE clause is specified, all rows from the
named table are deleted.
The DELETE statement can be used on views, provided the SELECT
statement defining the view has only one table in the FROM clause and does
not contain a GROUP BY clause, an aggregate function, or involve a
UNION operation.
The optional second FROM clause in the DELETE statement allows rows to
be deleted based on joins. If the second FROM clause is present, the
WHERE clause qualifies the rows of this second FROM clause. Rows are
deleted from the table name given in the first FROM clause.
$ The second FROM clause can contain arbitrary complex table
expressions, such as KEY and NATURAL joins. For a full description of the
FROM clause and joins, see "FROM clause" on page 532.
The following statement illustrates a potential ambiguity in table names in
DELETE statements with two FROM clauses that use correlation names:
DELETE
FROM table_1
FROM table_1 AS alias_1, table_2 AS alias_2
WHERE ...
The table
table_1
is identified without a correlation name in the first FROM
clause, but with a correlation name in the second FROM clause. In this case,
table_1
in the first clause is identified with
alias_1
in the second clause—
there is only one instance of
table_1
in this statement.
Function
Syntax
Permissions
Side effects
See also
Description