ABAP Keyword Documentation → ABAP - Reference → Processing Internal Data → Internal Tables → Internal Tables - Overview → Table Keys
Primary Table Key
Each internal table has a primary table key that enables access to individual rows in the table by means of a key specification.
- The components of the primary table key are declared using the
UNIQUE|NON-UNIQUE KEY
additions of the statementsTYPES
,DATA
, and so on.
- The standard key, which can be declared both explicitly and implicitly, has a special part to play here.
- The primary table key of a standard table can also be empty, meaning that it does not contain any key fields.
- In the case of key accesses for internal tables, the primary key is always used implicitly as long as no secondary key is specified.
- The primary key has the predefined name "primary_key", with which it can also be addressed explicitly in statements.
- Access to an internal table using the primary table key is determined by the table type and not the table key. For sorted tables and hashed tables, key access is always optimized using the primary table key. Primary key access to standard tables, however, uses a linear search.
- The key fields of the primary table key of sorted tables and hashed tables are always read-only.
- In the case of sorted tables and hashed tables, separate key administration exists for the primary table key, which enables optimized access but also affects the memory requirement of the internal table. There is no separate key administration for the primary table key of standard tables.
Other versions: 7.31 | 7.40 | 7.54
Notes
- Since sorted tables and hashed tables have real key administration for the primary key, unlike standard tables, these tables are also grouped under the term key tables.
- To achieve optimized key access to standard tables, secondary keys can be used.