Skip to content

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

INSERT dbtab

Short Reference

Other versions: 7.31 | 7.40 | 7.54


INSERT { {INTO target VALUES wa } 
       | {     target FROM   wa|{TABLE itab} } }.


The statement INSERT inserts one row specified in wa or multiple rows specified in itab in the database table or classic view specified in target. The two variants with INTO and VALUES or without INTO with FROM behave identically, with the exception that no internal tables can be specified after VALUES.

If VALUES is used, there must be an INTO between INSERT and target. If FROM is used, INTO must not be specified.

System Fields

sy-subrc Meaning
0 When a work area was declared in source, the specified row was changed.In the declaration of an internal table in source, all declared rows were inserted, or the internal table is empty.
2 When a LOB handle structure was specified with a component forwriter streams, the non-LOBhandle components were not yet written to the database, but instead are passed when the stream is closed, at the latest. Whether this situation occurs or not depends on the database. Refer toLOB handles.
4 When a work area was specified in source, the declared row was not inserted,or, when an internal table was specified in source, not all declared rows were inserted, since a row in the database table has the sameprimary key or a unique secondary index.

The INSERT statement sets sy-dbcnt to the number of rows inserted. If an overflow occurs because the number or rows is greater than 2,147,483,647, sy-dbcnt is set to -1. If sy-subrc is 2, sy-dbcnt is also set to the value -1 (for undefined).


  • The inserted rows are included permanently in the table in the next database commit. Up until this point, they can still be removed by a database rollback. The current isolation level defines whether the inserted data can be read into other database LUWs before or only after the database commit.
  • The statement INSERT sets a database lock until the next database commit or rollback. If used incorrectly, this can lead to a deadlock.
  • The number of rows that can be inserted in the tables of a database within a database LUW is limited, since a database system can only manage a limited amount of locks and data in the rollback area.
  • The statement INSERT cannot be applied to the system table TRDIR.


INSERT dbtab - target

INSERT dbtab - source