ABAP Keyword Documentation → ABAP − Reference → Processing External Data → ABAP Database Access → ABAP SQL
ABAP SQL - Database Hints
Other versions:
7.31 | 7.40 | 7.54
Syntax
... %_HINTS db @dbhint1
[db @dbhint2
... ] ...
Effect
The addition %_HINTS
can be used to specify database hints at the following positions in ABAP SQL statements:
- After the clauses of
SELECT
statements in main and subqueries.
One or more database hints can be specified after %_HINTS
as a blank-separated list in flat, character-like
literals or
host variables dbhint1
,
dbhint2
, and so on. The addition db
must be used
before each database hint to specify the database system for which the hint is intended. The following table shows the possible additions and the corresponding database system:
Addition | Database System |
---|---|
ADABAS |
SAP MaxDB |
AS400 |
IBM System i (AS/400) |
DB2 |
IBM DB2 |
DB6 |
IBM DB2 UDB |
HDB |
SAP HANA database |
MSSQLNT |
Microsoft SQL Server |
ORACLE |
Oracle DB |
SYBASE |
Sybase ASE |
A database system can be specified more than once if there are several database hints for this system. The possible database hints are database-specific and may depend on the release of the database system. They can be found in the documentation of the respective database system. An empty hint is ignored.
Any database hints specified are ignored if table buffering is used.
Notes
- A database hint usually only affects the part of an ABAP SQL statement for which is it specified. It does not usually affect the way a statement works, but may affect performance.
- Database hints should only be used with extreme caution. For example, they can be used as a last resort to influence the optimizer of the database system when selecting a secondary index.
- If database hints are used, they should generally be checked every time the database release or system configuration is changed.
- Database hints specified as literals are also not evaluated until runtime. If the syntax is incorrect, they can cause exceptions at runtime or are ignored. In the strict mode as of Release 7.51 only, statically known database hints are also checked statically.
- Database hints of the database interface are intended for internal use only. These are put between & characters and are evaluated before they are transferred to the database system from the database interface.
- In the strict modes of the syntax check
from Release 7.40, SP05, the escape character
@
must be before a hint that is not specified as a literal.
Example
Specifies a HANA-specific database hint for the SAP HANA database.
SELECT *
FROM scarr
WHERE carrid = 'LH'
%_HINTS HDB 'INDEX_SEARCH'
INTO TABLE @DATA(result).