ABAP - Keyword Documentation →  ABAP - Reference →  Processing External Data →  ABAP Database Accesses →  Open SQL →  Open SQL - Write Accesses → 

DELETE dbtab

Quick Reference

Syntax

DELETE { FROM target [ connection] [ WHERE sql_cond] [db_hints]
                                  [ORDER BY ... [OFFSET o]] [UP TO n ROWS]
}
     | { target [ connection] FROM source }.



Variants:

1. DELETE FROM target ...

2. DELETE target FROM source.

Effect

The Open SQL statement DELETE deletes one or more rows in the database table or classic view specified in target. The rows to delete can be specified as follows:

The addition connection can be used to specify a secondary database connection.

System Fields

The statement DELETE sets the values of the system fields sy-subrc and sy-dbcnt.

sy-subrc Meaning
0 In the variant DELETE FROM target, at least one row was deleted if a WHERE condition was specified and all or n rows were deleted if no condition was specified. In the variant DELETE target FROM, the specified row was deleted if a work area was specified in source and all specified rows were deleted if an internal table was specified in source or the internal table is empty.
4 In the variant DELETE FROM target, no row was deleted if a WHERE condition was specified or no row was deleted if no condition was specified, since the database table was already empty. In the variant DELETE target FROM, no row was deleted if a work area was specified in source or not all specified rows were deleted if an internal table was specified in source.

The statement DELETE sets sy-dbcnt to the number of deleted rows. If an overflow occurs because the number or rows is greater than 2,147,483,647, sy-dbcnt is set to -1.

Notes

Variant 1

DELETE FROM target ...


Effect

In the variant DELETE FROM target, either all rows are deleted or the rows in question are restricted using a WHERE condition or additions ORDER BY, OFFSET, and UP TO. In this variant, database notes can be specified with db_hints.

Variant 2

DELETE target FROM source.


Effect

In the variant DELETE target FROM, either a row specified by a work area is deleted or multiple rows specified by an internal table are deleted.



Continue
DELETE dbtab - target
DELETE dbtab - cond
DELETE dbtab - source