Logo Passei Direto
Buscar
Material
páginas com resultados encontrados.
páginas com resultados encontrados.

Escolha uma das opções e acesse esse e outros materiais sem bloqueio. 🤩

Cadastre-se ou realize login

Ao continuar, você aceita os Termos de Uso e Política de Privacidade

Escolha uma das opções e acesse esse e outros materiais sem bloqueio. 🤩

Cadastre-se ou realize login

Ao continuar, você aceita os Termos de Uso e Política de Privacidade

Escolha uma das opções e acesse esse e outros materiais sem bloqueio. 🤩

Cadastre-se ou realize login

Ao continuar, você aceita os Termos de Uso e Política de Privacidade

Escolha uma das opções e acesse esse e outros materiais sem bloqueio. 🤩

Cadastre-se ou realize login

Ao continuar, você aceita os Termos de Uso e Política de Privacidade

Escolha uma das opções e acesse esse e outros materiais sem bloqueio. 🤩

Cadastre-se ou realize login

Ao continuar, você aceita os Termos de Uso e Política de Privacidade

Escolha uma das opções e acesse esse e outros materiais sem bloqueio. 🤩

Cadastre-se ou realize login

Ao continuar, você aceita os Termos de Uso e Política de Privacidade

Escolha uma das opções e acesse esse e outros materiais sem bloqueio. 🤩

Cadastre-se ou realize login

Ao continuar, você aceita os Termos de Uso e Política de Privacidade

Escolha uma das opções e acesse esse e outros materiais sem bloqueio. 🤩

Cadastre-se ou realize login

Ao continuar, você aceita os Termos de Uso e Política de Privacidade

Escolha uma das opções e acesse esse e outros materiais sem bloqueio. 🤩

Cadastre-se ou realize login

Ao continuar, você aceita os Termos de Uso e Política de Privacidade

Escolha uma das opções e acesse esse e outros materiais sem bloqueio. 🤩

Cadastre-se ou realize login

Ao continuar, você aceita os Termos de Uso e Política de Privacidade

Prévia do material em texto

PUBLIC
SAP HANA Platform 2.0 SPS 00
Document Version: 1.0 – 2016-11-30
SAP HANA SQL and System Views Reference
Content
1 Introduction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
2 SQL Reference. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
2.1 Notation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .21
2.2 Introduction to SQL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
2.3 Data Types. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
2.4 Reserved Words. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
2.5 Operators. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
2.6 Expressions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
2.7 Predicates. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
Comparison Predicates. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
BETWEEN Predicate. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
EXISTS Predicate. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
IN Predicate. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
LIKE Predicate. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
NULL Predicate. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
CONTAINS Predicate. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .58
2.8 SQL Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
Alphabetical List Of Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .62
Aggregate Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274
Data Type Conversion Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274
Datetime Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275
Fulltext Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 276
Hierarchy Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 277
Miscellaneous Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278
Numeric Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279
Series Data Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 280
String Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .281
Security Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .282
Window Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 282
2.9 SQL Statements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .304
Data Definition Statements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 304
Data Manipulation Statements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 433
Procedural Statements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 475
Transaction Management Statements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 515
Session Management Statements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 522
Access Control Statements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 530
2 P U B L I C
SAP HANA SQL and System Views Reference
Content
Data Import Export Statements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 608
System Management Statements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 624
Workload Management Statements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 686
Tenant Database Management Statements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 694
Backup and Recovery Statements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 700
2.10 System Limitations. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 719
2.11 SQL Error Codes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .722
3 SQL Reference for SAP HANA Options. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 776
3.1 Accelerator for SAP ASE. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 777
ALTER DATABASE Statement [Accelerator for SAP ASE]. . . . . . . . . . . . . . . . . . . . . . . . . . . . 777
ALTER SYSTEM ALTER CONFIGURATION Statement [Accelerator for SAP ASE] . . . . . . . . . . . 778
ALTER SYSTEM INITIALIZE SERVICE Statement [Accelerator for SAP ASE]. . . . . . . . . . . . . . . 780
ALTER SYSTEM UNINITIALIZE SERVICE Statement [Accelerator for SAP ASE]. . . . . . . . . . . . .782
3.2 Dynamic Tiering. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 783
ALTER AUDIT POLICY Statement [Dynamic Tiering]. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 785
ALTER DATABASE Statement [Dynamic Tiering]. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 788
ALTER EXTENDED STORAGE Statement [Dynamic Tiering]. . . . . . . . . . . . . . . . . . . . . . . . . . 789
ALTER STATISTICS Statement (Extended Store Table) [Dynamic Tiering]. . . . . . . . . . . . . . . . 793
ALTER STATISTICS Statement (Multistore Table) [Dynamic Tiering]. . . . . . . . . . . . . . . . . . . . 798
ALTER SYSTEM ALTER CONFIGURATION Statement [Dynamic Tiering]. . . . . . . . . . . . . . . . . 804
ALTER SYSTEM RECONFIGURE SERVICE Statement [Dynamic Tiering]. . . . . . . . . . . . . . . . . 809
ALTER TABLE Statement (Extended Store Table) [Dynamic Tiering]. . . . . . . . . . . . . . . . . . . . 810
ALTER TABLE Statement (Multistore Table) [Dynamic Tiering]. . . . . . . . . . . . . . . . . . . . . . . . 815
CALL CHECK_CATALOG Statement (Multistore Table) [Dynamic Tiering]. . . . . . . . . . . . . . . . 827
CALL CHECK_ES Statement (Extended Store Table) [Dynamic Tiering]. . . . . . . . . . . . . . . . . . 829
CALL CHECK_TABLE_CONSISTENCY Statement (Multistore Table) [Dynamic Tiering]. . . . . . . 833
CREATE AUDIT POLICY Statement [Dynamic Tiering].. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 835
CREATE EXTENDED STORAGE Statements [Dynamic Tiering]. . . . . . . . . . . . . . . . . . . . . . . . 840
CREATE INDEX Statement [Dynamic Tiering]. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .841
CREATE STATISTICS Statement (Extended Store Table) [Dynamic Tiering]. . . . . . . . . . . . . . . 844
CREATE STATISTICS Statement (Multistore Table) [Dynamic Tiering]. . . . . . . . . . . . . . . . . . .848
CREATE TABLE Statement (Extended Store Table) [Dynamic Tiering]. . . . . . . . . . . . . . . . . . . 854
CREATE TABLE Statement (Multistore Table) [Dynamic Tiering]. . . . . . . . . . . . . . . . . . . . . . . 859
DROP EXTENDED STORAGE [Dynamic Tiering]. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 869
DROP STATISTICS Statement (Extended Store Table) [Dynamic Tiering]. . . . . . . . . . . . . . . . . 871
DROP STATISTICS Statement (Multistore Table) [Dynamic Tiering]. . . . . . . . . . . . . . . . . . . . 874
EXPORT Statement (Extended Store Table) [Dynamic Tiering]. . . . . . . . . . . . . . . . . . . . . . . . 876
EXPORT Statement (Multistore Table) [Dynamic Tiering]. . . . . . . . . . . . . . . . . . . . . . . . . . . . 880
GRANT EXTENDED STORAGE ADMIN System Privilege Statement [Dynamic Tiering]. . . . . . . . 883
IMPORT Statement (Extended Store Table) [Dynamic Tiering]. . . . . . . . . . . . . . . . . . . . . . . . 885
IMPORT Statement (Multistore Table) [Dynamic Tiering]. . . . . . . . . . . . . . . . . . . . . . . . . . . . 889
SAP HANA SQL and System Views Reference
Content P U B L I C 3
IMPORT FROM Statement (Extended Store Table) [Dynamic Tiering]. . . . . . . . . . . . . . . . . . . 893
IMPORT FROM Statement (Multistore Table) [Dynamic Tiering]. . . . . . . . . . . . . . . . . . . . . . . 899
INSERT Statement (Extended Store Table) [Dynamic Tiering]. . . . . . . . . . . . . . . . . . . . . . . . .904
INSERT Statement (Multistore Table) [Dynamic Tiering]. . . . . . . . . . . . . . . . . . . . . . . . . . . . 906
MERGE DELTA Statement [Dynamic Tiering]. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .909
REFRESH STATISTICS Statement (Extended Store Table) [Dynamic Tiering]. . . . . . . . . . . . . . 911
REFRESH STATISTICS Statement (Multistore Table) [Dynamic Tiering]. . . . . . . . . . . . . . . . . . 915
UPDATE Statement (Extended Store Table) [Dynamic Tiering]. . . . . . . . . . . . . . . . . . . . . . . . 918
UPDATE Statement (Multistore Table) [Dynamic Tiering]. . . . . . . . . . . . . . . . . . . . . . . . . . . . 921
Additional Syntax [Dynamic Tiering]. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 924
3.3 Remote Data Sync. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 925
ALTER DATABASE Statement (Remote Data Sync). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 925
ALTER SYSTEM INITIALIZE SERVICE Statement (Remote Data Sync). . . . . . . . . . . . . . . . . . . 926
ALTER SYSTEM UNINITIALIZE SERVICE Statement (Remote Data Sync). . . . . . . . . . . . . . . . . 928
3.4 Smart Data Integration. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 929
ALTER ADAPTER Statement [Smart Data Integration]. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 931
ALTER AGENT Statement [Smart Data Integration]. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 933
ALTER REMOTE SOURCE Statement [Smart Data Integration]. . . . . . . . . . . . . . . . . . . . . . . . 934
ALTER REMOTE SUBSCRIPTION Statement [Smart Data Integration]. . . . . . . . . . . . . . . . . . . 938
CANCEL TASK Statement [Smart Data Integration]. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 939
CREATE ADAPTER Statement [Smart Data Integration]. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 941
CREATE AGENT Statement [Smart Data Integration]. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 942
CREATE AGENT GROUP Statement [Smart Data Integration]. . . . . . . . . . . . . . . . . . . . . . . . . 944
CREATE AUDIT POLICY Statement [Smart Data Integration]. . . . . . . . . . . . . . . . . . . . . . . . . .945
CREATE REMOTE SOURCE Statement [Smart Data Integration]. . . . . . . . . . . . . . . . . . . . . . . 947
CREATE REMOTE SUBSCRIPTION Statement [Smart Data Integration]. . . . . . . . . . . . . . . . . .948
CREATE VIRTUAL PROCEDURE [Smart Data Integration]. . . . . . . . . . . . . . . . . . . . . . . . . . . . 953
DROP ADAPTER Statement [Smart Data Integration]. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 955
DROP AGENT Statement [Smart Data Integration]. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 956
DROP AGENT GROUP Statement [Smart Data Integration]. . . . . . . . . . . . . . . . . . . . . . . . . . . 957
DROP REMOTE SUBSCRIPTION Statement [Smart Data Integration]. . . . . . . . . . . . . . . . . . . 958
GRANT Statement [Smart Data Integration]. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 959
PROCESS REMOTE SUBSCRIPTION EXCEPTION Statement [Smart Data Integration]. . . . . . . 961
SESSION_CONTEXT Statement [Smart Data Integration]. . . . . . . . . . . . . . . . . . . . . . . . . . . . 962
START TASK Statement [Smart Data Integration]. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 963
3.5 Smart Data Streaming. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 966
ALTER DATABASE Statement [Smart Data Streaming]. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 966
ALTER SYSTEM INITIALIZE SERVICE Statement [Smart Data Streaming]. . . . . . . . . . . . . . . . 967
ALTER SYSTEM UNINITIALIZE SERVICE Statement [Smart Data Streaming]. . . . . . . . . . . . . . 968
3.6 Advanced Data Processing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 969
Advanced Data Processing: TM_CATEGORIZE_KNN. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .970
4 P U B L I C
SAP HANA SQL and System Views Reference
Content
Advanced Data Processing: TM_GET_RELATED_DOCUMENTS. . . . . . . . . . . . . . . . . . . . . . . . 974
Advanced Data Processing: TM_GET_RELATED_TERMS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 977
Advanced Data Processing: TM_GET_RELEVANT_DOCUMENTS . . . . . . . . . . . . . . . . . . . . . . . 981
Advanced Data Processing: TM_GET_RELEVANT_TERMS. . . . . . . . . . . . . . . . . . . . . . . . . . . 984
Advanced Data Processing: TM_GET_SUGGESTED_TERMS. . . . . . . . . . . . . . . . . . . . . . . . . . 987
4 System Views Reference. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 990
4.1 ACCESSIBLE_VIEWS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1010
4.2 AFL_AREAS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1011
4.3 AFL_FUNCTIONS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1011
4.4 AFL_FUNCTION_PARAMETERS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1012
4.5 AFL_FUNCTION_PROPERTIES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1013
4.6 AFL_PACKAGES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1014
4.7 AFL_TEXTS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1014
4.8 APPLICATION_ENCRYPTION_KEYS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1015
4.9 ASSOCIATIONS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . 1015
4.10 AUDIT_ACTIONS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1016
4.11 AUDIT_LOG System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1017
4.12 AUDIT_POLICIES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1019
4.13 AUTHORIZATION_GRAPH System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1020
4.14 AUTHORIZATION_TYPES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1022
4.15 BIMC_CUBES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1022
4.16 BIMC_DIMENSION_VIEW System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1023
4.17 BIMC_MEASURES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1027
4.18 BIMC_VARIABLE_VIEW System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1030
4.19 CDS_ANNOTATION_VALUES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1030
4.20 CDS_ARTIFACT_NAMES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1031
4.21 CDS_ASSOCIATIONS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1032
4.22 CDS_ENTITIES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1033
4.23 CDS_VIEWS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1033
4.24 CERTIFICATES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1034
4.25 CONSTRAINTS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1035
4.26 CREDENTIALS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1036
4.27 CS_ALL_COLUMNS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1037
4.28 CS_BO_VIEWS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1038
4.29 CS_FREESTYLE_COLUMNS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1038
4.30 CS_JOIN_CONDITIONS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1039
4.31 CS_JOIN_CONSTRAINTS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1040
4.32 CS_JOIN_PATHS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1040
4.33 CS_JOIN_TABLES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1041
4.34 CS_KEY_FIGURES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1042
4.35 CS_VIEW_COLUMNS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1043
SAP HANA SQL and System Views Reference
Content P U B L I C 5
4.36 CS_VIEW_PARAMETERS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1044
4.37 DATA_STATISTICS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1045
4.38 DATA_TYPES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1048
4.39 EFFECTIVE_APPLICATION_PRIVILEGES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1051
4.40 EFFECTIVE_PRIVILEGE_GRANTEES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1052
4.41 EFFECTIVE_PRIVILEGES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1053
4.42 EFFECTIVE_ROLES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1054
4.43 EFFECTIVE_ROLE_GRANTEES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1054
4.44 EFFECTIVE_STRUCTURED_PRIVILEGES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1055
4.45 ELEMENT_TYPES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1057
4.46 ENCRYPTION_ROOT_KEYS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1058
4.47 EPM_MODELS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1059
4.48 EPM_QUERY_SOURCES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1059
4.49 EXPLAIN_PLAN_TABLE System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1060
4.50 FLEXIBLE_TABLES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1063
4.51 FULL_SYSTEM_INFO_DUMPS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1064
4.52 FULLTEXT_INDEXES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1065
4.53 FUNCTIONS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1067
4.54 FUNCTION_PARAMETER_COLUMNS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1068
4.55 FUNCTION_PARAMETERS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1069
4.56 GEOCODE_INDEXES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1070
4.57 GRANTED_PRIVILEGES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1071
4.58 GRANTED_ROLES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1072
4.59 GRAPH_WORKSPACES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1072
4.60 HINTS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1073
HINT Details. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1074
4.61 INDEXES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1096
4.62 INDEX_COLUMNS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1097
4.63 INVALID_CONNECT_ATTEMPTS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1098
4.64 LCM_PRODUCTS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1098
4.65 LCM_PRODUCT_INSTANCES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1099
4.66 LCM_PRODUCT_INSTANCES_INCLUDED System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1100
4.67 LCM_SOFTWARE_COMPONENTS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1100
4.68 LCM_SWID System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1101
4.69 LDAP_PROVIDER_URLS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1102
4.70 LDAP_PROVIDERS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . .1103
4.71 LDAP_USERS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1104
4.72 LIBRARIES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1105
4.73 M_ACTIVE_PROCEDURES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1105
4.74 M_ACTIVE_STATEMENTS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1107
4.75 M_AFL_FUNCTIONS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1110
6 P U B L I C
SAP HANA SQL and System Views Reference
Content
4.76 M_AFL_STATES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1110
4.77 M_ATTACHED_STORAGES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1111
4.78 M_BACKUP_CATALOG System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1111
4.79 M_BACKUP_CATALOG_FILES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1113
4.80 M_BACKUP_CONFIGURATION System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1114
4.81 M_BACKUP_PROGRESS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1115
4.82 M_BACKUP_SIZE_ESTIMATIONS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1116
4.83 M_BLOCKED_TRANSACTIONS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1117
4.84 M_CACHES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1118
4.85 M_CACHES_RESET System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1119
4.86 M_CACHE_ENTRIES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1119
4.87 M_CATALOG_MEMORY System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1120
4.88 M_CE_CALCSCENARIOS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1121
4.89 M_CE_CALCSCENARIOS_OVERVIEW System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1122
4.90 M_CE_CALCVIEW_DEPENDENCIES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1123
4.91 M_CE_DEBUG_INFOS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1123
4.92 M_CE_DEBUG_JSONS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1124
4.93 M_CE_DEBUG_NODE_MAPPING System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1125
4.94 M_CE_PLE_CALCSCENARIOS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1126
4.95 M_CLIENT_VERSIONS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1126
4.96 M_COMPACTION_THREAD System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1127
4.97 M_CONDITIONAL_VARIABLES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1129
4.98 M_CONDITIONAL_VARIABLES_RESET System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1131
4.99 M_CONNECTIONS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1131
4.100 M_CONNECTION_STATISTICS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1135
4.101 M_CONTAINER_DIRECTORY System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1140
4.102 M_CONTAINER_NAME_DIRECTORY System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1141
4.103 M_CONTEXT_MEMORY System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1142
4.104 M_CONTEXT_MEMORY_RESET System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1144
4.105 M_CONVERTER_STATISTICS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1145
4.106 M_CONVERTER_STATISTICS_RESET System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1147
4.107 M_CS_ALL_COLUMNS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1147
4.108 M_CS_COLUMNS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1150
4.109 M_CS_INDEXES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1152
4.110 M_CS_LOADS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1153
4.111 M_CS_LOB_SPACE_RECLAIMS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1154
4.112 M_CS_MVCC System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1155
4.113 M_CS_PARTITIONS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1156
4.114 M_CS_TABLES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1157
4.115 M_CS_UNLOADS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1161
4.116 M_CUSTOMIZABLE_FUNCTIONALITIES System View . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1162
SAP HANA SQL and System Views Reference
Content P U B L I C 7
4.117 M_DATABASE System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1162
4.118 M_DATABASES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1163
4.119 M_DATABASE_HISTORY System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1164
4.120 M_DATABASE_REPLICAS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1164
4.121 M_DATABASE_REPLICA_STATISTICS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1165
4.122 M_DATA_VOLUMES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1166
4.123 M_DATA_VOLUME_PAGE_STATISTICS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1167
4.124 M_DATA_VOLUME_PAGE_STATISTICS_RESET System View. . . . . . . . . . . . . . . . . . . . . . . . . . . 1168
4.125 M_DATA_VOLUME_SUPERBLOCK_STATISTICS System View. . . . . . . . . . . . . . . . . . . . . . . . . . 1169
4.126 M_DEBUG_CONNECTIONS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1170
4.127 M_DEBUG_SESSIONS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1170
4.128 M_DELTA_MERGE_STATISTICS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1171
4.129 M_DISKS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1174
4.130 M_DISK_USAGE System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1175
4.131 M_DYNAMIC_RESULT_CACHE System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1175
4.132 M_DYNAMIC_RESULT_CACHE_EXCLUSIONS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . 1177
4.133 M_EFFECTIVE_TABLE_PLACEMENT System View. . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . . . . 1178
4.134 M_ENCRYPTION_OVERVIEW System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1179
4.135 M_EPM_SESSIONS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1179
4.136 M_ERROR_CODES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1180
4.137 M_EVENTS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1180
4.138 M_EXECUTED_STATEMENTS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1181
4.139 M_EXPENSIVE_STATEMENTS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1184
4.140 M_EXPORT_BINARY_STATUS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1188
4.141 M_EXTRACTORS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1189
4.142 M_FEATURE_USAGE System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1189
4.143 M_FEATURES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1191
4.144 M_FULLTEXT_QUEUES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1191
4.145 M_FUZZY_SEARCH_INDEXES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1192
4.146 M_GARBAGE_COLLECTION_STATISTICS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1193
4.147 M_GARBAGE_COLLECTION_STATISTICS_RESET System View. . . . . . . . . . . . . . . . . . . . . . . . . 1196
4.148 M_HA_DR_PROVIDERS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1196
4.149 M_HEAP_MEMORY System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1196
4.150 M_HEAP_MEMORY_RESET System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1199
4.151 M_HISTORY_INDEX_LAST_COMMIT_ID System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1200
4.152 M_HOST_INFORMATION System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1200
4.153 M_HOST_NETWORK_STATISTICS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1202
4.154 M_HOST_RESOURCE_UTILIZATION System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1203
4.155 M_IMPORT_BINARY_STATUS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1204
4.156 M_INDEXING_QUEUES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1205
4.157 M_INIFILES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1206
8 P U B L I C
SAP HANA SQL and System Views Reference
Content
4.158 M_INIFILE_CONTENTS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1207
4.159 M_JOBEXECUTORS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1207
4.160 M_JOBEXECUTORS_RESET System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1209
4.161 M_JOB_PROGRESS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1209
4.162 M_JOB_HISTORY_INFO System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1212
4.163 M_JOIN_DATA_STATISTICS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1212
4.164 M_JOIN_TRANSLATION_TABLES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1214
4.165 M_KERNEL_PROFILER System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1215
4.166 M_LANDSCAPE_HOST_CONFIGURATION System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1216
4.167 M_LICENSE System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1220
4.168 M_LICENSES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1221
4.169 M_LICENSE_MEASUREMENTS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1223
4.170 M_LICENSE_USAGE_HISTORY System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1223
4.171 M_LIVECACHE_CONTAINER_STATISTICS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1224
4.172 M_LIVECACHE_CONTAINER_STATISTICS_RESET System View. . . . . . . . . . . . . . . . . . . . . . . . . 1225
4.173 M_LIVECACHE_LOCKS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1225
4.174 M_LIVECACHE_LOCK_STATISTICS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1227
4.175 M_LIVECACHE_LOCK_STATISTICS_RESET System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1228
4.176 M_LIVECACHE_OMS_VERSIONS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1228
4.177 M_LIVECACHE_PROCEDURE_STATISTICS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1229
4.178 M_LIVECACHE_PROCEDURE_STATISTICS_RESET System View. . . . . . . . . . . . . . . . . . . . . . . . 1237
4.179 M_LIVECACHE_SCHEMA_STATISTICS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1238
4.180 M_LIVECACHE_SCHEMA_STATISTICS_RESET System View. . . . . . . . . . . . . . . . . . . . . . . . . . . 1238
4.181 M_LOAD_HISTORY_HOST System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1239
4.182 M_LOAD_HISTORY_INFO System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1240
4.183 M_LOAD_HISTORY_SERVICE System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1241
4.184 M_LOCK_WAITS_STATISTICS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1244
4.185 M_LOG_BUFFERS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1244
4.186 M_LOG_BUFFERS_RESET System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1246
4.187 M_LOG_PARTITIONS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1246
4.188 M_LOG_PARTITIONS_RESET System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1250
4.189 M_LOG_SEGMENTS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1250
4.190 M_LOG_SEGMENTS_RESET System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1252
4.191 M_MEMORY_OBJECTS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1253
4.192 M_MEMORY_OBJECTS_RESET System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1255
4.193 M_MEMORY_OBJECT_DISPOSITIONS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1255
4.194 M_MEMORY_RECLAIM_STATISTICS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1257
4.195 M_MEMORY_RECLAIM_STATISTICS_RESET System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . .1260
4.196 M_MERGED_TRACES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1260
4.197 M_MONITORS System View. . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . . . . . 1262
4.198 M_MONITOR_COLUMNS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1262
SAP HANA SQL and System Views Reference
Content P U B L I C 9
4.199 M_MUTEXES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1263
4.200 M_MUTEXES_RESET System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1265
4.201 M_MVCC_OVERVIEW System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1265
4.202 M_MVCC_TABLES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1267
4.203 M_OBJECT_LOCKS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1267
4.204 M_OBJECT_LOCK_STATISTICS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1268
4.205 M_OBJECT_LOCK_STATISTICS_RESET System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1269
4.206 M_OUT_OF_MEMORY_EVENTS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1269
4.207 M_PAGEACCESS_STATISTICS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1270
4.208 M_PAGEACCESS_STATISTICS_RESET System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1271
4.209 M_PASSWORD_POLICY System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1272
4.210 M_PERFTRACE System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1273
4.211 M_PERSISTENCE_ENCRYPTION_KEYS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1274
4.212 M_PERSISTENCE_ENCRYPTION_STATUS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1275
4.213 M_PERSISTENCE_MANAGERS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1276
4.214 M_PERSISTENCE_MANAGERS_RESET System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1278
4.215 M_PLUGIN_MANIFESTS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1279
4.216 M_PLUGIN_STATUS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1279
4.217 M_PREPARED_STATEMENTS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1280
4.218 M_READWRITELOCKS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1283
4.219 M_READWRITELOCKS_RESET System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1286
4.220 M_RECORD_LOCKS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1286
4.221 M_REMOTE_CONNECTIONS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1287
4.222 M_REMOTE_STATEMENTS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1288
4.223 M_REORG_ALGORITHMS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1289
4.224 M_REPO_TRANSPORT_FILES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1289
4.225 M_RESULT_CACHE System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1290
4.226 M_RESULT_CACHE_RESET System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1291
4.227 M_RESULT_CACHE_EXCLUSIONS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1292
4.228 M_RS_INDEXES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1293
4.229 M_RS_MEMORY System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1295
4.230 M_RS_TABLES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1296
4.231 M_RS_TABLE_VERSION_STATISTICS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1297
4.232 M_SAVEPOINTS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1299
4.233 M_SAVEPOINT_STATISTICS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1302
4.234 M_SAVEPOINT_STATISTICS_RESET System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1305
4.235 M_SEMAPHORES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1305
4.236 M_SEMAPHORES_RESET System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1307
4.237 M_SEQUENCES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1307
4.238 M_SERIES_TABLES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1308
4.239 M_SERVICES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1309
10 P U B L I C
SAP HANA SQL and System Views Reference
Content
4.240 M_SERVICE_COMPONENT_MEMORY System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1310
4.241 M_SERVICE_MEMORY System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1311
4.242 M_SERVICE_NETWORK_IO System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1312
4.243 M_SERVICE_NETWORK_IO_RESET System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1313
4.244 M_SERVICE_REPLICATION System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1313
4.245 M_SERVICE_STATISTICS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1316
4.246 M_SERVICE_THREADS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1319
4.247 M_SERVICE_THREAD_CALLSTACKS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1321
4.248 M_SERVICE_THREAD_SAMPLES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1321
4.249 M_SERVICE_TRACES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1323
4.250 M_SERVICE_TYPES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1324
4.251 M_SESSION_CONTEXT System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1324
4.252 M_SHARED_MEMORY System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1330
4.253 M_SNAPSHOTS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1330
4.254 M_SQL_CLIENT_NETWORK_IO System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1331
4.255 M_SQL_PLAN_CACHE System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1332
4.256 M_SQL_PLAN_CACHE_RESET System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1340
4.257 M_SQL_PLAN_CACHE_EXECUTION_LOCATION_STATISTICS System View. . . . . . . . . . . . . . . . 1340
4.258 M_SQL_PLAN_CACHE_EXECUTION_LOCATION_STATISTICS_RESET System View. . . . . . . . . . . 1341
4.259 M_SQL_PLAN_CACHE_OVERVIEW System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1342
4.260 M_SQL_PLAN_CACHE_PARAMETERS System View. . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . 1345
4.261 M_SQL_PLAN_STATISTICS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1345
4.262 M_STATISTICS_LASTVALUES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1353
4.263 M_SYSTEM_AVAILABILITY System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1354
4.264 M_SYSTEM_INFORMATION_STATEMENTS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1355
4.265 M_SYSTEM_LIMITS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1356
4.266 M_SYSTEM_OVERVIEW System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1356
4.267 M_SYSTEM_REPLICATION System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1357
4.268 M_SYSTEM_REPLICATION_MVCC_HISTORY System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . .1358
4.269 M_TABLES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1358
4.270 M_TABLE_LOB_FILES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1359
4.271 M_TABLE_LOB_STATISTICS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1360
4.272 M_TABLE_LOCATIONS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1362
4.273 M_TABLE_LOCKS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1363
4.274 M_TABLE_PERSISTENCE_LOCATIONS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1363
4.275 M_TABLE_PERSISTENCE_LOCATION_STATISTICS System View. . . . . . . . . . . . . . . . . . . . . . . . 1364
4.276 M_TABLE_PERSISTENCE_STATISTICS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1365
4.277 M_TABLE_REPLICAS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1366
4.278 M_TABLE_REPLICAS_RESET System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1368
4.279 M_TABLE_SNAPSHOTS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1369
4.280 M_TABLE_STATISTICS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1370
SAP HANA SQL and System Views Reference
Content P U B L I C 11
4.281 M_TABLE_STATISTICS_RESET System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1371
4.282 M_TABLE_VIRTUAL_FILES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1372
4.283 M_TEMPORARY_JOIN_CONDITIONS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1373
4.284 M_TEMPORARY_JOIN_CONSTRAINTS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1374
4.285 M_TEMPORARY_KEY_FIGURES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1374
4.286 M_TEMPORARY_OBJECT_DEPENDENCIES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1375
4.287 M_TEMPORARY_TABLES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1376
4.288 M_TEMPORARY_TABLE_COLUMNS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1378
4.289 M_TEMPORARY_VIEWS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1380
4.290 M_TEMPORARY_VIEW_COLUMNS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1381
4.291 M_TENANTS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1382
4.292 M_TEXT_ANALYSIS_LANGUAGES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1383
4.293 M_TEXT_ANALYSIS_MIME_TYPES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1383
4.294 M_TIMEZONE_ALERTS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1384
4.295 M_TOPOLOGY_TREE System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1385
4.296 M_TRACEFILES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1386
4.297 M_TRACEFILE_CONTENTS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1387
4.298 M_TRACE_CONFIGURATION System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1388
4.299 M_TRACE_CONFIGURATION_RESET System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1389
4.300 M_TRANS_TOKENS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1390
4.301 M_TRANSACTIONS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1391
4.302 M_UNDO_CLEANUP_FILES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1393
4.303 M_VERSION_MEMORY System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1395
4.304 M_VOLUMES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1395
4.305 M_VOLUME_FILES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1396
4.306 M_VOLUME_IO_DETAILED_STATISTICS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1397
4.307 M_VOLUME_IO_DETAILED_STATISTICS_RESET System View. . . . . . . . . . . . . . . . . . . . . . . . . . 1400
4.308 M_VOLUME_IO_PERFORMANCE_STATISTICS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . 1400
4.309 M_VOLUME_IO_PERFORMANCE_STATISTICS_RESET System View. . . . . . . . . . . . . . . . . . . . . .1408
4.310 M_VOLUME_IO_RETRY_STATISTICS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1408
4.311 M_VOLUME_IO_RETRY_STATISTICS_RESET System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1411
4.312 M_VOLUME_IO_STATISTICS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1411
4.313 M_VOLUME_IO_STATISTICS_RESET System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1415
4.314 M_VOLUME_IO_TOTAL_STATISTICS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1416
4.315 M_VOLUME_IO_TOTAL_STATISTICS_RESET System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1418
4.316 M_VOLUME_SIZES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1418
4.317 M_WORKLOAD System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1419
4.318 M_WORKLOAD_CAPTURES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1420
4.319 M_WORKLOAD_REPLAYS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1422
4.320 M_WORKLOAD_REPLAY_PREPROCESSES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1423
4.321 M_XS_APPLICATIONS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1426
12 P U B L I C
SAP HANA SQL and System Views Reference
Content
4.322 M_XS_APPLICATION_ISSUES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1426
4.323 M_XS_PUBLIC_URLS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1427
4.324 M_XS_SESSIONS System View. . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . . . 1427
4.325 OBJECTS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1428
4.326 OBJECT_DEPENDENCIES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1429
4.327 OBJECT_PRIVILEGES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1429
4.328 OWNERSHIP System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1430
4.329 PARTITIONED_TABLES System View . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1430
4.330 PINNED_SQL_PLANS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1431
4.331 PRIVILEGES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1432
4.332 PROCEDURES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1433
4.333 PROCEDURE_OBJECTS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1435
4.334 PROCEDURE_PARAMETERS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1436
4.335 PROCEDURE_PARAMETER_COLUMNS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1437
4.336 PROJECTION_VIEW_COLUMN_SOURCES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1438
4.337 PSES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1438
4.338 PSE_CERTIFICATES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1439
4.339 QUERY_PLANS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1439
4.340 REFERENTIAL_CONSTRAINTS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1440
4.341 REMOTE_SOURCES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1441
4.342 REMOTE_USERS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1442
4.343 REORG_OVERVIEW System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1442
4.344 REORG_PLAN System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1443
4.345 REORG_PLAN_INFOS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1444
4.346 REORG_STEPS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1445
4.347 RESERVED_KEYWORDS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1446
4.348 RESULT_CACHE System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1447
4.349 RESULT_CACHE_COLUMNS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1448
4.350 ROLE_LDAP_GROUPS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1448
4.351 ROLES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1449
4.352 SAML_PROVIDER System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1449
4.353 SAML_USER_MAPPINGS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1450
4.354 SCHEMAS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1451
4.355 SEARCH_RULE_SETS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1451
4.356 SEARCH_RULE_SET_CONDITIONS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1452
4.357 SEQUENCES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1453
4.358 SERIES_KEY_COLUMNS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1454
4.359 SERIES_TABLES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1455
4.360 SESSION_COOKIES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1456
4.361 SQLSCRIPT_TRACE System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1457
4.362 STATEMENT_HINTS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1458
SAP HANA SQL and System Views Reference
Content P U B L I C 13
4.363 STATISTICS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1459
4.364 STRUCTURED_PRIVILEGES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1460
4.365 ST_GEOMETRY_COLUMNS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1461
4.366 ST_SPATIAL_REFERENCE_SYSTEMS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1461
4.367 ST_UNITS_OF_MEASURE System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1464
4.368 SYNONYMS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1464
4.369 TABLES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1465
4.370 TABLE_COLUMNS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1468
4.371 TABLE_COLUMNS_ODBC System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1471
4.372 TABLE_GROUPS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1472
4.373 TABLE_PARTITIONS System View . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1472
4.374 TABLE_PLACEMENT System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1474
4.375 TABLE_REPLICAS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1474
4.376 TEXT_CONFIGURATIONS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1475
4.377 TIMEZONES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1476
4.378 TRANSACTION_HISTORY System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1476
4.379 TRIGGERS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1477
4.380 USERS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1478
4.381 USER_PARAMETERS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1480
4.382 VIEWS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1480
4.383 VIEW_COLUMNS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1482
4.384 VIRTUAL_COLUMN_PROPERTIES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1484
4.385 VIRTUAL_COLUMNS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . 1485
4.386 VIRTUAL_FUNCTION_PACKAGES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1486
4.387 VIRTUAL_FUNCTIONS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1486
4.388 VIRTUAL_TABLE_PARAMETERS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1487
4.389 VIRTUAL_TABLE_PROPERTIES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1488
4.390 VIRTUAL_TABLES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1489
4.391 VIRTUAL_PACKAGES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1490
4.392 VIRTUAL_PROCEDURES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1490
4.393 WORKLOAD_CLASSES System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1491
4.394 WORKLOAD_MAPPINGS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1491
4.395 X509_USER_MAPPINGS System View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1492
4.396 Embedded Statistics Service Views. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1493
GLOBAL_DEC_EXTRACTOR_STATUS System View (Embedded Statistics Service). . . . . . . . . 1493
GLOBAL_DISKS System View (Embedded Statistics Service). . . . . . . . . . . . . . . . . . . . . . . . 1494
GLOBAL_INTERNAL_EVENTS System View (Embedded Statistics Service). . . . . . . . . . . . . . 1495
GLOBAL_PERSISTENCE_STATISTICS System View (Embedded Statistics Service). . . . . . . . .1496
GLOBAL_ROWSTORE_TABLES_SIZE System View (Embedded Statistics Service). . . . . . . . . 1497
GLOBAL_TABLE_PERSISTENCE_STATISTICS System View (Embedded Statistics Service)
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1498
14 P U B L I C
SAP HANA SQL and System Views Reference
Content
HOST_BLOCKED_TRANSACTIONS System View (Embedded Statistics Service). . . . . . . . . . 1500
HOST_COLUMN_TABLES_PART_SIZE System View (Embedded Statistics Service). . . . . . . . 1502
HOST_CONNECTIONS System View (Embedded Statistics Service). . . . . . . . . . . . . . . . . . . .1505
HOST_CONNECTION_STATISTICS System View (Embedded Statistics Service). . . . . . . . . . .1508
HOST_CS_UNLOADS System View (Embedded Statistics Service). . . . . . . . . . . . . . . . . . . . . 1513
HOST_DATA_VOLUME_PAGE_STATISTICS System View (Embedded Statistics Service). . . . . 1514
HOST_DATA_VOLUME_SUPERBLOCK_STATISTICS System View (Embedded Statistics 
Service). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1515
HOST_DELTA_MERGE_STATISTICS System View (Embedded Statistics Service). . . . . . . . . . 1516
HOST_HEAP_ALLOCATORS System View (Embedded Statistics Service). . . . . . . . . . . . . . . . 1518
HOST_LIVECACHE_CONTAINER_STATISTICS System View (Embedded Statistics Service)
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1520
HOST_LIVECACHE_OMS_VERSIONS System View (Embedded Statistics Service). . . . . . . . . .1521
HOST_LIVECACHE_PROCEDURE_STATISTICS System View (Embedded Statistics Service)
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1522
HOST_LIVECACHE_SCHEMA_STATISTICS System View (Embedded Statistics Service). . . . . 1524
HOST_LOAD_HISTORY_HOST System View (Embedded Statistics Service). . . . . . . . . . . . . . 1525
HOST_LOAD_HISTORY_SERVICE System View (Embedded Statistics Service). . . . . . . . . . . . 1526
HOST_LONG_IDLE_CURSOR System View (Embedded Statistics Service). . . . . . . . . . . . . . . 1528
HOST_LONG_RUNNING_STATEMENTS System View (Embedded Statistics Service). . . . . . . 1529
HOST_LONG_SERIALIZABLE_TRANSACTION System View (Embedded Statistics Service)
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1531
HOST_MVCC_OVERVIEW System View (Embedded Statistics Service). . . . . . . . . . . . . . . . . .1532
HOST_OBJECT_LOCKS System View (Embedded Statistics Service). . . . . . . . . . . . . . . . . . . 1533
HOST_OBJECT_LOCK_STATISTICS System View (Embedded Statistics Service). . . . . . . . . . 1534
HOST_ONE_DAY_FILE_COUNT System View (Embedded Statistics Service). . . . . . . . . . . . . .1535
HOST_RECORD_LOCKS System View (Embedded Statistics Service). . . . . . . . . . . . . . . . . . .1536
HOST_RESOURCE_UTILIZATION_STATISTICS System View (Embedded Statistics Service)
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1537
HOST_RS_INDEXES System View (Embedded Statistics Service). . . . . . . . . . . . . . . . . . . . . .1538
HOST_RS_MEMORY System View (Embedded Statistics Service). . . . . . . . . . . . . . . . . . . . . 1540
HOST_SAVEPOINTS System View (Embedded Statistics Service). . . . . . . . . . . . . . . . . . . . . 1540
HOST_SERVICE_COMPONENT_MEMORY System View (Embedded Statistics Service). . . . . . 1542
HOST_SERVICE_MEMORY System View (Embedded Statistics Service). . . . . . . . . . . . . . . . . 1543
HOST_SERVICE_REPLICATION System View (Embedded Statistics Service). . . . . . . . . . . . . 1544
HOST_SERVICE_STATISTICS System View (Embedded Statistics Service). . . . . . . . . . . . . . .1546
HOST_SERVICE_THREAD_SAMPLES System View (Embedded Statistics Service). . . . . . . . . 1548
HOST_SERVICE_THREAD_SAMPLES_STATEMENTS System View (Embedded Statistics 
Service). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1549
HOST_SQL_PLAN_CACHE System View (Embedded Statistics Service). . . . . . . . . . . . . . . . . 1551
HOST_SQL_PLAN_CACHE_OVERVIEW System View (Embedded Statistics Service). . . . . . . . 1556
HOST_TASKS System View (Embedded Statistics Service). . . . . . . . . . . . . . . . . . . . . . . . . . 1559
SAP HANA SQL and System Views Reference
Content P U B L I C 15
HOST_TASK_OPERATIONS System View (Embedded Statistics Service). . . . . . . . . . . . . . . . 1560
HOST_UNCOMMITTED_WRITE_TRANSACTION System View (Embedded Statistics Service)
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1561
HOST_VOLUME_FILES System View (Embedded Statistics Service). . . . . . . . . . . . . . . . . . . .1562
HOST_VOLUME_IO_DETAILED_STATISTICS System View (Embedded Statistics Service)
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1563
HOST_VOLUME_IO_RETRY_STATISTICS System View (Embedded Statistics Service). . . . . . 1566
HOST_VOLUME_IO_TOTAL_STATISTICS System View (Embedded Statistics Service). . . . . . 1568
HOST_WORKLOAD System View (Embedded Statistics Service). . . . . . . . . . . . . . . . . . . . . . 1570
STATISTICS_ALERTS System View (Embedded Statistics Service). . . . . . . . . . . . . . . . . . . . . 1571
STATISTICS_CURRENT_ALERTS System View (Embedded Statistics Service). . . . . . . . . . . . 1572
STATISTICS_LAST_CHECKS System View (Embedded Statistics Service). . . . . . . . . . . . . . . 1572
STREAMING_PROJECTS_STATISTICS System View (Embedded Statistics Service). . . . . . . . 1573
STREAMING_PROJECT_CONNECTIONS_STATISTICS System View (Embedded Statistics 
Service). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1574
STREAMING_PROJECT_STREAMS_STATISTICS SystemView (Embedded Statistics Service)
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1576
STREAMING_PUBLISHERS_STATISTICS System View (Embedded Statistics Service). . . . . . .1577
STREAMING_SUBSCRIBERS_STATISTICS System View (Embedded Statistics Service). . . . . 1578
STATISTICS_ALERT_INFORMATION System View (Embedded Statistics Service). . . . . . . . . . 1579
STATISTICS_ALERT_THRESHOLDS System View (Embedded Statistics Service). . . . . . . . . . 1579
STATISTICS_EMAILRECIPIENTS System View (Embedded Statistics Service). . . . . . . . . . . . 1580
STATISTICS_EMAIL_PROCESSING System View (Embedded Statistics Service). . . . . . . . . . . 1581
STATISTICS_OBJECTS System View (Embedded Statistics Service). . . . . . . . . . . . . . . . . . . .1581
STATISTICS_PROPERTIES System View (Embedded Statistics Service). . . . . . . . . . . . . . . . . 1582
STATISTICS_SCHEDULE System View (Embedded Statistics Service). . . . . . . . . . . . . . . . . . 1582
4.397 Statistics Server Tables. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1583
5 System Views Reference for SAP HANA Options. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1647
5.1 Dynamic Tiering. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1647
M_ES_CONNECTIONS System View [Dynamic Tiering]. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1648
M_ES_DBSPACE_FILES System View [Dynamic Tiering]. . . . . . . . . . . . . . . . . . . . . . . . . . . . 1649
M_ES_DELTA_MEMORY System View [Dynamic Tiering]. . . . . . . . . . . . . . . . . . . . . . . . . . . .1650
M_ES_DELTA_MERGE_STATISTICS System View [Dynamic Tiering]. . . . . . . . . . . . . . . . . . . 1651
M_ES_DBSPACES System Views [Dynamic Tiering]. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1652
M_ES_SERVICE_REPLICATION System View [Dynamic Tiering]. . . . . . . . . . . . . . . . . . . . . . .1653
M_ES_LOCKS System View [Dynamic Tiering]. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1655
M_ES_OVERVIEW System View [Dynamic Tiering]. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1656
M_ES_TABLES System View [Dynamic Tiering]. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1657
M_ES_TRANSACTIONS System View [Dynamic Tiering]. . . . . . . . . . . . . . . . . . . . . . . . . . . . 1657
Additional System View [Dynamic Tiering]. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1660
5.2 Smart Data Integration. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1661
16 P U B L I C
SAP HANA SQL and System Views Reference
Content
ADAPTER_CAPABILITIES System View [Smart Data Integration]. . . . . . . . . . . . . . . . . . . . . . 1663
ADAPTER_LOCATIONS System View [Smart Data Integration]. . . . . . . . . . . . . . . . . . . . . . . 1663
ADAPTERS System View [Smart Data Integration]. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1664
AGENT_CONFIGURATION System View [Smart Data Integration]. . . . . . . . . . . . . . . . . . . . . 1664
AGENT_GROUPS System View [Smart Data Integration]. . . . . . . . . . . . . . . . . . . . . . . . . . . . 1665
AGENTS System View [Smart Data Integration]. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1665
M_AGENTS System View [Smart Data Integration]. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1666
M_REMOTE_SOURCES System View [Smart Data Integration]. . . . . . . . . . . . . . . . . . . . . . . 1666
M_REMOTE_SUBSCRIPTION_COMPONENTS System View [Smart Data Integration]. . . . . . . 1667
M_REMOTE_SUBSCRIPTION_STATISTICS System View [Smart Data Integration]. . . . . . . . . 1668
M_REMOTE_SUBSCRIPTIONS System View [Smart Data Integration]. . . . . . . . . . . . . . . . . . 1669
M_SESSION_CONTEXT System View [Smart Data Integration]. . . . . . . . . . . . . . . . . . . . . . . 1670
REMOTE_SOURCE_ OBJECT_DESCRIPTIONS System View [Smart Data Integration]. . . . . . . 1671
REMOTE_SOURCE_OBJECTS System View [Smart Data Integration]. . . . . . . . . . . . . . . . . . . 1672
REMOTE_SOURCES System View [Smart Data Integration]. . . . . . . . . . . . . . . . . . . . . . . . . . 1672
REMOTE_SUBSCRIPTION_EXCEPTIONS System View [Smart Data Integration]. . . . . . . . . . . 1673
REMOTE_SUBSCRIPTIONS System View [Smart Data Integration]. . . . . . . . . . . . . . . . . . . . 1674
TASK_CLIENT_MAPPING System View [Smart Data Integration]. . . . . . . . . . . . . . . . . . . . . . 1675
TASK_COLUMN_DEFINITIONS System View [Smart Data Integration]. . . . . . . . . . . . . . . . . . 1675
TASK_EXECUTIONS System View [Smart Data Integration]. . . . . . . . . . . . . . . . . . . . . . . . . .1676
TASK_LOCALIZATION System View [Smart Data Integration]. . . . . . . . . . . . . . . . . . . . . . . . 1677
TASK_OPERATIONS System View [Smart Data Integration]. . . . . . . . . . . . . . . . . . . . . . . . . 1678
TASK_OPERATIONS_EXECUTIONS System View [Smart Data Integration]. . . . . . . . . . . . . . .1679
TASK_PARAMETERS System View [Smart Data Integration]. . . . . . . . . . . . . . . . . . . . . . . . . 1680
TASK_TABLE_DEFINITIONS System View [Smart Data Integration]. . . . . . . . . . . . . . . . . . . . 1680
TASK_TABLE_RELATIONSHIPS System View [Smart Data Integration]. . . . . . . . . . . . . . . . . .1681
TASKS System View [Smart Data Integration]. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1682
VIRTUAL_COLUMN_PROPERTIES System View [Smart Data Integration]. . . . . . . . . . . . . . . .1683
VIRTUAL_TABLE_PROPERTIES System View [Smart Data Integration]. . . . . . . . . . . . . . . . . 1684
5.3 Smart Data Quality. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1684
BEST_RECORD_GROUP_MASTER_STATISTICS System View [Smart Data Quality]. . . . . . . . 1685
BEST_RECORD_RESULTS System View [Smart Data Quality]. . . . . . . . . . . . . . . . . . . . . . . . 1685
BEST_RECORD_STRATEGIES System View [Smart Data Quality]. . . . . . . . . . . . . . . . . . . . . .1687
CLEANSE_ADDRESS_RECORD_INFO System View [Smart Data Quality]. . . . . . . . . . . . . . . . 1687
CLEANSE_CHANGE_INFO System View [Smart Data Quality]. . . . . . . . . . . . . . . . . . . . . . . . 1688
CLEANSE_COMPONENT_INFO System View [Smart Data Quality]. . . . . . . . . . . . . . . . . . . . .1689
CLEANSE_INFO_CODES System View [Smart Data Quality]. . . . . . . . . . . . . . . . . . . . . . . . . .1691
CLEANSE_STATISTICS System View [Smart Data Quality]. . . . . . . . . . . . . . . . . . . . . . . . . . 1692
GEOCODE_INFO_CODES System View [Smart Data Quality]. . . . . . . . . . . . . . . . . . . . . . . . . 1693
GEOCODE_STATISTICS System View [Smart Data Quality]. . . . . . . . . . . . . . . . . . . . . . . . . . 1694
MATCH_GROUP_INFO System View [Smart Data Quality]. . . . . . . . . . . . . . . . . . . . . . . . . . . 1694
SAP HANA SQL and System Views Reference
Content P U B L I C 17
MATCH_RECORD_INFO System View [Smart Data Quality]. . . . . . . . . . . . . . . . . . . . . . . . . . 1695
MATCH_SOURCE_STATISTICS System View [Smart Data Quality]. . . . . . . . . . . . . . . . . . . . 1696
MATCH_STATISTICS System View [Smart Data Quality]. . . . . . . . . . . . . . . . . . . . . . . . . . . . 1697
MATCH_TRACING System View [Smart Data Quality]. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1698
5.4 Smart Data Streaming. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1699
M_STREAMING_APPLICATIONS System View [Smart Data Streaming]. . . . . . . . . . . . . . . . . 1700
M_STREAMING_PROJECTS System View [Smart Data Streaming]. . . . . . . . . . . . . . . . . . . . . 1701
M_STREAMING_PROJECT_ADAPTERS System View [Smart Data Streaming].. . . . . . . . . . . 1704
M_STREAMING_PROJECT_ADAPTER_STATISTICS System View [Smart Data Streaming]
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1706
M_STREAMING_PROJECT_GD_SUBSCRIPTIONS System View [Smart Data Streaming]. . . . . 1707
M_STREAMING_PROJECT_PUBLISHERS System View [Smart Data Streaming]. . . . . . . . . . . 1709
M_STREAMING_PROJECT_SUBSCRIBERS System View [Smart Data Streaming]. . . . . . . . . . 1711
M_STREAMING_PROJECT_STREAMS System View [Smart Data Streaming]. . . . . . . . . . . . . .1714
M_STREAMING_SCHEMAS System View [Smart Data Streaming]. . . . . . . . . . . . . . . . . . . . . 1717
M_STREAMING_SERVICES System View [Smart Data Streaming]. . . . . . . . . . . . . . . . . . . . . 1718
Additional Views For Smart Data Streaming. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1718
18 P U B L I C
SAP HANA SQL and System Views Reference
Content
1 Introduction
This reference describes the syntax and semantics of SQL statements and system views in the SAP HANA 
database system. This document applies to all supported platforms in the same manner if it is not explicitly 
mentioned to work for a specific one. The guide reflects the structure of the SAP HANA® platform.
The SAP HANA platform is composed of the following components:
● The SAP HANA base edition as part of the SAP HANA platform is required for all SAP HANA deployments. 
The SAP HANA base edition comprises among others:
○ SAP HANA Database
The functions of the SAP HANA base edition are described in the chapters SQL Reference and System 
Views Reference.
● SAP HANA options and capabilities provide additional functions you can use in addition to the SAP HANA 
base edition. To use the SAP HANA options you need a dedicated license for the options you want to use 
(see disclaimer below). SAP HANA options include:
○ SAP HANA Accelerator for SAP ASE
○ SAP HANA Dynamic Tiering
○ SAP HANA Remote Data Sync
○ SAP HANA Smart Data Integration
○ SAP HANA Smart Data Quality
○ SAP HANA Smart Data Streaming
The following SAP HANA features, SAP HANA capabilities, SAP HANA options are supported on Intel-based 
hardware platforms only:
● SAP HANA Accelerator for SAP ASE
● SAP HANA Hadoop Controller
● SAP HANA Remote Data Sync
● SAP HANA Smart Data Streaming
● SAP HANA Information Composer
● HIVE ODBC Driver
The functions of the SAP HANA options are described in the chapters SQL Reference for SAP HANA Options 
and System Views Reference for SAP HANA Options.
Caution
SAP HANA server software and tools can be used for several SAP HANA platform and options scenarios as 
well as the respective capabilities used in these scenarios. The availability of these is based on the available 
SAP HANA licenses and the SAP HANA landscape, including the type and version of the back-end systems 
the SAP HANA administration and development tools are connected to. There are several types of licenses 
available for SAP HANA. Depending on your SAP HANA installation license type, some of the features and 
tools described in the SAP HANA platform documentation may only be available in the SAP HANA options 
and capabilities, which may be released independently of an SAP HANA Platform Support Package Stack 
(SPS). Although various features included in SAP HANA options and capabilities are cited in the SAP HANA 
platform documentation, each SAP HANA edition governs the options and capabilities available. Based on 
SAP HANA SQL and System Views Reference
Introduction P U B L I C 19
this, customers do not necessarily have the right to use features included in SAP HANA options and 
capabilities. For customers to whom these license restrictions apply, the use of features included in SAP 
HANA options and capabilities in a production system requires purchasing the corresponding software 
license(s) from SAP. The documentation for the SAP HANA optional components is available in SAP Help 
Portal at http://help.sap.com/hana_options. If you have additional questions about what your particular 
license provides, or wish to discuss licensing features available in SAP HANA options, please contact your 
SAP account team representative.
Related Information
SQL Reference [page 21]
SQL Reference for SAP HANA Options [page 776]
System Views Reference [page 990]
System Views Reference for SAP HANA Options [page 1647]
20 P U B L I C
SAP HANA SQL and System Views Reference
Introduction
http://help.sap.com/hana_options
2 SQL Reference
Notation [page 21]
Introduction to SQL [page 24]
This chapter describes the SAP HANA database implementation of Structured Query Language (SQL).
Data Types [page 26]
A data type defines the characteristics of a data value.
Reserved Words [page 42]
Reserved words are words which have a special meaning to the SQL parser in the SAP HANA database 
and cannot be used as when defining an identifier. 
Operators [page 44]
Expressions [page 47]
Predicates [page 51]
SQL Functions [page 61]
SQL Statements [page 304]
System Limitations [page 719]
There are some limitations to take into consideration when administering an SAP HANA database.
SQL Error Codes [page 722]
Each SAP HANA error has a numeric error code. The M_ERROR_CODES system view contains 
information about the error codes.
2.1 Notation
This reference uses BNF (Backus-Naur Form), a notation technique used to define programming languages. 
BNF describes the syntax of a grammar using a set of production rules and a set of symbols.
Symbols used in BNF
Table 1:
Symbol Description
< > Angle brackets are used to surround the name of a syntactic 
element (BNF nonterminal) of the SQL language.
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 21
Symbol Description
::= The definition operator is used to provide definitions of the 
element appearing on the left side of the operator in a pro­
duction rule.
[ ] Square brackets are used to indicate optional elements in a 
formula. Optional elements can be specified or omitted.
{ } Braces group elements in a formula. Repetitive elements 
(zero or more elements) can be specified within brace sym­
bols.
| The alternative operator indicates that the portion of the 
formula following the bar is an alternative to the portion pre­
ceding it.
... Ellipsis indicates that the element can be repeated any num­
ber of times. If ellipsis appears after grouped elements, the 
grouped elements enclosed with braces can be repeated 
any number of times. If ellipsis appears after a single ele­
ment, only this element can be repeated any number of 
times.
!! Introduces normal English text. This is used when the defini­
tion of a syntactic element is not expressed in BNF.
BNF Lowest Terms Representations
Throughout the BNF used in this manual, each syntax term is defined to one of the lowest term 
representations shown below.
<digit> ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 <letter> ::= a | b | c | d | e | f | g | h | i | j | k | l | m | n | o | p | q | 
r | s | t | u | v | w | x | y | z | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | 
R | S | T | U | V | W | X | Y | Z
 <any_character> ::= !!any character. <comma> ::= , <dollar_sign> ::= $ <double_quotes> ::= " <greater_than_sign> ::= > <hash_symbol> ::= # <left_bracket> ::= [ 
22 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
<left_curly_bracket> ::= { <lower_than_sign> ::= < <period> ::= . <pipe_sign> ::= | <right_bracket> ::= ] <right_curly_bracket> ::= } <sign> ::= + | - <single_quote> ::= ' <underscore> ::= _ <apostrophe> ::= <single_quote> <approximate_numeric_literal> ::= <mantissa>E<exponent> <cesu8_restricted_characters> ::= <double_quote> | <dollar_sign> | 
<single_quote> | <sign> | <period> | <greater_than_sign> | <lower_than_sign> | 
<pipe_sign> | <left_bracket> | <right_bracket> | <left_curly_bracket>| 
<right_curly_bracket> | ( | ) | ! | % | * | , | / | : | ; | = | ? | @ | \ | ^ 
| ` <exact_numeric_literal> ::= <unsigned_integer>[<period>[<unsigned_integer>]] | <period><unsigned_integer> <exponent> ::= <signed_integer> <hostname> ::= {<letter> | <digit>}[{ <letter> | <digit> | <period> | - }...] <identifier> ::= simple_identifier | special_identifier <mantissa> ::= <exact_numeric_literal> <numeric_literal> ::= <signed_numeric_literal> | <signed_integer> <password> ::= {<letter> | <underscore> | <hash_symbol> | <dollar_sign> | 
<digit>}... | <double_quotes> <any_character>...<double_quotes> <port_number> ::= <unsigned_integer> <schema_name> ::= <unicode_name> <simple_identifier> ::= {<letter> | <underscore>} [{<letter> | <digit> | 
<underscore> | <hash_symbol> | <dollar_sign>}...] <special_identifier> ::= <double_quotes><any_character>...<double_quotes> <signed_integer> ::= [<sign>] <unsigned_integer> <signed_numeric_literal> ::= [<sign>] <unsigned_numeric_literal> <string_literal> ::= <single_quote>[<any_character>...]<single_quote> <unicode_name> ::= !! CESU-8 string excluding any characters listed in 
<cesu8_restricted_characters> <unsigned_integer> ::= <digit>... <unsigned_numeric_literal> ::= <exact_numeric_literal> | 
<approximate_numeric_literal> <user_name> ::= <unicode_name> 
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 23
2.2 Introduction to SQL
This chapter describes the SAP HANA database implementation of Structured Query Language (SQL).
● SQL [page 24]
● Supported languages and code pages [page 24]
● Comments [page 24]
● Identifiers [page 25]
● Quotation marks [page 25]
● Identifiers and case sensitivity [page 25]
SQL
SQL stands for Structured Query Language. It is a standardized language for communicating with a relational 
database. SQL is used to retrieve, store or manipulate information in the database.
SQL statements perform the following tasks:
● Schema definition and manipulation
● Data manipulation
● System management
● Session management
● Transaction management
Supported languages and code pages
The SAP HANA database supports Unicode to allow the use of all languages in the Unicode Standard and 7 Bit 
ASCII code page without restriction.
Comments
You can add comments to improve the readability and maintainability of your SQL statements. Comments are 
delimited in SQL statements as follows:
● Double hyphens "--". Everything after the double hyphen until the end of a line is ignored by the SQL 
parser.
● "/*" and "*/". This style of commenting is used to place comments on multiple lines. All text between the 
opening "/*" and closing "*/" is ignored by the SQL parser.
24 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
Identifiers
Identifiers are used to represent names used in SQL statement including table name, view name, synonym 
name, column name, index name, function name, procedure name, user name, role name, and so on. There 
are two kinds of identifiers, undelimited identifiers and delimited identifiers.
● Undelimited table and column names must start with a letter and cannot contain any symbols other than 
digits or an underscore "_".
● Delimited identifiers are enclosed in the delimiter, double quotes. The identifier can then contain any 
character including special characters. "AB$%CD" is a valid identifier name for example.
● Limitations:
○ "_SYS_" is reserved exclusively for database engine and is therefore not allowed at the beginning of 
schema object names.
○ The role name and user name must be specified as undelimited identifiers.
○ The maximum length for identifiers is 127 characters.
Quotation marks
Single quotation marks are used to delimit string literals. A single quotation mark itself can be represented 
using two single quotation marks. Double quotation marks are used to delimit identifiers. A double quotation 
mark itself can be represented using two double quotation marks.
Identifiers and case sensitivity
Identifiers without double-quotes in SQL syntax are converted to upper case when processed by the server. 
For example, the statement CREATE COLUMN TABLE MyTAB.. creates a table called MYTAB, whereas 
CREATE COLUMN TABLE "MyTab" creates a table called MyTab--and both tables can co-exist in the 
database.
Specifying identifiers without double-quotes is allowed but can cause ambiguity later when querying or 
performing operations on objects where casing in the identifier name is significant. A recommendation is to 
standardize to using double-quotes around all identifiers in SQL statements where ambiguity may be a 
concern.
Related Information
Notation [page 21]
M_INIFILE_CONTENTS System View [page 1207]
AUDIT_LOG System View [page 1017]
AUDIT_POLICIES System View [page 1019]
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 25
2.3 Data Types
A data type defines the characteristics of a data value.
This section describes the data types used in the SAP HANA database. A special value of NULL is included in 
every data type to indicate the absence of a value.
● Classification of Data Types [page 26]
● Datetime Types [page 27]
○ Date Formats [page 27]
○ Time Formats [page 28]
○ Timestamp Formats [page 29]
○ Additional Formats [page 29]
○ Supported Functions for Date/Time types [page 30]
● Multi-valued types [page 31]
● Numeric Types [page 31]
● Boolean Types [page 33]
● Character String Types [page 33]
● Binary Types [page 34]
● Large Object (LOB) Types [page 35]
● Spatial Types [page 36]
● Mapping between SQL Data Type and Column Store Data Type [page 37]
● Data Type Conversion [page 37]
● Typed Constant [page 41]
Classification of Data Types
In the SAP HANA database, each data type can be classified by its characteristics as follows:
Table 2: Classification of data types
Classification Data Type
Datetime types DATE, TIME, SECONDDATE, TIMESTAMP
Numeric types TINYINT, SMALLINT, INTEGER, BIGINT, SMALLDECIMAL, 
DECIMAL, REAL, DOUBLE
Boolean type BOOLEAN
Character string types VARCHAR, NVARCHAR, ALPHANUM, SHORTTEXT
Binary types VARBINARY
Large Object types BLOB, CLOB, NCLOB, TEXT
26 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
Classification Data Type
Multi-valued types ARRAY
Spatial types ST_GEOMETRY, ST_POINT
Datetime Types
● DATE
The DATE data type consists of year, month, and day information to represent a date value. The default 
format for the DATE data type is 'YYYY-MM-DD'. YYYY represents the year, MM represents the month, 
and DD represents the day. The range of the date value is between 0001-01-01 and 9999-12-31.
● TIME
The TIME data type consists of hour, minute, and second to represent a time value. The default format for 
the TIME data type is 'HH24:MI:SS'. HH24 represents the hour from 0 to 24, MI represents the minute 
from 0 to 59, SS represents the second from 0 to 59.
● SECONDDATE
The SECONDDATE data type consists of year, month, day, hour, minute and second information to 
represent a date with time value. The default format for the SECONDDATE data type is 'YYYY-MM-DD 
HH24:MI:SS'. YYYY represents the year, MM represents the month, DD represents the day, HH24 
represents hours, MI represents minutes, and SS represents seconds. The range of the date value is 
between 0001-01-01 00:00:01 and 9999-12-31 24:00:00.
● TIMESTAMP
The TIMESTAMP data type consists of date and time information. Its default format is 'YYYY-MM-DD 
HH24:MI:SS.FF7'. FFn represents the fractional seconds where n indicates the number of digits in 
fractional part. The range of the time stamp value is between 0001-01-01 00:00:00.0000000 and 
9999-12-31 23:59:59.9999999.
The 'EMPTY' value refers to the lowest possible value of each Datetime Type and ensures compatibility with 
ABAP.
For details about the formats supported for Datetime Types, see tables 4, 5, 6 and 7 below.
Date Formats
The following date/timeformats can be used when parsing a string into a date/time type and converting a 
date/time type value into a string value. The format for Time stamp is the combination of Date and Time with 
additional support for fractional seconds.
Note
An empty date ('000-00-00') is a special value in SAP HANA. Even though an empty date looks like a NULL 
or unknown value, it does not behave like one nor is it treated like one.
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 27
Table 3: Supported formats for Date
Format Description Examples
YYYY-MM-DD Default format INSERT INTO my_tbl VALUES 
('1957-06-13');
YYYY/MM/DD
YYYY/MM-DD
YYYY-MM/DD
YYYY from 0001 to 9999, MM from 1 to 
12, DD from 1 to 31. If year has less than 
four digits, month has less than two 
digits, or day has less than two digits, 
values are padded by one or more ze­
ros. A two-digit year 45 is saved as year 
0045 for example, while a one digit 
month 9 is saved as 09, and a one digit 
day 2 is saved as 02.
INSERT INTO my_tbl VALUES 
('1957-06-13');
INSERT INTO my_tbl VALUES 
('1957/06/13');
INSERT INTO my_tbl VALUES 
('1957/06-13');
INSERT INTO my_tbl VALUES 
('1957-06/13');
YYYYMMDD ABAP Data Type, DATS format. INSERT INTO my_tbl VALUES 
('19570613');
MON Abbreviated name of month. (JAN. ~ 
DEC.)
INSERT INTO my_tbl VALUES 
(TO_DATE('2040-Jan-10', 'YYYY-MON-
DD'));
INSERT INTO my_tbl VALUES 
(TO_DATE('Jan-10', 'MON-DD'));
MONTH Name of month. (JANUARY - DECEM­
BER).
INSERT INTO my_tbl VALUES 
(TO_DATE('2040-January-10', 'YYYY-
MONTH-DD'));
INSERT INTO my_tbl VALUES 
(TO_DATE('January-10', 'MONTH-
DD'));
RM Roman numeral month (I-XII; JAN = I). INSERT INTO my_tbl VALUES 
(TO_DATE('2040-I-10', 'YYYY-RM-
DD'));
INSERT INTO my_tbl VALUES 
(TO_DATE('I-10', 'RM-DD'));
DDD Day of year (1-366). INSERT INTO my_tbl VALUES 
(TO_DATE('204', 'DDD'));
INSERT INTO my_tbl VALUES 
(TO_DATE('2001-204','YYYY-DDD'));
Time Formats
28 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
Table 4: Supported formats for Time
Format Description Examples
HH24:MI:SS Default format
HH:MI[:SS][AM|PM]
HH12:MI[:SS][AM|PM]
HH24:MI[:SS]
HH from 0 to 23. MI from 0 to 59. SS 
from 0 to 59. FFF from 0 to 999.
If one digit hour, minute, second is 
specified, 0 is inserted into the value. 
9:9:9 is saved as 09:09:09 for example.
HH12 indicates 12 hour clock. HH24 in­
dicates 24 hour clock.
AM or PM can be specified as a suffix to 
indicate that the time value is before or 
after midday.
INSERT INTO my_tbl VALUES 
('23:59:59');
INSERT INTO my_tbl VALUES ('3:47:39 
AM');
INSERT INTO my_tbl VALUES ('9:9:9 
AM');
INSERT INTO my_tbl VALUES 
(TO_TIME('11:59:59','HH12:MI:SS');
SSSSS Seconds past midnight (0-86399). INSERT INTO my_tbl VALUES 
(TO_TIME('12345', 'SSSSS'));
Timestamp Formats
Table 5: Supported formats for Timestamp
Format Description Examples
YYYY-MM-DD HH24:MI:SS.FF7 Default format
FF [1..7] Fractional seconds has the range 1 to 7 
after the FF parameter to specify the 
number of digits in the fractional sec­
ond portion of the date time value re­
turned. If a digit is not specified, the de­
fault value is used.
INSERT INTO my_tbl VALUES 
(TO_TIMESTAMP('2011-05-11 
12:59.999','YYYY-MM-DD 
HH:SS.FF3'));
Additional Formats
Table 6: Additional formats for Datetime
Format Description Example
D Day of week (1-7). TO_VARCHAR(CURRENT_TIME­
STAMP,'D')
DAY Name of day (MONDAY - SUNDAY). TO_VARCHAR(CURRENT_TIME­
STAMP,'DAY')
DY Abbreviated name of day (MON - SUN). TO_VARCHAR(CURRENT_TIME­
STAMP,'DY')
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 29
Format Description Example
MON Abbreviated month name (JAN - DEC) TO_VARCHAR(CURRENT_TIME­
STAMP,'MON')
MONTH Full month name (JANUARY - DECEM­
BER)
TO_VARCHAR(CURRENT_TIME­
STAMP,'MONTH')
RM Roman numeral month (I - XII; I is for 
January)
TO_VARCHAR(CURRENT_TIME­
STAMP,'RM')
Q Quarter of year (1, 2, 3, 4) TO_VARCHAR(CURRENT_TIME­
STAMP,'Q')
W Week of month (1-5). TO_VARCHAR(CURRENT_TIME­
STAMP,'W')
WW Week of year (1-53). TO_VARCHAR(CURRENT_TIME­
STAMP,'WW')
Supported Functions for Date/Time types
● ADD_DAYS [page 65]
● ADD_MONTHS [page 65]
● ADD_SECONDS [page 67]
● ADD_YEARS [page 71]
● COALESCE [page 86]
● CURRENT_DATE [page 107]
● CURRENT_TIME [page 109]
● CURRENT_TIMESTAMP [page 110]
● CURRENT_UTCDATE [page 114]
● CURRENT_UTCTIME [page 114]
● CURRENT_UTCTIMESTAMP [page 115]
● DAYNAME [page 115]
● DAYOFMONTH [page 116]
● DAYOFYEAR [page 117]
● DAYS_BETWEEN [page 117]
● EXTRACT [page 122]
● GREATEST [page 125]
● HOUR [page 153]
● IFNULL [page 153]
● ISOWEEK [page 158]
● LAST_DAY [page 173]
● LEAST [page 175]
● LOCALTOUTC [page 178]
● MINUTE [page 191]
● MONTH [page 192]
● MONTHNAME [page 193]
30 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
● NEXT_DAY [page 195]
● NULLIF [page 198]
● QUARTER [page 201]
● SECOND [page 213]
● SECONDS_BETWEEN [page 214]
● TO_DATE [page 247]
● TO_DATS [page 248]
● TO_TIME [page 256]
● TO_TIMESTAMP [page 257]
● UTCTOLOCAL [page 263]
● WEEK [page 265]
● WEEKDAY [page 266]
● YEAR [page 270]
Multi-valued Types
Multi-valued types are used to store collections of values sharing the same data type.
● ARRAY
The ARRAY type is used to store collections of values sharing the same data type where each element is 
associated with exactly one ordinal position. Arrays can contain NULL values as elements to indicate the 
absence of a value. Arrays are immutable: adding, removing or changing elements is not possible.
Supported functions and expressions for the ARRAY type:
● <ARRAY> || <ARRAY> (concatenation)
● <ARRAY>[<index>] (element access)
● CARDINALITY
● MEMBER_AT
● [NOT] MEMBER OF
● SUBARRAY
● TRIM_ARRAY
● UNNEST
Numeric Types
Note
Each numeric type below has the maximum value and the minimum value. A numeric overflow exception is 
thrown if a value is smaller than the minimum value or greater than the maximum value. NaN and infinity 
are not supported in order to comply with IEEE754. -0.0 is stored as +0.0.
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 31
Note
Floating-point data types are stored in the system using binary numbers. The fractional part of these 
numbers is represented using a combination of 1/2, 1/4, 1/8, 1/16, and so on. For this reason they cannot 
completely represent rational numbers with fractional digits. For example, 0.1 cannot be represented 
exactly by combining these binary fractions. In this case, you obtain inaccurate results when using a 
floating-point data type. This is the correct behavior for these data types. The following example 
demonstrates the behaviour:
 SELECT TO_DOUBLE(0.1) + TO_DOUBLE(4.6) AS DOUBLE_SUM FROM DUMMY; DOUBLE_SUM
 4.6999999999 
● TINYINT
The TINYINT data type stores an 8-bit unsigned integer. The minimum value is 0. The maximum value is 
255.
● SMALLINT
The SMALLINT data type stores a 16-bit signed integer. The minimum value is -32,768. The maximum 
value is 32,767.
● INTEGER
The INTEGER data type stores a 32-bit signed integer. The minimum value is -2,147,483,648. The 
maximum value is 2,147,483,647.
● BIGINT
The BIGINT data type stores a 64-bit signed integer. The minimum value is -9,223,372,036,854,775,808. 
The maximum value is 9,223,372,036,854,775,807.
● DECIMAL(precision, scale) or DEC(p,s)
DECIMAL(p, s) is the SQL standard notation for fixed-point decimal. "p" specifies precision or the number 
of total digits (the sum of whole digits and fractional digits). "s" denotes scale or the number of fractional 
digits. If a column is defined as DECIMAL(5, 4) for example, the numbers 3.14, 3.1415, 3.141592 are stored 
in the column as 3.1400, 3.1415, 3.1415, retaining the specified precision(5) and scale(4).
Precision p, can range from 1 to 38. The scale can range from 0 to p. If the scale is not specified, it defaults 
to 0.
If precision and scale are not specified, DECIMAL becomes a floating-point decimal number. In this case, 
precision and scale can vary within the range1 to 34 for precision and -6,111 to 6,176 for scale, depending 
on the stored value.
Examples: 0.0000001234 (1234E-10) has precision 4 and scale 10. 1.0000001234 (10000001234E-10) 
has precision 11 and scale 10. The value 1234000000 (1234E6) has precision 4 and scale -6.
● SMALLDECIMAL
The SMALLDECIMAL is a floating-point decimal number. The precision and scale can vary within the 
range 1~16 for precision and -369~368 for scale, depending on the stored value. SMALLDECIMAL is only 
supported on column store.
DECIMAL and SMALLDECIMAL are floating-point types. For instance, a decimal column can store any of 
3.14, 3.1415, 3.141592 while maintaining their precision.
DECIMAL(p, s) is the SQL standard notation for fixed-point decimal. 3.14, 3.1415, 3.141592 are stored in a 
decimal(5, 4) column as 3.1400, 3.1415, 3.1415 for example, retaining the specified precision(5) and 
scale(4).
● REAL
The REAL data type specifies a single-precision 32-bit floating-point number.
● DOUBLE
32 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
The DOUBLE data type specifies a double-precision 64-bit floating-point number. The minimum value is 
-1.7976931348623157E308 and the maximum value is 1.7976931348623157E308 . The smallest positive 
DOUBLE value is 2.2250738585072014E-308 and the largest negative DOUBLE value is 
-2.2250738585072014E-308.
● FLOAT(n)
The FLOAT(n) data type specifies a 32-bit or 64-bit real number, where n specifies the number of 
significant bits and can range between 1 and 53.
If you use the FLOAT(n) data type, and n is smaller than 25, the 32-bit REAL data type is used instead. If n 
is greater than or equal to 25, or if n is not declared, the 64-bit DOUBLE data type is used.
Boolean Type
The BOOLEAN data type stores boolean values, which are TRUE, FALSE and UNKNOWN where UNKNOWN is 
a synonym of NULL.
CREATE TABLE TEST (A BOOLEAN); INSERT INTO TEST VALUES (TRUE);
INSERT INTO TEST VALUES (FALSE);
INSERT INTO TEST VALUES (UNKNOWN);
INSERT INTO TEST VALUES (NULL);
SELECT A "boolean" FROM TEST WHERE A = TRUE;
boolean TRUE
Note
When the client does not support a boolean type, it returns 1 for TRUE and 0 for FALSE instead.
Although predicates and boolean expressions can both have the same values (TRUE, FALSE, UNKNOWN), 
they are not the same. Therefore, you cannot use boolean type comparisons to compare predicates, or use 
predicates where boolean expressions should be used.
For example, the following statement does not work:
SELECT * FROM DUMMY WHERE ( A>B ) = ( C>D );
The following statement is the correct way to achieve the results desired from the statement above:
SELECT * FROM DUMMY WHERE case when ( A>B ) then TRUE when NOT ( A>B ) then FALSE else NULL end= 
 case when ( C>D ) then TRUE when NOT ( C>D ) then FALSE else NULL end; 
Character String Types
The character string data types are used to store values that contain character strings. While VARCHAR data 
types contain ASCII character strings, NVARCHAR are used for storing Unicode character strings.
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 33
Note
Collation expressions are not supported, and values of type string are compared using a binary comparison.
VARCHAR
The VARCHAR(n) data type specifies a variable-length character string, where n indicates the maximum 
length in bytes and is an integer between 1 and 5000. If the length is not specified, then the default is 1.
If the VARCHAR(n) data type is used in a DML query, for example CAST (A as VARCHAR(n)), <n> 
indicates the maximum length of the string in characters. SAP recommends using VARCHAR with ASCII 
characters based strings only. For data containing other characters, SAP recommends using the 
NVARCHAR data type instead.
NVARCHAR
The NVARCHAR(n) data type specifies a variable-length Unicode character set string, where <n> indicates 
the maximum length in characters and is an integer between 1 and 5000. If the length is not specified, then 
the default is 1.
ALPHANUM
The ALPHANUM(n) data type specifies a variable-length character string which contains alpha-numeric 
characters, where n indicates the maximum length and is an integer between 1 and 127.
Sorting among values of type ALPHANUM is performed in alpha-representation. In the case of a purely 
numeric value, this means that the value can be considered as an alpha value with leading zeros.
SHORTTEXT
The SHORTTEXT(n) data type specifies a variable-length character string which supports text search 
features and string search features. This data type can be defined for column tables, but not for row 
tables. This is not a standalone sql type. Selecting a SHORTTEXT(n) column yields a column of type 
NVARCHAR(n).
 <shorttext_type> ::= SHORTTEXT ( <unsigned_integer> ) <elem_list_shorttext> <elem_list_shorttext> ::= <fulltext_elem> [{, <fulltext_elem>}...] 
Binary Types
Binary types are used to store bytes of binary data.
A value of type binary can be converted to a value of type (N)VARCHAR if its size is smaller than or equal to 
8192. It can therefore be used like a value of type (N)VARCHAR except for full text search operations and 
numeric operations.
VARBINARY
The VARBINARY(n) data type is used to store binary data of a specified maximum length in bytes, where n 
indicates the maximum length and is an integer between 1 and 5000. If the length is not specified, then the 
default is 1.
34 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
Large Object (LOB) Types
LOB (large objects) data types, CLOB, NCLOB and BLOB, are used to store a large amount of data such as text 
documents and images. The maximum size for an LOB is 2 GB.
● BLOB
The BLOB data type is used to store large amounts of binary data.
● CLOB
The CLOB data type is used to store large amounts of ASCII character data.
● NCLOB
The NCLOB data type is used to store a large Unicode character object.
● TEXT
The TEXT data type enables text search features. This data type can be defined for column tables, but not 
for row tables. This is not a standalone SQL-Type. Selecting a TEXT column yields a column of type 
NCLOB.
Note
A value of type TEXT cannot be converted implicitly to a value of type (N)VARCHAR , and string 
functions (UPPER, LOWER and so on) cannot be applied directly to a value of type TEXT directly. 
Explicit conversion from a value of type TEXT to a value of type (N)VARCHAR is allowed however. String 
functions can therefore be applied to the converted value.
For columns of type TEXT, the LIKE predicate is not supported.
 <text_type> ::= TEXT <opt_fulltext_elem_list_text> <opt_fulltext_elem_list_text> ::= <fulltext_elem> [{, <fulltext_elem>}...] 
● BINTEXT
The BINTEXT data type is similar to data type TEXT and thus supports text search features, but it is 
possible to insert binary data. This data type can be defined for column tables, but not for row tables. This 
is not a standalone SQLType. Selecting a BINTEXT column yields a column of type NCLOB.
Note
For values of type BINTEXT, the same restrictions apply as for values of type TEXT.
 <bintext_type> ::= BINTEXT <opt_fulltext_elem_list_bintext> <opt_fulltext_elem_list_bintext> ::= <fulltext_elem> [{, <fulltext_elem>}...] 
Syntax rules common to TEXT, BINTEXT and SHORTTEXT
 <fulltext_elem> ::= LANGUAGE COLUMN <column_name> | LANGUAGE DETECTION ( <string_literal_list> ) | MIME TYPE COLUMN <column_name> | <change_tracking_elem> | FUZZY SEARCH INDEX <on_off> | PHRASE INDEX RATIO <index_ratio> | CONFIGURATION <string_literal> | SEARCH ONLY <on_off> | FAST PREPROCESS <on_off> | TEXT ANALYSIS <on_off> | MIME TYPE <string_literal> | TOKEN SEPARATORS <string_literal> <change_tracking_elem> ::= SYNC[HRONOUS] 
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 35| ASYNC[HRONOUS] [FLUSH [QUEUE] <flush_queue_elem>] <flush_queue_elem> ::= EVERY <integer_literal> MINUTES | AFTER <integer_literal> DOCUMENTS | EVERY <integer_literal> MINUTES OR AFTER 
<integer_literal> DOCUMENTS 
LOB types can be used to store and retrieve large amounts of data. Values of type CLOB and NCLOB can be 
converted to VARCHAR and NVARCHAR respectively. Values of type BLOB can be converted to VARBINARY. 
LOB types support the following operations:
● LENGTH() function for values of type CLOB/NCLOB/BLOB, which returns the LOB length in bytes.
● SUBSTR() function for values of type CLOB/NCLOB, which returns the substring of a (N)CLOB value.
● COALESCE() function
● LIKE and CONTAINS predicate for values of type CLOB/NCLOB
● IS NULL predicate for values of type CLOB/NCLOB/BLOB
The LOB types have the following restrictions:
● LOB columns cannot appear in ORDER BY or GROUP BY clauses.
● LOB columns cannot appear in FROM clauses as join predicates.
● LOB columns cannot appear in WHERE clauses as predicates other than LIKE (meaning that no 
comparison is allowed).
● LOB columns cannot appear in SELECT clauses as aggregate function arguments.
● LOB columns cannot appear in SELECT DISTINCT clauses.
● LOB columns cannot be used in set operations such as EXCEPT. UNION ALL is an exception.
● LOB columns cannot be used as primary keys.
● LOB columns cannot be used in CREATE INDEX statements.
● LOB columns cannot be used in statistics update statements.
Spatial Types
The spatial data types are used to store values that contain spatial data such as points, lines or polygons.
The following column types are supported in column tables only: ST_Point, ST_Geometry.
The column type ST_Point supports only the two-dimensional spatial data type ST_Point.
The column type ST_Geometry supports the following spatial data types: ST_CircularString, 
ST_GeometryCollection, ST_LineString, ST_MultiLineString, ST_MultiPoint, ST_MultiPolygon, ST_Point, 
ST_Polygon.
Note
For more information, refer to the SAP HANA Spatial Reference available in the SAP Help Portal at http://
help.sap.com/hana/.
36 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
http://help.sap.com/hana/
http://help.sap.com/hana/
Mapping between SQL Data Type and Column Store Data Type
Table 7:
SQL Type Column Store Type
Integer Types TINYINT, SMALLINT, INT CS_INT
BIGINT CS_FIXED(18,0)
Approximate Types REAL CS_FLOAT
DOUBLE CS_DOUBLE
FLOAT CS_DOUBLE
FLOAT(p) CS_FLOAT, CS_DOUBLE
Decimal Types DECIMAL CS_DECIMAL_FLOAT
DECIMAL(p,s) CS_FIXED(p-s,s)
SMALLDECIMAL CS_SDFLOAT
Boolean Type BOOLEAN CS_INT
Character Types VARCHAR CS_STRING
NVARCHAR CS_STRING
CLOB, NCLOB CS_STRING
ALPHANUM CS_ALPHANUM
Binary Types BLOB CS_RAW
VARBINARY CS_RAW
Date/Time Types DATE CS_DAYDATE
TIME CS_SECONDTIME
TIMESTAMP CS_LONGDATE
SECONDDATE CS_SECONDDATE
Data Type Conversion
This section describes the types of data type conversion allowed in the SAP HANA database.
● Explicit type conversion 
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 37
The type of an expression result, for example a field reference, a function on fields, or literals, can be 
converted using the following functions: CAST, TO_ALPHANUM, TO_BIGINT, TO_VARBINARY, TO_BLOB, 
TO_CLOB, TO_DATE, TO_DATS, TO_DECIMAL, TO_DOUBLE, TO_INTEGER, TO_INT, TO_NCLOB, 
TO_NVARCHAR, TO_REAL, TO_SECONDDATE, TO_SMALLINT, TO_TINYINT, TO_TIME, TO_TIMESTAMP, 
TO_VARCHAR.
● Implicit type conversion
When a given set of operand/argument types does not match what an operator/function expects, a type 
conversion is carried out by the SAP HANA database. This conversion only occurs if a relevant conversion 
is available and if it makes the operation/function executable. A comparison of BIGINT and VARCHAR is 
performed for example by implicitly converting VARCHAR to BIGINT. The entire explicit conversions can 
be used for implicit conversion except for the TIME and TIMESTAMP data types. TIME and TIMESTAMP 
can be converted reciprocally using TO_TIME(TIMESTAMP) and TO_TIMESTAMP(TIME).
● Examples 
Table 8: Implicit Type conversion Examples
Input Expression Transformed Expression with Implicit Conversion
BIGINT > VARCHAR BIGINT > BIGINT(VARCHAR)
BIGINT > DECIMAL DECIMAL(BIGINT) > DECIMAL
TIMESTAMP > DATE TIMESTAMP > TIMESTAMP(DATE)
DATE > TIME Error because there is no conversion available between 
DATE and TIME
In the tables below,
● Boxes with "OK" means data type conversions are allowed without any checks.
● Boxes with "CHK" means the data type can be converted if the data is valid for the target type.
● Boxes with "-" indicates that data type conversion is not allowed.
● Conversion types
○ Numeric types to Numeric types: Least significant digits are truncated toward 0. The most significant 
digits cannot be cut. Overflow errors occur if the converted value is incompatible with the target 
format.
 DECIMAL(10,2) -> BIGINT : 12345.67 -> 12345 
○ Character types to Numeric types: No truncation allowed, overflow error or invalid number error can 
be returned
 VARCHAR -> BIGINT : "12345.67" -> invalid number error returned VARCHAR -> TINYINT : "256" -> overflow error returned 
○ Date/Time types to Date/Time types: Truncated to the target type when source types are larger 
types, otherwise default value is added
 TIMESTAMP -> DATE : 2013-07-03 01:23:45 123456789 -> 2013-07-03 DATE -> TIMESTAMP : 2013-07-03 -> 2013-07-03 00:00:00 000000000
 TIMESTAMP -> SECONDDATE : 2013-07-03 23:59:59 7777777 -> 2013-07-03 
23:59:59 
38 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
○ Character types to Date/Time types: Truncated to the target type, invalid DATE, TIME of TIMESTAMP 
error can be returned
 VARCHAR -> DATE : "2013-07-03 00:00:00 000000000" -> 2013-07-03 
The rules shown are applicable to both implicit and explicit conversion except for Time to Timestamp 
conversion. Only explicit conversions are allowed for converting the Time data type to Timestamp using the 
TO_TIMESTAMP or CAST functions.
Table 9: Data type conversion table
Target/
Source
tinyi
nt
small
int
integ
er
bigin
t
decim
al
decim
al(<p>,
<s>)
small
decim
al
real doubl
e
varch
ar
nvarc
har
tinyi
nt
- OK OK OK OK OK OK OK OK OK OK
small
int
CHK - OK OK OK OK OK OK OK OK OK
integ
er
CHK CHK - OK OK OK OK OK OK OK OK
bigin
t
CHK CHK CHK - OK CHK CHK CHK OK OK OK
decim
al
CHK CHK CHK CHK - CHK CHK CHK OK OK OK
decim
al(<p>,
<s>)
CHK CHK CHK CHK CHK CHK CHK CHK CHK OK OK
small
decim
al
CHK CHK CHK CHK OK CHK - CHK CHK OK OK
real CHK CHK CHK CHK OK CHK CHK - OK OK OK
doubl
e
CHK CHK CHK CHK CHK CHK CHK CHK - OK OK
varch
ar
CHK CHK CHK CHK CHK CHK CHK CHK CHK - OK
nvarc
har
CHK CHK CHK CHK CHK CHK CHK CHK CHK OK -
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 39
Table 10: Data type conversion table
Target/
Source
time date seconddate timestamp varchar nvarchar
time - - - - OK OK
date - - OK OK OK OK
seconddate time date - timestamp OK OK
timestamp time date seconddate - OK OK
varchar CHK CHK CHK CHK - OK
nvarchar CHK CHK CHK CHK OK -
Table 11: Data type conversion table
Target/
Source
varbinary alphanum varchar nvarchar
varbinary - - - -
alphanum - - OK OK
varchar OK OK - OK
nvarchar OK OK OK -
Data Type Precedence 
This section describes the data type precedence implemented by the SAP HANA database. Data type 
precedence specifies that the data type with the lower precedence is converted to the data type with the 
higher precedence.
Table 12: Data Type Precedence
Highest TIMESTAMP
SECONDDATE
DATE
TIME
DOUBLE
REAL
DECIMAL
SMALLDECIMAL
40 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
BIGINT
INTEGER
SMALLINT
TINYINT
NCLOB
NVARCHAR
CLOB
VARCHAR
BLOB
Lowest VARBINARY
Typed Constant
A constant is a symbol that represents a specific fixed data value.
● Character string constant
A characterstring constant is enclosed in single quotation marks.
○ 'Brian'
○ '100'
Unicode string has a similar format to character string but is preceded by an N identifier (N stands for 
National Language in the SQL-92 standard). The N prefix must be uppercase.
○ N'abc'
 SELECT 'Brian' "character string 1", '100' "character string 2", N'abc' 
"unicode string" FROM DUMMY; character string 1, character string 2, unicode string
 Brian, 100, abc 
● Number constant
A number constant is represented by a string of numbers that are not enclosed in quotation marks. 
Numbers may contain a decimal point or scientific notation.
○ 123
○ 123.4
○ 1.234e2
A hexadecimal number constant is a string of hexadecimal numbers and has the prefix 0x.
○ 0x0abc
 SELECT 123 "integer", 123.4 "decimal1", 1.234e2 "decimal2", 0x0abc 
"hexadecimal" FROM DUMMY; integer, decimal1, decimal2, hexadecimal
 123, 123.4, 123.4, 2748 
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 41
● Binary string constant
A binary string has the prefix X and is a string of hexadecimal numbers that are enclosed in quotation 
marks.
○ X'00abcd'
○ x'dcba00'
 SELECT X'00abcd' "binary string 1", x'dcba00' "binary string 2" FROM DUMMY; binary string 1, binary string 2
 00ABCD, DCBA00 
● Date/Time/Timestamp constant
Date, Time and Timestamp each have the following prefixes:
○ date'2010-01-01'
○ time'11:00:00.001'
○ timestamp'2011-12-31 23:59:59'
 SELECT date'2010-01-01' "date", time'11:00:00.001' "time", timestamp'2011-12-31 
23:59:59' "timestamp" FROM DUMMY; date, time, timestamp
 2010-01-01, 11:00:00, 2011-12-31 23:59:59.0 
2.4 Reserved Words
Reserved words are words which have a special meaning to the SQL parser in the SAP HANA database and 
cannot be used as when defining an identifier.
The following list provides you with the current reserved words for the SAP HANA database. You can obtain 
this list by querying the RESERVED_KEYWORDS system view (SELECT * FROM RESERVED_KEYWORDS;).
In addition to the keywords listed below, avoid using the reserved keywords from the most recent ANSI SQL 
standard to ensure the compatibility of your SQL statements with future SAP HANA database developments. 
However, if you do use any of them, we recommend placing them in uppercase and delimiting them with 
double quotation marks to ensure compatibility.
Reserved words should not be used in SQL statements for schema object names. If necessary, you can work 
around this limitation by delimiting a table or column name with double quotation marks.
ALL ALTER
AS
BEFORE
BEGIN
BOTH
CASE
CHAR
CONDITION
CONNECT
CROSS
CUBE
CURRENT_CONNECTION
CURRENT_DATE
CURRENT_SCHEMA
CURRENT_TIME
CURRENT_TIMESTAMP
42 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
CURRENT_TRANSACTION_ISOLATION_LEVEL
CURRENT_USER
CURRENT_UTCDATE
CURRENT_UTCTIME
CURRENT_UTCTIMESTAMP
CURRVAL
CURSOR
DECLARE
DISTINCT
ELSE
ELSEIF
END
EXCEPT
EXCEPTION
EXEC
FALSE
FOR
FROM
FULL
GROUP
HAVING
IF
IN
INNER
INOUT
INTERSECT
INTO
IS
JOIN
LEADING
LEFT
LIMIT
LOOP
MINUS
NATURAL
NCHAR
NEXTVAL
NULL
ON
ORDER
OUT
PRIOR
RETURN
RETURNS
REVERSE
RIGHT
ROLLUP
ROWID
SELECT
SESSION_USER
SET
SQL
START
SYSUUID
TABLESAMPLE
TOP
TRAILING
TRUE
UNION
UNKNOWN
USING
UTCTIMESTAMP
VALUES
WHEN
WHERE
WHILE WITH
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 43
2.5 Operators
● Unary and Binary Operators [page 44]
● Operator Precedence [page 44]
● Arithmetic Operators [page 45]
● String Operators [page 46]
● Comparsion Operators [page 46]
● Logical Operators [page 47]
● Set Operators [page 47]
You can use operators to perform arithmetic operations in expressions. Operators can be used for calculation, 
value comparison or to assign values.
Unary and Binary Operators
Table 13: Unary and binary operators
Operator Operation Format Description
Unary A unary operator applies to 
one operand or a single value 
expression.
operator operand unary plus operator(+)
unary negation operator(-)
logical negation(NOT)
Binary Binary A binary operator ap­
plies to two operands or two 
value expressions.
operand1 operator operand2 multiplicative operators 
( *, / )
additive operators ( +,- )
comparison operators
( =,!=,<,>,<=,>=)
logical operators ( AND, OR )
Operator Precedence
An expression can use multiple operators. If the number of operators is greater than one, the SAP HANA 
database evaluates them in order of operator precedence. You can use parantheses to change the order of 
evaluation, as expressions contained within parentheses are always evaluated first.
If parentheses are not used, the precedence of the various operators is as indicated by the table below. The 
SAP HANA database evaluates operators with equal precedence from left to right within an expression.
44 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
Table 14: SQL operator precedence
Precedence Operator Operation
Highest () parentheses
+, - unary positive and negative operation
*, / multiplication, division
+, - addition, subtraction
|| concatenation
=, !=, <, >, <=, >=, IS NULL, LIKE, BE­
TWEEN
comparsion
NOT logical negation
AND conjunction
Lowest OR disjunction
Arithmetic Operators
You use arithmetic operators to perform mathematical operations, such as adding, subtracting, multiplying, 
dividing and negation of numeric values.
Table 15: Arithmetic operators
Operator Description
-<expression> Negation. If the expression is the NULL value, the result is 
NULL.
<expression> + <expression> Addition. If either expression is the NULL value, the result is 
NULL.
<expression> - <expression> Subtraction. If either expression is the NULL value, the re­
sult is NULL.
<expression> * <expression> Multiplication. If either expression is NULL, the result is 
NULL.
<expression> / <expression> Division. If either expression is NULL, or if the second ex­
pression is 0, an error is returned.
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 45
String Operators
A concatenation operator combines two items, such as strings, expressions or constants into one.
Table 16: Concatenation operators
Operator Description
<expression> || <expression> String concatenation (two vertical bars).
If either string is NULL, it returns NULL.
For VARCHAR or NVARCHAR type strings, leading or trailing spaces are retained. If either string is of data type 
NVARCHAR, the result has data type NVARCHAR and is limited to 5000 characters. The maximum length for 
VARCHAR concatenation is also limited to 5000 characters.
Comparsion Operators
Syntax:
<comparison_operation> ::= <expression1> <comparison_operator> <expression2> 
Table 17: Comparison operators
Operator Description Example
= Equal to SELECT * FROM students WHERE id = 
25;
> Greater than SELECT * FROM students WHERE id > 
25;
< Less than SELECT * FROM students WHERE id < 
25;
>= Greater than or equal to SELECT * FROM students WHERE id 
>= 25;
<= Less than or equal to SELECT * FROM students WHERE id 
<= 25;
!=, <> Not equal SELECT * FROM students WHERE id != 
25;
SELECT * FROM students WHERE id 
<> 25;
46 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
Logical Operators
Search conditions can be combined using AND or OR operators. You can also negate them using the NOT 
operator.
Table 18: Logical operators
Operator Syntax Description
AND WHERE condition1 AND condition2 When using AND, the combined condi­
tion is TRUE if both conditions are 
TRUE, FALSE if either condition is 
FALSE, and UNKNOWN otherwise.
OR WHERE condition1 OR condition2 When using OR, the combined condi­
tion is TRUE if either condition is TRUE, 
FALSE if both conditions are FALSE, 
and UNKNOWN otherwise.
NOT WHERE NOT condition The NOT operator is placed before a 
condition to negate the condition. The 
NOT condition is TRUE if condition is 
FALSE, FALSE if condition is TRUE, and 
UNKNOWN if condition is UNKNOWN.
Set Operators
See the Set Operators section of the SELECT statement.
Related Information
SELECT Statement(Data Manipulation) [page 452]
2.6 Expressions
● Case Expressions [page 48]
● Function Expressions [page 48]
● Aggregate Expressions [page 49]
● Subqueries in Expressions [page 51]
An expression is a clause that can be evaluated to return values.
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 47
Syntax
<expression> ::= <case_expression> | <function_expression> | <aggregate_expression> | (<expression> ) | ( <subquery> ) | - <expression> | <expression> <operator> <expression> | <variable_name> | <constant> | [<correlation_name>.]<column_name> 
Case Expressions
A case expression allows the user to use IF - THEN - ELSE logic without using procedures in SQL statements.
Syntax
<case_expression> ::= <simple_case_expression> | <search_case_expression> <simple_case_expression> ::= CASE <expression> WHEN <expression> THEN <expression> [{ WHEN <expression> THEN <expression>}…] [ ELSE <expression>] END <search_case_expression> > ::= CASE WHEN <condition> THEN <expression> [{ WHEN <condition> THEN <expression>}…] [ ELSE <expression>] END <condition> ::= <condition> OR <condition> | <condition> AND <condition> | NOT <condition> | ( <condition> ) | <predicate> 
If the expression following the CASE statement is equal to the expression following the WHEN statement, the 
expression following the THEN statement is returned. Otherwise, the expression following the ELSE statement 
is returned if it exists.
Function Expressions
SQL built-in functions can be used as expressions.
Syntax
 <function_expression> ::= <function_name> ( <expression> [{, <expression>}...] ) 
48 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
Aggregate Expressions
An aggregate expression uses an aggregate function to calculate a single value from the values of multiple 
rows in one or more columns.
Syntax
 <aggregate_expression> ::= COUNT(*) | COUNT ( DISTINCT <expression_list> ) | 
<agg_name> ( [ ALL | DISTINCT ] <expression> ) | STRING_AGG ( <expression> [, 
<delimiter>] [<aggregate_order_by_clause>]) <agg_name> ::= CORR | CORR_SPEARMAN | COUNT | MIN | MEDIAN | MAX | SUM | 
AVG | STDDEV | VAR | STDDEV_POP | VAR_POP | STDDEV_SAMP | VAR_SAMP <delimiter> ::= <string_constant> <aggregate_order_by_clause> ::= ORDER BY <expression> [ ASC | DESC ] 
[ NULLS FIRST | NULLS LAST]
You can specify sorted aggregate by the <aggregate_order_by_clause>. ASC sorts records in ascending 
order. DESC sorts records in descending order. By default for ascending ordering NULL values are returned 
first, and for descending they are returned last. You can override this behavior using NULLS FIRST or NULLS 
LAST to explicitly specify NULL value ordering.
Table 19:
Aggregate name Description
CORR Computes the Pearson product momentum correlation co­
efficient between two columns. See the CORR function for 
more details.
CORR_SPEARMAN Returns the Spearman's rank correlation coefficient of the 
values found in the corresponding rows of two colums. See 
the CORR_SPEARMAN function for more details.
COUNT Counts the number of rows returned by a query. COUNT(*) 
returns the number of rows, regardless of the value of those 
rows and including duplicate values. 
COUNT(<expression>) returns the number of non-NULL 
values for that expression returned by the query. 
COUNT(DISTINCT <expression_list>) returns the num­
ber of distinct values for that expressions returned by the 
query, excluding rows with all NULL values for that expres­
sion.
MIN Returns the minimum value of the expression.
MEDIAN Finds the statistical median of an input column with a nu­
meric data type. See the MEDIAN function for more infor­
mation.
MAX Returns the maximum value of the expression.
SUM Returns the sum of the expression.
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 49
Aggregate name Description
AVG Returns the arithmetical mean of the expression.
STDDEV Returns the standard deviation of the given expression as 
the square root of the VAR function.
STDDEV_POP Returns the standard deviation of the given expression as 
the square root of the VAR_POP function.
STDDEV_SAMP Returns the standard deviation of the given expression as 
the square root of the VAR_SAMP function.
VAR Returns the variance of the given expression as the square 
of the standard deviation.
VAR_POP Returns the population variance of expression as the sum of 
squares of the difference of <expression> from the mean 
of <expression>, divided by the number of rows remain­
ing.
VAR_SAMP Returns the sample variance of expression as the sum of 
squares of the difference of <expression> from the mean 
of <expression>, divided by the number of rows remaining 
minus 1 (one).This function is similar to VAR, the only differ­
ence is that it returns NULL when the number of rows is 1.
STRING_AGG Returns the concatenated string.
Table 20: Result type of numeric aggregate expressions
aggregat
e name
tinyint smallint integer bigint decimal(
p,s)
decimal real double
COUNT bigint bigint bigint bigint bigint bigint bigint bigint
MIN tinyint smallint integer bigint decimal(
p,s)
decimal real double
MAX tinyint smallint integer bigint decimal(
p,s)
decimal real double
SUM integer integer integer bigint decimal(
p',s) *
decimal real double
AVG decimal(
9,6)
decimal(
11,6)
decimal(
16,6)
decimal(
25,6)
decimal(
p,s)
decimal real double
STDDEV decimal(
9,6)
decimal(
11,6)
decimal(
16,6)
decimal(
25,6)
decimal(
p,s)
decimal real double
VAR decimal(
9,6)
decimal(
11,6)
decimal(
16,6)
decimal(
25,6)
decimal(
p,s)
decimal real double
* p' is determined by the following rule: p' = 18 when p <= 18, p' = 28 when p <= 28 and p' = 38 when p <= 38
50 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
The following statements returns the distinct count of a, b columns.
 CREATE TABLE T (A INT, B INT); INSERT INTO T VALUES (NULL, NULL);
 INSERT INTO T VALUES (1, NULL);
 INSERT INTO T VALUES (1, NULL);
 INSERT INTO T VALUES (NULL, 1);
 INSERT INTO T VALUES (1, 1);
 INSERT INTO T VALUES (1, 1);
 SELECT COUNT (DISTINCT A, B) AS DISTINCT_A_B FROM T;
 distinct_a_b 3
Subqueries in Expressions
A subquery is a SELECT statement enclosed in parentheses. The SELECT statement can contain no more than 
one select list item. When used as an expression, a scalar subquery can only return a zero or a single value.
Syntax
<scalar_subquery_expression> ::= (<subquery>)
In the SELECT list of the top level SELECT, or in the SET clause of an UPDATE statement, you can use a scalar 
subquery anywhere where you can use a column name. scalar_subquery cannot be used inside the GROUP BY 
clause however.
The following statement returns the number of employees in each department for example, grouped by 
department name:
 SELECT DepartmentName, COUNT(*), 'out of', (SELECT COUNT(*) FROM Employees)
 FROM Departments AS D, Employees AS E
 WHERE D.DepartmentID = E.DepartmentID GROUP BY DepartmentName;
Related Information
Predicates [page 51]
MEDIAN Function (Aggregate) [page 186]
CORR_SPEARMAN Function (Aggregate) [page 101]
CORR Function (Aggregate) [page 99]
2.7 Predicates
A predicate is specified by combining one or more expressions, or logical operators, and returns one of the 
following logical/truth values: TRUE, FALSE, or UNKNOWN.
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 51
Comparison Predicates [page 52]
BETWEEN Predicate [page 53]
Compares a value with a list of values within the specified range and returns true or false.
EXISTS Predicate [page 54]
Tests for the presence of a value in a set and returns either true or false.
IN Predicate [page 55]
Searches for a value in a set ofvalues and returns true or false.
LIKE Predicate [page 56]
Performs a comparison to see if a character string matches, or does not match, a specified pattern.
NULL Predicate [page 57]
Performs a comparison of the value of an expression with NULL. 
CONTAINS Predicate [page 58]
Matches a search string with the results of a subquery.
2.7.1 Comparison Predicates
Syntax
 <comparison_predicate> ::= <expression> { = | != | <> | > | < | >= | <= } [ ANY | SOME | ALL ] { <expression_list> | 
<subquery> } 
Syntax Elements
 <expression_list> ::= <expression> [{, <expression>}...] 
An <expression> is either a simple expression such as a character, a date or a number, or it can be a scalar 
subquery.
 ANY | SOME 
Specifies that the comparison returns true if the comparison of the <expression> and at least one value 
returned by the <subquery> or <expression_list> is true.
If the <subquery> or <expression_list> is empty, the comparison returns false.
 ALL 
Specifies that the comparison returns true if the comparison of all values returned by the <subquery> or 
<expression_list> is true. If the <subquery> or <expression_list> is empty, the comparison returns 
true.
52 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
Description
Two values are compared using comparison predicates, and the comparison returns true, false, or unknown.
Related Information
Expressions [page 47]
SELECT Statement (Data Manipulation) [page 452]
2.7.2 BETWEEN Predicate
Compares a value with a list of values within the specified range and returns true or false.
Syntax
<between_predicate> ::= <expression> [NOT] BETWEEN <lower_expression> AND 
<upper_expression>
Syntax Elements
expression
The value to search for in the specified list of values.
lower_expression
An expression setting the lower bound of the value list to compare <expression> to.
upper_expression
An expression setting the upper bound of the value list to compare <expression> to.
NOT
Inverts the operation of the BETWEEN predicate: returns TRUE when <expression> is not in the range of 
values specified between <lower_expression> and <upper_expression>, including equal to 
<lower_expression> and <upper_expression>.
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 53
Description
The range predicate returns true if <expression1> is within the range specified by <lower_expression> 
and <upper_expression>, and NOT is not specified.
Note
TRUE will only be returned if <lower_expression> has a value less than or equal to 
<upper_expression>.
An expression is either a simple expression such as a character, a date or a number, or it can be a scalar 
subquery.
Related Information
Expressions [page 47]
SELECT Statement (Data Manipulation) [page 452]
2.7.3 EXISTS Predicate
Tests for the presence of a value in a set and returns either true or false.
Syntax
<exists_predicate> ::= [NOT] EXISTS ( <subquery> )
Syntax Elements
NOT
Inverts the operation of the EXISTS predicate: true is returned when the <subquery> returns an empty 
result set and false is returned when the <subquery> returns a result set.
subquery
Specifies what to test for. For information on subqueries, see the SELECT statement.
54 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
Description
Returns true if the <subquery> returns a result set that is not empty and returns false if the <subquery> 
returns an empty result set.
Related Information
SELECT Statement (Data Manipulation) [page 452]
2.7.4 IN Predicate
Searches for a value in a set of values and returns true or false.
Syntax
<in_predicate> ::= <expression1> [NOT] IN { <expression_list> | <subquery> }
Syntax Elements
expression1
The value to search for in the set.
expression_list
Specifies one or more expressions in which to to search for <expression1>.
<expression_list> ::= <expression> [{, <expression>}...]
subquery
Specifies a subquery in which to to search for <expression1>.
NOT
Inverts the operation of the IN predicate: true is returned if <expression1> is not found in the specified 
set.
Description
True will be returned if the value of <expression1> is found in the <expression_list> or <subquery>.
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 55
An expression is either a simple expression such as a character, a date or a number, or it can be a scalar 
subquery.
Related Information
SELECT Statement (Data Manipulation) [page 452]
Expressions [page 47]
Expressions [page 47]
2.7.5 LIKE Predicate
Performs a comparison to see if a character string matches, or does not match, a specified pattern.
Syntax
<like_predicate> ::= <source_expression> [NOT] LIKE <pattern_expression> [ESCAPE <escape_expression>]
Syntax Elements
source_expression Specifies the character string in which to search for <pattern_expression>. 
Specifying NOTE inverts the operation of the LIKE predicate.
pattern_expression Specifies the pattern to search for in <source_expression>.
escape_expression
Specifies the escape character used in comparison string <pattern_expression>, if any.
Description
The LIKE predicate performs string comparisons: <source_expression> is tested for the pattern contained 
in <pattern_expression>. LIKE returns true if the value of <pattern_expression> is found in 
<source_expression> (assuming NOT is not set).
Wildcard characters ( % ) and ( _ ) can be used in <pattern_expression>. The percentage sign (%) 
wildcard matches zero or more characters. The underscore (_) wildcard matches exactly one character.
To match a percentage sign or underscore with the LIKE predicate, an escape character must be placed in 
front of the wildcard character. Use ESCAPE <escape_expression> to specify the escape character you are 
56 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
using. For example, LIKE 'data_%' ESCAPE '_' matches the string data%, and LIKE 'data__%' 
ESCAPE '_' (that is, two underscores, followed by a percent sign) matches a string that starts with 'data_'
The underscore ( _ ) and percentage sign ( % ) are ASCII characters.
An expression is either a simple expression such as a character, a date or a number, or it can be a scalar 
subquery.
Related Information
Expressions [page 47]
SELECT Statement (Data Manipulation) [page 452]
2.7.6 NULL Predicate
Performs a comparison of the value of an expression with NULL.
Syntax
<null_predicate> ::= <expression> IS [NOT] NULL
Syntax Elements
expression
An expression is either a simple expression such as a character, a date or a number, or it can be a scalar 
subquery.
IS NULL
Returns true if the value of <expression> is NULL.
IS NOT NULL
Returns true if the value of <expression> is not NULL.
Description
Performs a comparison of the value of an expression with NULL.
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 57
Related Information
Expressions [page 47]
SELECT Statement (Data Manipulation) [page 452]
2.7.7 CONTAINS Predicate
Matches a search string with the results of a subquery.
Syntax
<contains_predicate> ::= CONTAINS ( <contains_columns> , <search_string> [, 
<search_specifier>] )
Syntax Elements
contains_columns
Specifies the columns to search.
<contains_columns> ::= * | <column_name> | ( <column_list> ) <column_list> ::= ( <column_name> [,<..>] )
search_string
Specifies the string to search for in <contains_columns>, using the freestyle search string format (for 
example, Peter "Palo Alto" OR Berlin -"SAP LABS").
<search_string> ::= <string_const>
search_specifier
Defines specifications on the type of matching to perform. If <search_specifier> is not specified, 
EXACT is the default.
<search_specifier> ::= [<search_type>] [<opt_search_specifier2_list>] | <search_specifier2_list> <opt_search_specifier2_list> ::= (empty, nothing specified) | <search_specifier2_list> <search_type> ::= 
58 P U B L I C
SAP HANA SQL and System Views ReferenceSQL Reference
 <exact_search> | <fuzzy_search> | <linguistic_search> <search_specifier2_list> ::= <search_specifier2> | <search_specifier2_list> , <search_specifier2> <search_specifier2> ::= <weights> | <language> <exact_search> ::= EXACT | EXACT ( <additional_params> ) <fuzzy_search> ::= FUZZY | FUZZY ( <fuzzy_params> ) | FUZZY ( <fuzzy_params_list> ) <fuzzy_params_list> ::= ( <fuzzy_params> ) , <fuzzy_params_list2> <fuzzy_params_list2> ::= ( <fuzzy_params> ) | <fuzzy_params_list2> , ( <fuzzy_params> ) <fuzzy_params> ::= <float_const> | <float_const> , <additional_params> | NULL , <additional_params> <linguistic_search> ::= LINGUISTIC | LINGUISTIC ( <additional_params> ) <weights> ::= WEIGHT ( <float_const_list> ) <language> ::= LANGUAGE ( <string_const> ) <additional_params> ::= <string_const>
FUZZINESSTHRESHOLD
If the FUZZINESSTHRESHOLD parameter is defined in a join view, and <search_specifier> is not 
specified, a fuzzy search is performed using the fuzziness threshold defined in the view.
EXACT
Specifies to match the term or phrase exactly.
EXACT returns records where exact matches of the search terms are found in the search attributes.
FUZZY
Specifies to return matches that are similar to <search_string> (spelling errors are ignored to a 
certain extent for example).
Optionally, you can control the degree of fuzziness using parameters. For example, <float_const> 
specifies the degree of fuzziness expressed as value between 0.0 and 1.0, where 0.0 is very fuzzy, and 
1.0 is exact. If <float_const> is not specified, 0.8 is the default. It is possible to override this default 
by defining parameter FUZZINESSTHRESHOLD supported by columnstore join views.
When FUZZY is specified with more than one <additional_params> parameter, the number of 
<float_const> / <additional_params> pairs must match the number of column names in the 
column list.
additional_params
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 59
Specifies additional search parameters in the format of key-value pairs.
WEIGHT
Specifies weightings for the columns. If a weights list is specified, it must be the same size as the 
number of (expanded) columns in <contains_columns>.
LANGUAGE
Specifies the language characteristics to apply when searching. LANGUAGE is used during 
preprocessing of the search string and as a pre-search filter. Only documents which match the search 
string and the language specified are returned.
LINGUISTIC
Specifies to perform a linguistic search. A linguistic search finds all words that have the same word 
stem as the search term. It also finds all words for which the search term is the word stem. For 
example, searching for 'cats' also returns records that contain 'cat'. You can only perform linguistic 
searches on columns that contain text, and for which the FAST_PREPROCESS parameter is specified 
as OFF.
Remarks
The CONTAINS predicate only works on column store tables (simple tables and join views).
If there are multiple CONTAINS predicates specified in the WHERE clause of a SELECT statement, only one of 
the predicates can consist of more than one column in the <contains_columns> list.
There are many more search parameters (as suggested previously by <additional_params>) and examples 
for full-text search using the CONTAINS predicate found in the SAP HANA Search Developer Guide provided 
with the SAP HANA Advanced Data Processing option. Be aware that you need additional licenses for optional 
components such as the SAP HANA Advanced Data Processing option.
Examples
The following example performs a fuzzy search for the term car, and returns the rows that match (Blue 
baseball cap, and Red car), in descending order by score:
CREATE SCHEMA mySchema; CREATE COLUMN TABLE mySchema.SEARCH_TEXT( Content TEXT FAST PREPROCESS OFF, 
Descrip TEXT FAST PREPROCESS OFF, Comment TEXT FAST PREPROCESS OFF ); 
INSERT INTO mySchema.SEARCH_TEXT VALUES( 'Blue baseball cap', 'Vintage', 'Out of 
stock'); 
INSERT INTO mySchema.SEARCH_TEXT VALUES( 'Red car', 'Vintage', 'Taking orders' ); 
INSERT INTO mySchema.SEARCH_TEXT VALUES( 'Bluish sky', 'Retro', 'Discontinued' );
SELECT SCORE() AS SCORE,* 
 FROM mySchema.SEARCH_TEXT 
 WHERE CONTAINS(CONTENT,'cap',FUZZY(0.0)) ORDER BY SCORE DESC;
Changing SELECT statement to set the FUZZY parameter to 0.9, the equivalent of making the query less 
fuzzy or more exact, returns only the Blue baseball cap row:
SELECT SCORE() AS SCORE,* 
60 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
 FROM mySchema.SEARCH_TEXT 
 WHERE CONTAINS(CONTENT,'cap',FUZZY(0.9)) ORDER BY SCORE DESC
Using the table created in the previous example, the following statement performs an exact term search for 
either cap or sky, and returns the Blue baseball cap and Bluish sky rows:
SELECT * FROM mySchema.SEARCH_TEXT WHERE CONTAINS(CONTENT,'cap OR sky');
The following statement performs an exact phrase search for either baseball cap and returns the Blue 
baseball cap row:
SELECT * FROM mySchema.SEARCH_TEXT WHERE CONTAINS(CONTENT, '"baseball cap"');
The following statement shows a LINGUISTIC search. Searching for take returns the row that contains 
Taking orders because 'take' is the stem word for 'taking' in English.
SELECT * FROM MySchema.SEARCH_TEXT WHERE CONTAINS (*, 'take', LINGUISTIC);
The following statements demonstrate ways to perform a freestyle search over multiple columns. The second 
example is particularly helpful when you want to search across an entire table without listing the rows.
SELECT * FROM mySchema.SEARCH_TEXT WHERE CONTAINS (( Content, Descrip ), 
'vintage'); SELECT * FROM mySchema.SEARCH_TEXT WHERE CONTAINS (*, 'vintage');
2.8 SQL Functions
Introduction
This chapter describes SQL Functions that are provided by SAP HANA database.
Note
Analytic Functions can be found in the sections Aggregate Functions and Window Functions.
Alphabetical List Of Functions [page 62]
Aggregate Functions [page 274]
Aggregate functions are analytic functions that calculate an aggregate value based on a group of rows.
Data Type Conversion Functions [page 274]
Data type conversion functions convert data from one data type to another data type.
Datetime Functions [page 275]
Date and time functions perform operations on date and time data types or return date or time 
information.
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 61
Fulltext Functions [page 276]
Fulltext functions perform operations on data that has a fulltext index.
Hierarchy Functions [page 277]
Hierarchy functions allow you to work with hierarchical data such as tables with rows arranged in a tree 
or directed graph.
Miscellaneous Functions [page 278]
SAP HANA supports many functions that return system values and perform various operations on 
values, expressions, and return values of other functions.
Numeric Functions [page 279]
Numeric functions perform mathematical operations on numerical data types or return numeric 
information.
Series Data Functions [page 280]
Series data functions provide special functionality for series data and series tables.
String Functions [page 281]
String functions perform extraction and manipulation on strings, or return information about strings.
Security Functions [page 282]
Security functions provide special functionality for security purposes.
Window Functions [page 282]
Window functions allow you to perform analytic operations over a set of input rows.
2.8.1 Alphabetical List Of Functions
2.8.1.1 ABAP_UPPER Function (String)
Converts all characters in the specified string to uppercase.
Syntax
ABAP_UPPER (<str>)
Description
Converts all characters in string <str> to uppercase.
62 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
Example
The following example converts the given string to uppercase and returns the value ANT:
SELECT ABAP_UPPER ('Ant') "uppercase" FROM DUMMY;
2.8.1.2 ABAP_LOWERFunction (String)
Converts all characters in a specified string to lowercase.
Syntax
ABAP_LOWER(<str>)
Description
Converts all characters in string <str> to lowercase.
Example
The following example converts the given string to lowercase and returns the value ant:
SELECT ABAP_LOWER ('AnT') "lower" FROM DUMMY;
2.8.1.3 ABS Function (Numeric)
Returns the absolute value of a numeric argument.
Syntax
ABS (<n>)
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 63
Description
Returns the absolute value of the numeric argument <n>.
Example
The following example returns the value 1 for "absolute":
SELECT ABS (-1) "absolute" FROM DUMMY;
2.8.1.4 ACOS Function (Numeric)
Returns the arc-cosine, in radians, of a numeric argument between -1 and 1.
Syntax
ACOS (n)
Description
Returns the arc-cosine, in radians, of the numeric argument n between -1 and 1.
Example
The following example returns the value 1.0471975511965979 for "acos":
SELECT ACOS (0.5) "acos" FROM DUMMY;
64 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
2.8.1.5 ADD_DAYS Function (Datetime)
Computes the specified date plus the specified days.
Syntax
ADD_DAYS (<d>, <n>)
Description
Computes the date d plus n days.
Example
The following example increments the date value 2009-12-05 by 30 days, and returns the value 2010-01-04:
SELECT ADD_DAYS (TO_DATE ('2009-12-05', 'YYYY-MM-DD'), 30) "add days" FROM DUMMY;
2.8.1.6 ADD_MONTHS Function (Datetime)
Computes the specified date plus the specified number of months.
Syntax
ADD_MONTHS (<d>, <n>)
Description
Computes the date <d> plus <n> months.
To compute the date so that the output date is set to the last day of the month when the input date is the last 
day of the month, use the ADD_MONTHS_LAST function.
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 65
The parameter <d> must be implicitly or explicitly converted to one of the following SQL data types:
● DATE
● TIMESTAMP
● SECONDDATE
The SQL data type of the output parameters is the same as the SQL data type of the input parameters. For 
example, ADD_MONTHS_LAST(DATE) returns a date, while ADD_MONTHS_LAST(TIMESTAMP) returns a 
timestamp.
Example
The following example increments the date 2009-12-05 by one month, and returns the value 2010-01-05:
SELECT ADD_MONTHS (TO_DATE ('2009-12-05', 'YYYY-MM-DD'), 1) "add months" FROM 
DUMMY;
2.8.1.7 ADD_MONTHS_LAST Function (Datetime)
Computes the specified date plus the specified number of months, with the output date being the last day of 
the month if the input date is the last day of the month, even if those two dates differ.
Syntax
ADD_MONTHS_LAST (<d>, <n>)
Description
Computes the date <d> plus <n> months. If the input date is the last day of the input month, then the output 
date is set to the last day of the output month.
To compute the date plus months without using the last day of the month functionality, use the ADD_MONTHS 
function.
The parameter <d> must be implicitly or explicitly converted to one of the following SQL data types:
● DATE
● TIMESTAMP
● SECONDDATE
The SQL data type of the output parameters is the same as the SQL data type of the input parameters. For 
example, ADD_MONTHS_LAST(DATE) returns a date, while ADD_MONTHS_LAST(TIMESTAMP) returns a 
timestamp.
66 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
Example
The following example increments the date 2009-02-28 (the last day in February), by one month, and returns 
the value 2009-03-30, (the last day of March).
SELECT ADD_MONTHS_LAST (TO_DATE ('2009-02-28', 'YYYY-MM-DD'), 1) "add months 
last" FROM DUMMY;
2.8.1.8 ADD_SECONDS Function (Datetime)
Computes the specified time plus the specified seconds.
Syntax
ADD_SECONDS (<t>, <n>)
Description
Computes the time <t> plus <n> seconds.
Example
The example increments the TIMESTAMP 2012-01-01 23:30:45 by 60*30 seconds, and returns the value 
2012-01-02 00:00:45.0:
SELECT ADD_SECONDS (TO_TIMESTAMP ('2012-01-01 23:30:45'), 60*30) "add seconds" 
FROM DUMMY;
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 67
2.8.1.9 ADD_WORKDAYS Function (Datetime)
Computes a date by adding a number of workdays to a starting date.
Syntax
ADD_WORKDAYS (<factory_calendar_id>, <start_date>, <workdays> [, 
<source_schema>])
Syntax Elements
<factory_calendar_id> ::= <string_literal>
The ID of a factory calendar in the factory calendar table TFACS.
<start_date> ::= <string_literal> | <DATE>
The start date where work days will be added. You can use either a DATE type or a date format string (for 
example '20140101' or '2014-01-01') for this parameter.
<workdays> ::= <signed_integer>
The number of working days to be added to the starting date.
<source_schema> ::= <string_literal>
The schema where the factory calendar table TFACS is located.
This parameter can be omitted if the schema of the TFACS is the same as the current schema.
Return Type
DATE
Description
In order to use the ADD_WORKDAYS function, a factory calendar table TFACS must be available in the SAP 
HANA database. In SAP BW, SAP CRM, and SAP ERP systems running on a SAP HANA database the table 
TFACS is located in the ABAP schema SAP<SID>. For other SAP HANA databases the TFACS table can be 
replicated from an SAP Business Suite system.
68 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
Computes a date by adding a number of workdays to a starting date.
When <workdays> is positive the resultant calculated date is the next working day after the period defined by 
the number of <workdays>.
When <workdays> is negative the resultant calculated date is the previous working day before the period 
defined by the number of <workdays>.
Examples
For the examples below we are assuming that the following TFACS table for the month of January 2014 is 
used. However, the content in your TFACS may vary.
Table 21:
TFACS bitfield Day of the month Reason for not working
0 1 Public Holiday
1 2
1 3
0 4 Weekend
0 5 Weekend
0 6 Public Holiday
1 7
1 8
1 9
1 10
0 11 Weekend
0 12 Weekend
1 13
1 14
1 15
1 16
1 17
0 18 Weekend
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 69
TFACS bitfield Day of the month Reason for not working
0 19 Weekend
1 20
1 21
1 22
1 23
1 24
0 25 Weekend
0 26 Weekend
1 27
1 28
1 29
1 30
1 31
Example 1 - Simple positive workdays
The following example returns the value 10.01.2014:
SELECT ADD_WORKDAYS('01', '2014-01-09', 1, 'FCTEST') "result date" FROM DUMMY;
From this result you can see that the single workday was added to the start date of the 9th producing a 
resultant day of the 10th
Example 2 - Simple negative workdays
The following example returns the value 09.01.2014:
SELECT ADD_WORKDAYS('01', '2014-01-10', -1, 'FCTEST') "result date" FROM DUMMY;
From this result you can see that the 10th was considered to be the working day producing a final result of the 
9th.
Example 3 - Positive workdays input showing result after a non-working weekend period.
The following example returns the value 20.01.2014:
SELECT ADD_WORKDAYS('01', '2014-01-17', 1, 'FCTEST') "result date" FROM DUMMY;
From this result you can see that the single workday was added to the start date of the 17th. This produced a 
resultant day of the 20th which allowed for the non-working period at the weekend.
70 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
Example 4 - Negative workdays input showing result after a non-working weekend period.
The following example returns the value 17.01.2014:
SELECT ADD_WORKDAYS('01', '2014-01-20', -1, 'FCTEST') "result date" FROM DUMMY;
From this result you can see that the day of the 20th was considered to be the working day producing a result 
of the 17th. This result takes into account the non-working time at the weekend.
Example 5 - Complex example
The following example returns the value 27.01.2014:
SELECT ADD_WORKDAYS('01', '2014-01-01', 16, 'FCTEST')"result date" FROM DUMMY;
Here the statement added 16 working days to the start date of the 1st. The system takes into account the 
weekends (4th, 5th, 11th, 12th, 18th and 19th) and public holidays (1st and 6th) in the working period, which 
would give the last working day the 24th. The system then returned the next possible working day after this 
which would be the 27th.
Example 6 - Using a table for input
The following example returns the values 4.02.2014, 14.05.2014, 05.08.2014, and 30.10.2014:
CREATE SCHEMA SAPABC; SET SCHEMA "SAPABC";
 CREATE TABLE MY_DATES (FCID NVARCHAR(2), STARTDATE DATE, DURATION INTEGER);
 INSERT INTO MY_DATES VALUES ('01', '2014-01-01', 30);
 INSERT INTO MY_DATES VALUES ('01', '2014-04-01', 28);
 INSERT INTO MY_DATES VALUES ('01', '2014-07-01', 25);
 INSERT INTO MY_DATES VALUES ('01', '2014-10-01', 20);
 SELECT ADD_WORKDAYS(FCID, STARTDATE, DURATION) "shipment date" FROM MY_DATES;
Related Information
Data Types [page 26]
WORKDAYS_BETWEEN Function (Datetime) [page 267]
2.8.1.10 ADD_YEARS Function (Datetime)
Computes the specified date plus the specified years.
Syntax
ADD_YEARS (<d>, <n>)
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 71
Description
Computes the date d plus n years.
Example
The following example increments the specified date value 2009-12-05 by 1 year, and returns the value 
2010-12-05:
SELECT ADD_YEARS (TO_DATE ('2009-12-05', 'YYYY-MM-DD'), 1) "add years" FROM 
DUMMY;
2.8.1.11 ASCII Function (String)
Returns the integer ASCII value of the first byte in a specified string.
Syntax
ASCII(<c>)
Description
Returns the integer ASCII value of the first byte in a string <c>.
Example
This example converts the first character of the string Ant into an numeric ASCII value and returns the value 
65:
SELECT ASCII('Ant') "ascii" FROM DUMMY;
72 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
2.8.1.12 ASIN Function (Numeric)
Returns the arc-sine, in radians, of a numeric argument.
Syntax
ASIN (<n>)
Description
Returns the arc-sine, in radians, of the numeric argument <n> between -1 and 1.
Example
The following example returns the value 0.5235987755982989 for "asin":
SELECT ASIN (0.5) "asin" FROM DUMMY;
2.8.1.13 ATAN Function (Numeric)
Returns the arc-tangent, in radians, of a numeric argument.
Syntax
ATAN (<n>)
Description
Returns the arc-tangent, in radians, of the numeric argument <n>. The range of <n> is unlimited.
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 73
Example
The following example returns the value 0.4636476090008061 for "atan":
SELECT ATAN (0.5) "atan" FROM DUMMY;
2.8.1.14 ATAN2 Function (Numeric)
Returns the arc-tangent, in radians, of the ratio of two numbers.
Syntax
ATAN2 (<n>, <m>)
Description
Returns the arc-tangent, in radians, of the ratio of two numbers <n> and <m>.
This function returns the same result as the ATAN (<n>, <m>) function.
Example
The following example returns the value 0.4636476090008061 for "atan2":
SELECT ATAN2 (1.0, 2.0) "atan2" FROM DUMMY;
2.8.1.15 AUTO_CORR Function (Aggregate)
Computes all autocorrelation coefficients for a given input column and returns an array of values.
Syntax
AUTO_CORR(<column>, <maxTimeLag> {SERIES(...) | ORDER BY <col1>, ...})
74 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
Description
Computes all autocorrelation coefficients for a given input column and returns an array of values.
The time frame size is limited by the maxTimeLag parameter. This parameter must be a positive integer. The 
result size is the minimum of maxTimeLag and column size - 2 for dense series data.
Pairs that contain at least one null are removed. Even though AUTO_CORR can handle null input values, it is 
highly recommended to replace null values first (e.g. by using LINEAR_APPROX), which allows for much faster 
processing.
Input column values can be of any numeric type.
The output is empty if there are fewer than two rows.
The ORDER BY column, which determines the order of the input, must not contain any null values, nor any 
duplicates.
The SERIES definition can only be used with an equidistant series.
Examples
Example - Autocorrelation of dense series data
The example below returns [0.285714,-0.351351,-0.5625,-0.25,1,1,1,1].
CREATE COLUMN TABLE correlationTable (TS_ID VARCHAR(10), DATE DAYDATE, VALUE 
DOUBLE); INSERT INTO correlationTable VALUES ('A', '2014-10-01', 1);
INSERT INTO correlationTable VALUES ('A', '2014-10-02', 2);
INSERT INTO correlationTable VALUES ('A', '2014-10-03', 3);
INSERT INTO correlationTable VALUES ('A', '2014-10-04', 4);
INSERT INTO correlationTable VALUES ('A', '2014-10-05', 5);
INSERT INTO correlationTable VALUES ('A', '2014-10-06', 1);
INSERT INTO correlationTable VALUES ('A', '2014-10-07', 2);
INSERT INTO correlationTable VALUES ('A', '2014-10-08', 3);
INSERT INTO correlationTable VALUES ('A', '2014-10-09', 4);
INSERT INTO correlationTable VALUES ('A', '2014-10-10', 5);
SELECT TS_ID, AUTO_CORR(VALUE, 8 SERIES (PERIOD FOR SERIES(DATE)
 EQUIDISTANT INCREMENT BY INTERVAL 1 DAY MISSING ELEMENTS NOT ALLOWED))
 FROM correlationTable GROUP BY TS_ID ORDER BY TS_ID;
Example - Autocorrelation of sparse series data without considering missing entries
The example below returns [1,1,1,1,1].
CREATE COLUMN TABLE correlationTable (ts_id VARCHAR(20), date DAYDATE, val 
DOUBLE); INSERT INTO correlationTable VALUES ('A', '2014-10-01', 1);
INSERT INTO correlationTable VALUES ('A', '2014-10-02', 2);
INSERT INTO correlationTable VALUES ('A', '2014-10-04', 3);
INSERT INTO correlationTable VALUES ('A', '2014-10-07', 4);
INSERT INTO correlationTable VALUES ('A', '2014-10-11', 5);
INSERT INTO correlationTable VALUES ('A', '2014-10-21', 6);
INSERT INTO correlationTable VALUES ('A', '2014-10-22', 7);
SELECT ts_id, AUTO_CORR(val, 999 SERIES (PERIOD FOR SERIES(DATE)
 EQUIDISTANT INCREMENT BY INTERVAL 1 DAY MISSING ELEMENTS NOT ALLOWED))
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 75
 FROM correlationTable GROUP BY ts_id ORDER BY ts_id;
The correlationTable has missing entries, such as '2014-10-03', but the WITHIN GROUP clause considers the 
series to be equidistant with one day intervals, where missing elements are not allowed.
Since the series data is assumed to be dense, the autocorrelation of the data set [1..7] is calculated.
Example - Autocorrelation of sparse series data considering the missing entries
The example below returns [1.0, null, 1.0, null, null, null, null, null, null, * 1.0, 
null, null, null, null, null, null, null, null, null, 1.0].
CREATE COLUMN TABLE correlationTable (ts_id VARCHAR(20), date DAYDATE, val 
DOUBLE); INSERT INTO correlationTable VALUES ('A', '2014-10-01', 1);
INSERT INTO correlationTable VALUES ('A', '2014-10-02', 2);
INSERT INTO correlationTable VALUES ('A', '2014-10-04', 3);
INSERT INTO correlationTable VALUES ('A', '2014-10-07', 4);
INSERT INTO correlationTable VALUES ('A', '2014-10-11', 5);
INSERT INTO correlationTable VALUES ('A', '2014-10-21', 6);
INSERT INTO correlationTable VALUES ('A', '2014-10-22', 7);
SELECT ts_id, AUTO_CORR(val, 999 SERIES (PERIOD FOR SERIES(DATE)
 EQUIDISTANT INCREMENT BY INTERVAL 1 DAY MISSING ELEMENTS ALLOWED))
 FROM correlationTable GROUP BY ts_id ORDER BY ts_id;
Autocorrelation works as if there were nulls instead of the missing elements in the column.
2.8.1.16 BINTOHEX Function (String)
Converts a binary value to a hexadecimal value as a VARCHAR data type.
Syntax
BINTOHEX (<expression>)
Description
Converts a binary value to a hexadecimal value as a VARCHAR data type. The input value is converted to a 
binary value first if it is not a binary value.
76 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
Example
The following example converts the binary value AB to a hexadecimal VARCHAR value 4142:
SELECT BINTOHEX('AB') "bintohex" FROM DUMMY;
2.8.1.17 BINTONHEX Function (String)Converts a binary value to a hexadecimal value as an NVARCHAR data type.
Syntax
BINTONHEX (<expression>)
Description
Converts a binary value to a hexadecimal value as an NVARCHAR data type. The input value is converted to a 
binary value first if it is not a binary value.
Example
The following example converts the binary value AB to a hexadecimal NVARCHAR value 4142.
SELECT BINTONHEX('AB') "bintonhex" FROM DUMMY; 
2.8.1.18 BINTOSTR Function (String)
Converts a VARBINARY string into a character string.
Syntax
BINTOSTR (<bstring>)
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 77
Description
Converts a VARBINARY string <bstring> into a character string with CESU-8 encoding.
Example
This example converts the VARBINARY string 416E74 into a CESU-8 encoded character string, and returns 
the value Ant:
SELECT BINTOSTR ('416E74') "bintostr" FROM DUMMY;
2.8.1.19 BITAND Function (Numeric)
Performs an AND operation on the bits of two arguments.
Syntax
BITAND (<n>, <m>)
Description
Performs an AND operation on the bits of the arguments <n> and <m>, where <n> and <m> must be non-
negative INTEGER or VARBINARY values. The BITAND function returns a result along the argument's type.
Example
The following example returns the value 123 for "bitand":
SELECT BITAND (255, 123) "bitand" FROM DUMMY;
78 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
2.8.1.20 BITCOUNT Function (Numeric)
Counts the number of set bits of an expression.
Syntax
BITCOUNT (<expression>)
Description
Counts the number of set bits of the argument <expression> where <expression> must be an INTEGER or 
a VARBINARY value.
The BITCOUNT function returns an INTEGER value.
Example
The following example counts the bits for 255, and returns the value 8:
SELECT BITCOUNT (255) "bitcount" FROM DUMMY;
2.8.1.21 BITNOT Function (Numeric)
Performs a bitwise NOT operation on the bits of an expression.
Syntax
BITNOT (<expression>)
Description
Performs a bitwise NOT operation on the bits of the argument <expression>, where <expression> must be 
an INTEGER value.
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 79
The BITNOT function returns a result along the argument's type.
Example
The following example performs a BITNOT operation on 255, and returns the value -256 for "bitnot":
SELECT BITNOT (255) "bitnot" FROM DUMMY;
2.8.1.22 BITOR Function (Numeric)
This function performs an OR operation on the bits of two arguments.
Syntax
BITOR (<expression1>, <expression2>)
Syntax Elements
Both <expression1> and <expression2> are arguments for the bitwise OR operation and must be non-
negative INTEGER or VARBINARY values.
Description
This function performs an OR operation on the bits of the arguments <expression1> and <expression2>.
The BITOR function returns a result along argument's type.
Example
The following example performs a bitwise OR for the arguments 255 and 123, and returns the value 255 for 
"bitor":
SELECT BITOR (255, 123) "bitor" FROM DUMMY;
80 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
2.8.1.23 BITSET Function (Numeric)
Sets a specific number of bits to 1 in a target number from a specified 1-based index position.
Syntax
BITSET (<target_num>, <start_bit>, <num_to_set>)
Syntax Elements
<target_num> ::= <string_literal>
The VARBINARY number where the bits are to be set.
<start_bit> ::= <unsigned_integer>
A 1-based index position where the first bit is to be set.
<num_to_set> ::= <unsigned_integer>
The number of bits to be set in the target number.
Description
Sets <num_to_set> bits to 1 in <target_num> from the <start_bit> position.
Example
The following example returns the value E000 for "bitset":
SELECT BITSET ('0000', 1, 3) "bitset" FROM DUMMY;
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 81
2.8.1.24 BITUNSET Function (Numeric)
Sets a specified number of bits to 0 in a target number from a specified 1-based index position.
Syntax
BITUNSET (<target_num>, <start_bit>, <num_to_unset>)
Syntax Elements
<target_num> ::= <string_literal>
The VARBINARY number where the bits are to be unset.
<start_bit> ::= <unsigned_integer>
A 1-based index position where the first bit is to be unset.
<num_to_unset> ::= <unsigned_integer>
The number of bits to be unset in the target number.
Description
Sets <num_to_unset> bits to 0 in <target_num> from the <start_bit> position.
Example
The following example returns the value 1FFF for "bitunset":
SELECT BITUNSET ('ffff', 1, 3) "bitunset" FROM DUMMY;
82 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
2.8.1.25 BITXOR Function (Numeric)
Performs an XOR operation on the bits of two arguments.
Syntax
BITXOR (<expression1>, <expression2>)
Description
Performs an XOR operation on the bits of the arguments <expression1> and <expression2> where 
<expression1> and <expression2> must be non-negative INTEGER or VARBINARY values.
The BITXOR function returns a result along the argument's type.
Example
The following example performs a bitwise XOR for the arguments 255 and 123, and returns the value 132 for 
"bitxor":
SELECT BITXOR (255, 123) "bitxor" FROM DUMMY;
2.8.1.26 CARDINALITY Function (Miscellaneous)
Returns the number of elements in a specified array.
Syntax
CARDINALITY (<array_value_expression>)
Description
Return the number of elements in <array_value_expression>.
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 83
Example
The following example returns the number of elements (3 and 4, respectively), contained in two arrays.
CREATE COLUMN TABLE ARRAY_TEST (IDX INT, VAL INT ARRAY); INSERT INTO ARRAY_TEST VALUES (1, ARRAY(1, 2, 3));
INSERT INTO ARRAY_TEST VALUES (2, ARRAY(10, 20, 30, 40)); SELECT CARDINALITY(VAL) "cardinality" FROM ARRAY_TEST;
2.8.1.27 CAST Function (Data Type Conversion)
Returns the value of an expression converted to a supplied data type.
Syntax
CAST (<expression> AS <data_type>)
Syntax Elements
expression
Specifies the expression to be converted.
data_type
Specifies the target data type.
<data_type> ::= TINYINT 
 | SMALLINT
 | INTEGER
 | BIGINT
 | DECIMAL
 | SMALLDECIMAL
 | REAL
 | DOUBLE
 | ALPHANUM
 | VARCHAR
 | NVARCHAR
 | DAYDATE
 | DATE
 | TIME
 | SECONDDATE | TIMESTAMP
84 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
Description
Returns the value of an expression converted to a supplied data type.
Examples
The following example converts the value 7 to the VARCHAR value 7.
SELECT CAST (7 AS VARCHAR) "cast" FROM DUMMY;
The following example converts the value 10.5 to the INTEGER value 10, truncating the mantissa.
SELECT CAST (10.5 AS INTEGER) "cast" FROM DUMMY;
2.8.1.28 CEIL Function (Numeric)
Returns the first integer that is greater than or equal to the specified value.
Syntax
CEIL (<n>)
Description
Returns the first integer that is greater than or equal to the value of <n>.
Example
The following example returns the value 15 for "ceiling":
SELECT CEIL (14.5) "ceiling" FROM DUMMY;
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 85
2.8.1.29 CHAR Function (String)
Returns the character that has the ASCII value of the specified number.
Syntax
CHAR (<n>)
Description
Returns the character that has the ASCII value of the number <v>.
Example
This example converts three ASCII values into characters and concatenates the results, returning the string 
Ant:.
SELECT CHAR (65) || CHAR (110) || CHAR (116) "character" FROM DUMMY;
2.8.1.30 COALESCE Function (Miscellaneous)
Returns the first non-NULL expression from a specified list.
Syntax
COALESCE (expression_list)
Description
Returns the first non-NULL expression from a list. At least two expressions must be contained in 
expression_list, and all expressions must be comparable. The result is NULL if all the arguments are NULL.
86 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
Example
CREATE TABLEcoalesce_example (ID INT PRIMARY KEY, A REAL, B REAL); INSERT INTO coalesce_example VALUES(1, 100, 80);
 INSERT INTO coalesce_example VALUES(2, NULL, 63);
 INSERT INTO coalesce_example VALUES(3, NULL, NULL); SELECT id, a, b, COALESCE (a, b*1.1, 50.0) "coalesce" FROM coalesce_example;
Table 22:
ID A B coalesce
1 100.0 80.0 100.0
2 NULL 63.0 69.30000305175781
3 NULL NULL 50.0
2.8.1.31 CONCAT Function (String)
Returns a combined string consisting of two specified strings.
Syntax
CONCAT (<str1>, <str2>)
Description
Returns a combined string consisting of <str1> followed by <str2>. The concatenation operator (||) is 
identical to this function.
The maximum length of the concatenated string is 8,388,607. If a string length is longer than the maximum 
length, an exception will be thrown. Exceptionally, an implicit truncation is done when converting a (N)CLOB 
typed value with a size greater than the maximum length of a (N)VARCHAR typed value.
Example
This example concatenates the specified string arguments and returns the value Cat:
SELECT CONCAT ('C', 'at') "concat" FROM DUMMY;
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 87
2.8.1.32 CONVERT_CURRENCY Function (Miscellaneous)
Calculates values in different currencies.
Syntax
CONVERT_CURRENCY ( <named_parameter_value>[{, <named_parameter_value>}...])
Syntax Elements
<named_parameter_value> ::= "<field_reference_parameter>" => <expression> | 
"<const_string_parameter>" => <const_string>
Specifies the parameters for the conversion.
<field_reference_parameter> ::= AMOUNT | SOURCE_UNIT | TARGET_UNIT | 
REFERENCE_DATE | CLIENT
You use field reference parameters to refer to table columns for the conversion.
Table 23:
Parameter Name Description Mandatory Default Value
AMOUNT Column identifier containing 
the values to be converted.
Yes none
CLIENT Defines a three character 
string which is used to sepa­
rate tenants within the ERP 
system tables. This is used in 
the conversion tables to se­
lect the correct rows for 
each user. Column Identifier 
also accepted using double 
quotations.
This parameter is mandatory 
as the CLIENT session con­
text variable is not used by 
this command.
Yes none
88 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
Parameter Name Description Mandatory Default Value
SOURCE_UNIT Column Identifier describing 
input unit. Constant string 
also accepted using single 
quotation.
Yes none
TARGET_UNIT Column Identifier describing 
target unit. Constant string 
also accepted using single 
quotation.
Yes none
REFERENCE_DATE Column Identifier describing 
the currency reference date. 
Constant string also ac­
cepted using single quota­
tion.
Yes none
<const_string_parameter> ::= SCHEMA | CONVERSION_TYPE | LOOKUP | ERROR_HANDLING 
| ACCURACY | DATE_FORMAT | STEPS | CONFIGURATION_TABLE | 
PRECISIONS_TABLE | NOTATION_TABLE | RATES_TABLE | PREFACTORS_TABLE
Defines constant parameter values used in the conversion.
Table 24:
Parameter name Description Mandatory Default Value
SCHEMA Defines the schema that 
contains the conversion ta­
bles used for the conversion.
Yes none
METHOD Table 25:
Value Purpose
ERP
Banking
No ERP
BID_ASK_TYPE Table 26:
Value Purpose
bid
ask
mid
No (empty string)
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 89
Parameter name Description Mandatory Default Value
MARKET_DATA_AREA Defines the market data area 
as stored in the tables. Man­
datory for Banking currency 
conversion.
No (empty string)
SYSTEM_TIME Defines the system time­
stamp for time travel func­
tionality.
No Current system timestamp 
in GMT
CONVERSION_TYPE Defines the conversion type 
as stored in the conversion 
tables. The conversion types 
available in your system vary 
according to the setup of 
your ERP system. In general 
these are either be M or 
EURX. Contact your system 
administrator for the details 
of your specific table config­
uration.
No M
LOOKUP The type of lookup to be per­
formed.
Table 27:
Value Purpose
regular A regular 
conversion 
is per­
formed.
reverse Performs a 
reverse con­
version with 
the input 
units swap­
ped.
No regular
90 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
Parameter name Description Mandatory Default Value
ERROR_HANDLING Defines how the system han­
dles a situation where a row 
could not be converted.
Table 28:
Value Purpose
fail on error The conver­
sion fails 
with an er­
ror.
set to null The output 
from the 
row that 
caused the 
error is set 
to null.
keep uncon­
verted
The input 
value is re­
turned.
No fail on error
ACCURACY Defines the rounding behav­
ior of the system.
Table 29:
Value Purpose
compatibil­
ity
Mimics ERP 
behavior by 
rounding the 
result.
highest Keeps as 
many digits 
as possible 
in the result.
No compatibility
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 91
Parameter name Description Mandatory Default Value
DATE_FORMAT Defines the format in which 
the reference date is pre­
sented.
Table 30:
Value Purpose
auto detect Attempt au­
tomatic de­
tection of 
the date for­
mat.
normal Date is pro­
vided in a 
regular for­
mat
inverted Date is pro­
vided in in­
verted SAP 
legacy for­
mat.
No auto detect
92 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
Parameter name Description Mandatory Default Value
STEPS Define the steps that should 
be included in the conversion 
process. You provide a 
comma delimited list of the 
steps to be included, the or­
der of the steps is irrelevant.
Table 31:
Value Purpose
shift Enables a 
decimal shift 
according to 
the source 
currency se­
lected. For 
example, if 
the source 
currency 
has 0 valid 
digits ac­
cording to 
PRECI­
SIONS_TA-
BLE, each 
value needs 
to be multi­
plied by 100 
because in 
SAP ERP 
systems val­
ues are 
stored using 
2 digits. This 
has to be 
done to con­
vert ERP val­
ues to their 
correct nu­
merical rep­
resentation.
convert Triggers the 
actual con­
version from 
No shift, convert
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 93
Parameter name Description Mandatory Default Value
Value Purpose
the source 
to the target 
currency.
round Rounds the 
converted 
value to the 
number of 
digits of the 
target cur­
rency. You 
should use 
this step 
carefully if 
subsequent 
aggrega­
tions take 
place on the 
number as 
rounding er­
rors could 
accumulate.
shift_back While shift 
changes the 
decimals 
from 2 to 
the config­
ured preci­
sion of the 
source cur­
rency, 
shift_back 
changes 
them back 
to two but 
from the tar­
get cur­
rency. If er­
ror handling 
is set to 
'keep un­
converted' 
94 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
Parameter name Description Mandatory Default Value
Value Purpose
the output 
currency 
might be the 
source in­
stead of the 
target cur­
rency. In the 
error case 
the rounding 
and the 
shift_back 
are done 
with respect 
to the 
source cur­
rency as well 
and the con­
version is 
dropped. 
This renders 
all steps to 
be redun­
dant yielding 
the input 
value again.
CONFIGURATION_TABLE The table identifier of the 
conversion type configura­
tion.
No TCURV
PRECISIONS_TABLE The table identifier of the 
precision table.
No TCURX
NOTATION_TABLE The table identifier of the ta­
ble that stores notations.
No TCURN
RATES_TABLE The identifier of the conver­
sion rates table.
No TCURR
PREFACTORS_TABLE The table identifier of the 
pre-factors table
No TCURF
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 95
Description
The CONVERT_CURRENCY function provides an efficient method to calculate values in different currencies. 
CONVERT_CURRENCY function is an SQL representation of the SQLScript Built-In function CE_CONVERSION, 
and internally uses CE_CONVERSION for computation.
To use the CONVERT_CURRENCY function, the currency conversiontables TCURV, TCURX, TCURN, TCURR 
and TCURF must be available in the SAP HANA database. For other SAP HANA databases, replicate the 
TCURV, TCURX, TCURN, TCURR and TCURF tables from an SAP ERP system.
Example
Create a table and populate it with two example currency amounts.
create table sample_input (price decimal(15,2), source_unit varchar(4),
 target_unit varchar(4),
 ref_date varchar(10)
 ) ;
 insert into sample_input values (1.0, 'SRC', 'TRG', '2011-01-01') ; insert into sample_input values (1.0, 'SRC', 'TRG', '2011-02-01') ;
Convert the values in the currency table using conversion tables contained in the SYSTEM schema.
SELECT CONVERT_CURRENCY(amount=>price, "SOURCE_UNIT_COLUMN" =>source_unit,
 "SCHEMA" => 'SYSTEM',
 "TARGET_UNIT_COLUMN" => target_unit,
 "REFERENCE_DATE" =>'2013-09-23',
 "ERROR_HANDLING"=>'set to null',
 "CLIENT" => '000') as converted FROM sample_input;
Convert the values by using the Banking method.
SELECT *, CONVERT_CURRENCY(method=>'Banking', -- new market_data_area=>'S000’, -- new (and mandatory for 
Banking)
 amount=>ext_limit,
 source_unit =>ext_limit_curr,
 schema => 'SAPCOB',
 target_unit=> 'EUR',
 reference_date => business_day,
 error_handling=> 'set to null', client => '150') as converted from v_fx_input
Convert the values by using the Banking method and system_time.
SELECT *, CONVERT_CURRENCY(method=>'Banking', -- new market_data_area=>'S000', -- mandatory (for Banking)
 bid_ask_type=>'MID', -- optional
 system_time=>to_timestamp('2011-05-11 
12:59.999','YYYY-MM-DD HH:SS.FF3') -- optional
 amount=>ext_limit,
 source_unit =>ext_limit_curr,
 schema => 'SAPCOB',
 target_unit=> 'EUR',
96 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
 reference_date => business_day,
 error_handling=> 'set to null', client => '150') as converted from v_fx_input
2.8.1.33 CONVERT_UNIT Function (Miscellaneous)
Converts the specified source units to specified target units.
Syntax
CONVERT_UNIT( <named_parameter_value>, ... )
Syntax Elements
<named_parameter_value> := "<field_reference_parameter>" => <expression> | 
"<const_string_parameter>" => <const_string>
Named value of field reference, or constant string, parameters.
<field_reference_parameter> ::= QUANTITY | SOURCE_UNIT | TARGET_UNIT | CLIENT <const_string_parameter> ::= SCHEMA | ERROR_HANDLING | RATES_TABLE | 
DIMENSION_TABLE
Table 32:
Parameter Name Description Mandatory Default Value
QUANTITY Column to be converted. Yes None
SOURCE_UNIT Column Identifier describing 
input unit. Constant string 
also accepted using single 
quotation.
Yes None
TARGET_UNIT Column Identifier describing 
target unit. Constant string 
also accepted using single 
quotation.
Yes None
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 97
CLIENT Defines a three character 
string which is used to sepa­
rate tenants within the ERP 
system tables. This is used in 
the conversion tables to se­
lect the correct rows for 
each user. Column Identifier 
also accepted using double 
quotations. This parameter 
is mandatory as the CLIENT 
session context variable is 
not used by this command.
Yes None
SCHEMA Defines the default schema 
in which the conversion ta­
bles should be looked up.
Yes None
ERROR_HANDLING Defines how the system han­
dles a situation where a row 
could not be converted.
Table 33:
Value Purpose
fail on error The conver­
sion fails 
with an er­
ror.
set to null The output 
from the 
row that 
caused the 
error is set 
to null.
keep uncon­
verted
The input 
value is re­
turned.
No 'fail on error'
RATES_TABLE Defines a table that stores 
the conversion rates.
No 'T006'
DIMENSION_TABLE Defines a table that stores 
the conversion dimensions.
no 'T006D'
Description
The CONVERT_UNIT function is an SQL representation of SQLScript Built-In function CE_CONVERSION, and 
internally uses CE_CONVERSION for computation.
98 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
To use the CONVERT_UNIT function, the unit conversion tables T006 and T006D must be available in the SAP 
HANA database. For other SAP HANA databases, replicate the T006 and T006D tables from an SAP ERP 
system.
Example
create table sample_input ( quant decimal(15,2),
 source_unit varchar(4),
 target_unit varchar(4)
 ) ;
 insert into sample_input values (1.0, 'SRC', 'TRG') ;
 insert into sample_input values (1.0, 'SRC', 'TRG') ;
 
 select CONVERT_UNIT("QUANTITY"=>quant
 , "SOURCE_UNIT_COLUMN" =>source_unit
 , "SCHEMA" => 'SYSTEM'
 , "TARGET_UNIT_COLUMN" => target_unit
 , "ERROR_HANDLING"=>'set to null'
 , "CLIENT" => '000') as converted from sample_input;
2.8.1.34 CORR Function (Aggregate)
Computes the Pearson product momentum correlation coefficient between two columns.
Syntax
CORR (<column1>, <column2>) [OVER([PARTITION BY <col1>, ...] [ORDER BY <col1>, ... [<window_frame>]])]
Syntax Elements
<column1> ::= <identifier> <column2> ::= <identifier>
These parameters specifiy the columns providing the input data for the correlation.
<col1> ::= <identifier>
This parameter specifies the columns for partitioning the data.
<window_frame> ::= {ROWS|GROUPS} UNBOUNDED PRECEDING | {ROWS|GROUPS} BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW 
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 99
 | {ROWS|GROUPS} BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
If ORDER BY is not specified, the default frame is UNBOUNDED PRECEEDING TO UNBOUNDED FOLLOWING; 
otherwise, the default frame is GROUPS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW.
Description
Computes the Pearson product momentum correlation coefficient between two columns.
The result ranges from -1 to 1, depending on the correlation, or null if a correlation could not be computed.
The result can return null for one of the following reasons:
● Less than two value pairs are correlated after nulls have been removed
● There is zero variance in at least one of the two columns
The values of <column1> and <column2> may be of any numeric type.
Examples
The examples below assume that the a correlation table has been created with the following values:
CREATE COLUMN TABLE correlationTable ( ts_id VARCHAR(20),
 date DAYDATE,
 value1 DOUBLE,
 value2 DOUBLE);
INSERT INTO correlationTable VALUES ('A', '2014-10-01', 1, 1);
INSERT INTO correlationTable VALUES ('A', '2014-10-02', 2, 2);
INSERT INTO correlationTable VALUES ('A', '2014-10-04', 3, 3);
INSERT INTO correlationTable VALUES ('B', '2014-10-07', 1, 3);
INSERT INTO correlationTable VALUES ('B', '2014-10-11', 2, 2); INSERT INTO correlationTable VALUES ('B', '2014-10-21', 3, 1);
The following aggregate function example returns the correlation between the ts_id column and the columns 
value1 and value2. The example returns [[A, 1], [B,-1]].
SELECT ts_id, CORR(value1, value2) FROM correlationTable GROUP BY ts_id;
The following WHERE clause example returns the correlation between the ts_id column and the columns 
value1 and value2 only for rows where ts_id equals A. The result is [A, 1].
SELECT ts_id, CORR(value1, value2) FROM correlationTable WHERE ts_id='A' GROUP BY ts_id;
The example shows using a window function. The result is [[A, 1], [A, 1], [A, 1], [B,-1],[B,-1],[B,-1]].
SELECT ts_id, CORR(value1, value2) OVER (PARTITION BY ts_id) FROM 
correlationTable;
100 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
The sliding window example below returns [[A, ?], [A, 1], [A, 1], [B, ?], [B,-1],[B,-1]].
SELECT ts_id, CORR(value1, value2) OVER (PARTITION BY ts_id ORDER BY date) FROM correlationTable ORDER BY ts_id;
The ROWS BETWEEN example below returns [[A, ?], [A, 1], [A, 1], [B, ?], [B,-1],[B,-1]].
SELECT ts_id, CORR(value1, value2) OVER (PARTITION BY ts_id ORDER BY date ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) from correlationTable;
2.8.1.35 CORR_SPEARMAN Function (Aggregate)
Returns the Spearman's rank correlation coefficient of the values found in the corresponding rows of 
<column1> and <column2>.
Syntax
CORR_SPEARMAN (<column1>, <column2>) [OVER([PARTITION BY <col1>, ...] [ORDER BY <col1>, ... [<window_frame>]])]
Syntax Elements
<column1> ::= <identifier> <column2> ::= <identifier>
These parameters specifiy the columns providing the input data for the correlation.
<col1> ::= <identifier>
The parameter specifies the columns for partitioning the data.
<window_frame> ::= {ROWS|GROUPS} UNBOUNDED PRECEDING | {ROWS|GROUPS} BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW | {ROWS|GROUPS} BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
If ORDER BY is not specified, the default frame is UNBOUNDED PRECEEDING TO UNBOUNDED FOLLOWING; 
otherwise, the default frame is GROUPS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW.
Description
Returns the Spearman's rank correlation coefficient of the values found in the corresponding rows of 
<column1> and <column2>.
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 101
Column1 and column2 may contain number or even character types.
The result ranges from -1 to 1, depending on the correlation, or null if a correlation could not be computed.
The result can return null for one of the following reasons:
● Less than two value pairs are correlated after nulls have been removed
● There is zero variance in at least one of the two columns
Whenever a null value is found then both the null value and the corresponding value of the other input column 
are ignored.
Examples
The example below returns -1.
CREATE COLUMN TABLE A (date DAYDATE, val INT); INSERT INTO A VALUES ('2014-10-01', 100);
INSERT INTO A VALUES ('2014-10-02', 200);
INSERT INTO A VALUES ('2014-10-03', 300);
CREATE COLUMN TABLE B (date DAYDATE, val INT);
INSERT INTO B VALUES ('2014-10-01', 300);
INSERT INTO B VALUES ('2014-10-02', 200);
INSERT INTO B VALUES ('2014-10-03', 100); SELECT CORR_SPEARMAN(A.val, B.val) "corr" FROM A, B WHERE A.date = B.date;
The examples below assume that the correlation table has been created with the following values:
CREATE COLUMN TABLE correlationSpearmanTable ( ts_id VARCHAR(20),
 date DAYDATE,
 value1 DOUBLE,
 value2 DOUBLE);
INSERT INTO correlationSpearmanTable VALUES ('A', '2014-10-01', 34.345, 45.345);
INSERT INTO correlationSpearmanTable VALUES ('A', '2014-10-02', 27.145, 28.893);
INSERT INTO correlationSpearmanTable VALUES ('A', '2014-10-02', 48.312, 28.865);
INSERT INTO correlationSpearmanTable VALUES ('A', '2014-10-03', 94.213, 58.854);
INSERT INTO correlationSpearmanTable VALUES ('A', '2014-10-03', 16.567, 28.231);
INSERT INTO correlationSpearmanTable VALUES ('A', '2014-10-03', 38.894, 94.378);
INSERT INTO correlationSpearmanTable VALUES ('B', '2014-10-04', 45.643, 76.987);
INSERT INTO correlationSpearmanTable VALUES ('B', '2014-10-04', 53.345, 50.893);
INSERT INTO correlationSpearmanTable VALUES ('B', '2014-10-04', 66.342, 48.342);
INSERT INTO correlationSpearmanTable VALUES ('B', '2014-10-04', 76.432, 37.234);
INSERT INTO correlationSpearmanTable VALUES ('B', '2014-10-05', 88.432, 23.242); INSERT INTO correlationSpearmanTable VALUES ('B', '2014-10-05', 93.234, 13.132);
The aggregate function example below returns [[A, 0.54], [B,-1]].
SELECT ts_id, CORR_spearman(value1, value2) FROM correlationSpearmanTable GROUP 
BY ts_id;
The window function example below returns [[A, 0.54], [A, 0.54], [A, 0.54], [A, 0.54], [A, 
0.54], [A, 0.54], [B,-1],[B,-1],[B,-1],[B,-1],[B,-1],[B,-1]].
SELECT ts_id, CORR_spearman(value1, value2) OVER (PARTITION BY ts_id) FROM 
correlationSpearmanTable;
102 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
The sliding window example below returns [[A, ?], [A, -0.5], [A, -0.5], [A, 0.54], [A, 
0.54], [A, 0.54], [B,-1],[B,-1],[B,-1],[B,-1],[B,-1],[B,-1]].
SELECT ts_id, CORR_spearman(value1, value2) OVER (PARTITION BY ts_id ORDER BY 
date) FROM correlationSpearmanTable ORDER BY ts_id;
The ROWS BETWEEN example below returns [[A, ?], [A, 1], [A, -0.5], [A, 0.4], [A, 0.7], 
[A, 0.54], [B,?],[B,-1],[B,-1],[B,-1],[B,-1],[B,-1]].
SELECT ts_id, CORR_spearman(value1, value2) OVER (PARTITION BY ts_id ORDER BY 
date ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) from 
correlationSpearmanTable;
The group example below returns [[A, ?], [A, -0.5], [A, -0.5], [A, 0.54], [A, 0.54], [A, 
0.54], [B, -1],[B, -1],[B, -1],[B, -1],[B, -1],[B, -1]].
SELECT ts_id, CORR_spearman(value1, value2) OVER (PARTITION BY ts_id ORDER BY 
date GROUPS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM 
correlationSpearmanTable;
2.8.1.36 COS Function (Numeric)
Returns the cosine of the angle, in radians, for the specified argument.
Syntax
COS (<n>)
Description
Returns the cosine of the angle <n>, in radians.
Example
The following example returns the value 1.0 for "cos":
SELECT COS (0.0) "cos" FROM DUMMY;
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 103
2.8.1.37 COSH Function (Numeric)
Computes the hyperbolic cosine of the specified argument.
Syntax
COSH (<n>)
Description
Computes the hyperbolic cosine of the numeric argument <n>.
Example
The following example returns the value .1276259652063807 for "cosh":
SELECT COSH (0.5) "cosh" FROM DUMMY;
2.8.1.38 COT Function (Numeric)
Computes the cotangent of a specified number.
Syntax
COT (<n>)
Description
Computes the cotangent of a number <n>, where <n> is an angle expressed in radians.
104 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
Example
The following example returns the value -0.8950829176379128 for "cot":
SELECT COT (40) "cot" FROM DUMMY;
2.8.1.39 CROSS_CORR Function (Aggregate)
Computes all cross-correlation coefficients between two given columns.
Syntax
CROSS_CORR (<expression1>, <expression2>, <maxLag> { <series_orderby> | ORDER BY <expression3> [ ASC | DESC ] [ NULLS FIRST | 
NULLS ] } ).{ POSITIVE_LAGS | NEGATIVE_LAGS | ZERO_LAG }
Syntax Elements
<expression1> ::= NUMERIC <expression2> ::= NUMERIC
These parameters are input values between which the cross-correlation is calculated.
<max_lag> ::= INTEGER
The <max_lag> parameter must be a positive integer that defines the number of cross-correlation 
coefficients to be returned.
<series_orderby> ::= SERIES (<series_period> <series_equidistant_definition>)
The SERIES clause can only be used with an equidistant series. For more information about the SERIES clause, 
see the CREATE TABLE statement.
Specify a single <expression3> in the ORDER BY clause. The function output can be non-deterministic 
among values.
Description
Computes all cross-correlation coefficients between two given columns.
The result is an array of cross-correlation coefficients of length <maxLag>.
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 105
If POSITIVE_LAGS is specified, the cross-correlation coefficients with lags 1 .. <maxLag> are returned
If NEGATIVE_LAGS is specified, the cross-correlation coefficients with lags -1 .. <maxLag> are returned
If ZERO_LAG is specified, a single value associated with lag 0 is returned.
Example
Example 1 - Cross correlation
The example below returns [1, -1, 1]:
CREATE COLUMN TABLE table1 ( ts_id INTEGER, number1 DOUBLE, number2 DOUBLE ); INSERT INTO table1 VALUES('1', 1, 2);
INSERT INTO table1 VALUES ('2', 2 ,1);
INSERT INTO table1 VALUES ('3', 1 ,2); SELECT CROSS_CORR(number1, number2, 10 ORDER BY ts_id) FROM table1;
Example 2 - Cross correlation using a series descriptor
The example below returns the values [-1, -0.9285714, -0.6, 0.5, -1]:
CREATE COLUMN TABLE TSeries( key INTEGER, ts TIMESTAMP, val1 DOUBLE, val2 
DOUBLE, PRIMARY KEY(key, ts) ) SERIES( SERIES KEY (key) EQUIDISTANT INCREMENT BY INTERVAL 1 DAY PERIOD FOR 
SERIES(ts) );
INSERT INTO TSeries VALUES (1, '2014-1-1', 1, 3);
INSERT INTO TSeries VALUES (2, '2014-1-3', 2, 4);
INSERT INTO TSeries VALUES (3, '2014-1-4', 4, 2);
INSERT INTO TSeries VALUES (4, '2014-1-5', 3, 1); SELECT CROSS_CORR(val1, val2, 10 ORDER BY ts) FROM TSeries;
Related Information
CREATE TABLE Statement (Data Definition) [page 367]
2.8.1.40 CURRENT_CONNECTION Function (Miscellaneous)
Returns the ID of the current connection.
Syntax
CURRENT_CONNECTION
106 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
Description
Returns the ID of the current connection.
Example
The following query returns the connection ID 2.
SELECT CURRENT_CONNECTION "current connection" FROM DUMMY;
2.8.1.41 CURRENT_DATE Function (Datetime)
Returns the current local system date.
Syntax
CURRENT_DATE
Description
Returns the current local system date.
The usage of local timestamps is discouraged. It is a best practice to use UTC times instead. The use of local 
times or conversion between local time zones might require additional handling in application code.
Example
The following example returns the value 2010-01-11 for the current local system date:
SELECT CURRENT_DATE "current date" FROM DUMMY;
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 107
2.8.1.42 CURRENT_IDENTITY_VALUE Function 
(Miscellaneous)
Returns a BIGINT value representing the latest inserted identity value in the current session.
Syntax Elements
CURRENT_IDENTITY_VALUE()
Description
Returns a BIGINT value representing the latest inserted identity value in the current session. If no identity 
value was inserted in the current session, NULL is returned as a result.
Example
This example creates the table test and inserts a row with the identity 102. The identity value is then read and 
returned.
CREATE COLUMN TABLE test (objectid BIGINT generated by default as identity 
(start with 101 increment by 1) NOT NULL, col2 integer, primary key(objectid));
INSERT INTO test (col2) VALUES ( 1 );
SELECT CURRENT_IDENTITY_VALUE() "current identity value" FROM test;
current identity value 102
2.8.1.43 CURRENT_SCHEMA Function (Miscellaneous)
Returns a string containing the current schema name.
Syntax
CURRENT_SCHEMA
108 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
Description
Returns a string containing the current schema name.
Example
SELECT CURRENT_SCHEMA "current schema" FROM DUMMY; 
 current schema SYSTEM
2.8.1.44 CURRENT_TIME Function (Datetime)
Returns the local system time.
Syntax
CURRENT_TIME
Description
Returns the current local system time.
The usage of local timestamps is discouraged. It is a best practice to use UTC times instead. The use of local 
times or conversion between local time zones might require additional handling in application code.
Example
The following example returns the value 17:37:37, reflect to reflect the current local system time:
SELECT CURRENT_TIME "current time" FROM DUMMY;
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 109
2.8.1.45 CURRENT_TIMESTAMP Function (Datetime)
Returns the current local system timestamp information.
Syntax
CURRENT_TIMESTAMP
Description
Returns the current local system timestamp information.
The usage of local timestamps is discouraged. It is a best practice to use UTC times instead. The use of local 
times or conversion between local time zones might require additional handling in application code.
Example
The following example returns the value 2010-01-11 17:38:48.802 as the current timestamp::
SELECT CURRENT_TIMESTAMP "current timestamp" FROM DUMMY;
2.8.1.46 CURRENT_TRANSACTION_ISOLATION_LEVEL 
Function (Miscellaneous)
Returns a string containing the current transaction isolation level.
Syntax
CURRENT_TRANSACTION_ISOLATION_LEVEL
Description
Returns a string containing the current transaction isolation level.
110 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
Example
SELECT CURRENT_TRANSACTION_ISOLATION_LEVEL "current transaction isolation level" 
FROM DUMMY; 
 current transaction isolation level READ COMMITTED
2.8.1.47 CURRENT_UPDATE_TRANSACTION Function 
(Miscellaneous)
Returns the unique ID of the current transaction when it is in write mode.
Syntax
CURRENT_UPDATE_TRANSACTION ()
Description
Returns the unique ID of the current transaction when it is in write mode. If the current transaction is in read 
mode, it returns 0.
Example
The following example returns the current update transaction id.
SELECT CURRENT_UPDATE_TRANSACTION() "current update transaction" FROM DUMMY; current update transaction 2
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 111
2.8.1.48 CURRENT_UPDATE_STATEMENT_SEQUENCE 
Function (Miscellaneous)
Returns the number of write statements that have been issued in a transaction incremented by 1.
Syntax
CURRENT_UPDATE_STATEMENT_SEQUENCE ()
Description
Returns the number of write statements that have been issued in a transaction incremented by 1. If the 
transaction has never issued a write transaction, then the function returns 1. The initial value is 1. In a read 
transaction, the function always returns 1.
Examples
The following example shows how to retrieve the current write statement sequence number of the current 
transaction:
CREATE COLUMN TABLE T(id INT); INSERT INTO T VALUES (1);
SELECT CURRENT_UPDATE_STATEMENT_SEQUENCE() "statement sequence number" FROM 
DUMMY;
statement sequence number
1
DELETE FROM T;
SELECT CURRENT_UPDATE_STATEMENT_SEQUENCE() "statement sequence number" FROM 
DUMMY;
statement sequence number 1
112 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
2.8.1.49 CURRENT_USER Function (Miscellaneous)
Returns the current user name at the current statement context.
Syntax
CURRENT_USER
Description
Returns the current user name at the current statement context. This is the user name that is currently at the 
top of authorization stack.
Example
-- example showing basic function operation using SYSTEM user SELECT CURRENT_USER "current user" FROM DUMMY;
 
 current user
 SYSTEM
 -- definer-mode procedure declared by USER_A
 CREATE PROCEDURE USER_A.PROC1 LANGUAGE SQLSCRIPT SQL SECURITY DEFINER AS
 BEGIN
 SELECT CURRENT_USER "current user" FROM DUMMY;
 END;
 
 -- USER_B executing USER_A.PROC1
 CALL USER_A.PROC1;
 current user
 USER_A
 -- invoker-mode procedure declared by USER_A
 CREATE PROCEDURE USER_A.PROC2 LANGUAGE SQLSCRIPT SQL SECURITY INVOKER AS
 BEGIN
 SELECT CURRENT_USER "current user" FROM DUMMY;
 END;
 
 -- USER_B is executing USER_A.PROC
 CALL USER_A.PROC2;
 current user USER_B
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 113
2.8.1.50 CURRENT_UTCDATE Function (Datetime)
Returns the current UTC date.
Syntax
CURRENT_UTCDATE
Description
Returns the current UTC date. The UTC stands for Coordinated Universal Time, also known as Greenwich 
Mean Time (GMT).
Example
The following example returns the value 2010-01-11 as the UTC date for the specified date:
SELECT CURRENT_UTCDATE "Coordinated Universal Date" FROM DUMMY;
2.8.1.51 CURRENT_UTCTIME Function (Datetime)
Returns the current UTC time.
Syntax
CURRENT_UTCTIME
Description
Returns the current UTC time.
114 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
Example
The following example returns the value 08:41:19 as the current UTC time:
SELECT CURRENT_UTCTIME "Coordinated Universal Time" FROM DUMMY;
2.8.1.52 CURRENT_UTCTIMESTAMPFunction (Datetime)
Returns the current UTC timestamp.
Syntax
CURRENT_UTCTIMESTAMP
Description
Returns the current UTC timestamp.
Example
The following example returns the value 2010-01-11 08:41:42.484 as the current UTC timestamp:
SELECT CURRENT_UTCTIMESTAMP "Coordinated Universal Timestamp" FROM DUMMY;
2.8.1.53 DAYNAME Function (Datetime)
Returns the weekday for the specified date.
Syntax
DAYNAME (<d>)
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 115
Description
Returns the weekday in English for date <d>.
Example
The following example returns Monday as the week day for the specified date:
SELECT DAYNAME ('2011-05-30') "dayname" FROM DUMMY;
2.8.1.54 DAYOFMONTH Function (Datetime)
Returns the day of the month for the specified date.
Syntax
DAYOFMONTH (<d>)
Description
Returns an integer the day of the month for date <d>.
Example
The following example returns 30 as the number for the day of the month for the specified date:
SELECT DAYOFMONTH ('2011-05-30') "dayofmonth" FROM DUMMY;
116 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
2.8.1.55 DAYOFYEAR Function (Datetime)
Returns an integer representation of the day of the year for the specified date.
Syntax
DAYOFYEAR (<d>)
Description
Returns an integer representation of the day of the year for date <d>.
Example
The following example returns the value 150 as the day of the year for the specified date:
SELECT DAYOFYEAR ('2011-05-30') "dayofyear" FROM DUMMY;
2.8.1.56 DAYS_BETWEEN Function (Datetime)
Computes the number of days between d1 and d2.
Syntax
DAYS_BETWEEN (<d1>, <d2>)
Description
Computes the number of days between <d1> and <d2>.
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 117
Example
The following example returns the value 31 for days between the two dates specified:
SELECT DAYS_BETWEEN (TO_DATE ('2009-12-05', 'YYYY-MM-DD'), TO_DATE('2010-01-05', 
'YYYY-MM-DD')) "days between" FROM DUMMY;
2.8.1.57 DFT Function (Aggregate)
Computes columns and returns an array with specific elements.
Syntax
DFT (<column>, <N> {SERIES( ... ) | ORDER BY <col1>, ... }).{REAL|IMAGINARY|AMPLITUDE|PHASE}
Description
Computes the Discrete Fourier Transform of a column for the first N values and returns an array with exactly N 
elements.
The returned values depend on the output parameter, which must be one of REAL, IMAGINARY, AMPLITUDE, 
or PHASE.
The column parameter must not contain any null values. All values are assumed to be samples taken at 
constant time intervals.
The N parameter must be a power of 2. The input is padded with zeros if it contains less than N elements.
The ORDER BY column (i.e. col1 above) must not contain any null values, nor any duplicates.
The SERIES definition can only be used with an equidistant series. The series * must not contain missing 
elements.
Examples
The example below computes the Discrete Fourier Transform of a column in an equidistant series.
SELECT DFT(FRACTION_OF_MIN_MAX_RANGE, 4 SERIES(EQUIDISTANT INCREMENT BY 1 PERIOD 
FOR SERIES(element_number))).REAL FROM SERIES_GENERATE_INTEGER(1,0,10);
118 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
The example below returns an array with 4 numbers representing the real part of the result.
SELECT DFT(col, 4 (ORDER BY DATE)).REAL FROM MY_TABLE;
The example below returns an array with 8 numbers representing the imaginary part of the result.
SELECT DFT(col, 8 (ORDER BY DATE)).IMAGINARY FROM MY_TABLE;
The example below returns an array with 8 numbers representing the amplitude part (i.e. SQRT(REAL^2 + 
IMAGINARY^2)) of the result.
SELECT DFT(col, 8 (ORDER BY DATE)).AMPLITUDE FROM MY_TABLE;
The example below returns an array with 8 numbers representing the phase part of the result and ranges 
between -PI and +PI.
SELECT DFT(col, 8 (ORDER BY DATE)).PHASE FROM MY_TABLE;
2.8.1.58 ENCRYPTION_ROOT_KEYS_EXTRACT_KEYS 
Function (Security)
Extracts root keys and sends them to a client session as a CLOB.
Syntax
ENCRYPTION_ROOT_KEYS_EXTRACT_KEYS(['<root_keytype_list>'])
Syntax Elements
root_keytype_list
Specify the key types that are included in the CLOB. All versions of the specified key type are included in 
the CLOB. If <root_keytype_list> is empty, then all key types are included in the CLOB.
<root_keytype_list> ::= <root_keytype> [, ...] <root_keytype> ::= PERSISTENCE | APPLICATION | LOG
PERSISTENCE Specifies that persistence encryption root keys are extracted.
APPLICATION Specifies that application encryption root keys are extracted.
LOG Specifies that redo log encryption root keys are extracted.
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 119
Description
Execute this statement in the database from which the root keys are being extracted.
You must have the ENCRYPTION ROOT KEY ADMIN privilege, and you must have an existing encryption root 
key backup password.
Example
The following statement extracts all persistence and backup root keys from the encryption root keys store 
(SSFS) and sends them to a client session as a CLOB.
SELECT ENCRYPTION_ROOT_KEYS_EXTRACT_KEYS ('PERSISTENCE, LOG') FROM DUMMY;
The following statement includes all key types in the CLOB.
SELECT ENCRYPTION_ROOT_KEYS_EXTRACT_KEYS ('') FROM DUMMY;
Related Information
ALTER SYSTEM SET ENCRYPTION ROOT KEYS BACKUP PASSWORD Statement (System Management) 
[page 669]
ALTER SYSTEM LOG ENCRYPTION Statement (System Management) [page 648]
ALTER SYSTEM PERSISTENCE ENCRYPTION Statement (System Management) [page 651]
ENCRYPTION_ROOT_KEYS System View [page 1058]
APPLICATION_ENCRYPTION_KEYS System View [page 1015]
M_ENCRYPTION_OVERVIEW System View [page 1179]
2.8.1.59 ESCAPE_DOUBLE_QUOTES Function (Security)
Escapes double quotes in the specified string.
Syntax
ESCAPE_DOUBLE_QUOTES(<value>)
120 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
Description
Escapes double quotes in the <value> string, ensuring that a valid SQL identifier is used in dynamic SQL 
statements to prevent SQL injections. The function returns the input string with escaped double quotes.
Example
The following query escapes the double quotes and returns the value TAB""LE.
SELECT ESCAPE_DOUBLE_QUOTES('TAB"LE') "table_name" FROM DUMMY
2.8.1.60 ESCAPE_SINGLE_QUOTES Function (Security)
Escapes single quotes in the specified string.
Syntax
ESCAPE_SINGLE_QUOTES(<value>)
Description
Escapes single quotes (apostrophes) in the given string <value>, ensuring a valid SQL string literal is used in 
dynamic SQL statements to prevent SQL injections. Returns the input string with escaped single quotes.
Examples
The following query escapes the parameter content Str'ing to Str''ing.
SELECT ESCAPE_SINGLE_QUOTES('Str''ing') "string_literal" FROM DUMMY
The following query example shows the strings retrieved from a table t, both without and with 
ESCAPE_SINGLE_QUOTES applied. The column col_txt contains the two entries Adam's and Eve.
CREATE COLUMN TABLE txt( col_txt NVARCHAR(5000) NOT NULL);
INSERT INTO txt VALUES ('Adam''s');
INSERT INTO txt VALUES ('Eve'); 
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 121
SELECT col_txt, escape_single_quotes(col_txt) FROM txt;
Table 34:
COL_TXT ESCAPE_SINGLE_QUOTES(COL_TXT)
Adam's Adam''s
Eve Eve
2.8.1.61 EXTRACT Function (Datetime)
Finds and returns the value of a specified datetime field from a specified date.
Syntax
EXTRACT ({YEAR | MONTH | DAY | HOUR | MINUTE | SECOND} FROM <d>)
Description
Finds and returns the value of a specified datetime field from date <d>.
Example
The following example returns the value 2010 for the year extracted from the specified date:
SELECT EXTRACT (YEAR FROM TO_DATE ('2010-01-04', 'YYYY-MM-DD')) "extract" FROM 
DUMMY;
122 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
2.8.1.62 EXP Function (Numeric)
Returns the result of the base of the natural logarithms e raised to the power of the specifiedargument.
Syntax
EXP (<n>)
Description
Returns the result of the base of the natural logarithms e raised to the power of the argument <n>.
Example
The following example returns the value 2.718281828459045 for "exp":
SELECT EXP (1.0) "exp" FROM DUMMY;
2.8.1.63 FIRST_VALUE Function (Aggregate)
Returns the value of the first element of an expression.
Syntax
FIRST_VALUE (<expression> ORDER BY <column>) 
Description
Returns the value of the first element in <expression> as ordered by <column>.
Null is returned if the value is null or if <expression> is empty.
The output of FIRST_VALUE function can be non-deterministic among tie values.
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 123
Example
The example below returns the first value in COL1 column when the table is ordered by COL2:
CREATE TABLE T (COL1 DOUBLE, COL2 DOUBLE); INSERT INTO T VALUES(9, 1);
INSERT INTO T VALUES(4, 5);
INSERT INTO T VALUES(7, 3); SELECT FIRST_VALUE (COL1 ORDER BY COL2) FROM T;
The query returns 9.
2.8.1.64 FLOOR Function (Numeric)
Returns the largest integer that is not greater than the specified numeric argument.
Syntax
FLOOR (<n>)
Description
Returns the largest integer that is not greater than the numeric argument <n>.
Example
The following example returns the value 14 for "floor":
SELECT FLOOR (14.5) "floor" FROM DUMMY;
124 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
2.8.1.65 GREATEST Function (Miscellaneous)
Returns the greatest value among the specified arguments.
Syntax
GREATEST (<argument> [{, <argument>}...])
Description
Returns the greatest value among the arguments (n1, n2, ...).
Example
SELECT GREATEST ('aa', 'ab', 'ba', 'bb') "greatest" FROM DUMMY; 
 greatest bb
2.8.1.66 GROUPING Function (Miscellaneous)
Determines whether a specified column is used in grouping.
Syntax
GROUPING(column_name)
Description
The GROUPING function can be used with GROUPING SETS/ROLLUP/CUBE that return multiple levels of 
aggregation in a single result set. The function returns 1 if the specified column is used in grouping and 0 
otherwise. The column of GROUPING must be an element of the GROUPING SETS.
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 125
Example
The following query returns results and indicates whether the results are grouped by customer, year, and/or 
product.
CREATE COLUMN TABLE guided_navi_tab( customer NVARCHAR(5000) NOT NULL,
 year DATE NOT NULL,
 product NVARCHAR(5000),
 sales INTEGER);
SELECT customer, year, product, SUM(sales), 
 GROUPING(customer), GROUPING(year), GROUPING(product)
 FROM guided_navi_tab
 GROUP BY GROUPING SETS (
 (customer, year, product),
 (customer, year),
 (customer, product),
 (year, product),
 (customer),
 (year), (product));
Table 35:
CUSTOMER YEAR PRODUCT SUM(SALES) GROUP­
ING(CUSTO­
MER),
GROUP­
ING(YEAR)
GROUP­
ING(PROD-
UCT)
C1 2009 P1 100 1 1 1
C1 2010 P1 50 1 1 1
C2 2009 P1 200 1 1 1
C2 2010 P1 100 1 1 1
C1 2009 P2 200 1 1 1
C1 2010 P2 150 1 1 1
C2 2009 P2 300 1 1 1
C2 2010 P2 150 1 1 1
C1 2009 a 300 1 1 0
C1 2010 a 200 1 1 0
C2 2009 a 500 1 1 0
C2 2010 a 250 1 1 0
C1 a P1 150 1 0 1
C2 a P1 300 1 0 1
126 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
CUSTOMER YEAR PRODUCT SUM(SALES) GROUP­
ING(CUSTO­
MER),
GROUP­
ING(YEAR)
GROUP­
ING(PROD-
UCT)
C1 a P2 350 1 0 1
C2 a P2 450 1 0 1
a 2009 P1 300 0 1 1
a 2010 P1 150 0 1 1
a 2009 P2 500 0 1 1
a 2010 P2 300 0 1 1
C1 a a 500 1 0 0
C2 a a 750 1 0 0
a 2009 a 800 0 1 0
a 2010 a 450 0 1 0
a a P1 450 0 0 1
a a P2 800 0 0 1
2.8.1.67 GROUPING_ID Function (Miscellaneous)
Returns an integer value to identify which grouping set each row belongs to.
Syntax
GROUPING_ID(column_name_list)
Description
GROUPING_ID function can be used with GROUPING SETS/ROLLUP/CUBE that return multiple levels of 
aggregations in a single result set. GROUPING_ID returns an integer value to identify which grouping set each 
row belongs to. Each column in GROUPING_ID must be an element of the GROUPING SETS.
GROUPING_ID is assigned by converting the bit vector generated from GROUPING SETS to a decimal number 
by treating the bit vector as a binary number. When a bit vector is composed, 0 is assigned to each column 
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 127
specified in the GROUPING SETS and 1 otherwise in the order it appears in the GROUPING SETS. By treating 
the bit vector as a binary number, this function returns an integer value as the output.
Example
CREATE COLUMN TABLE guided_navi_tab( customer NVARCHAR(5000) NOT NULL,
 year DATE NOT NULL,
 product NVARCHAR(5000),
 sales INTEGER);
SELECT customer, year, product, SUM(sales), 
 GROUPING_ID(customer, year, product)
 FROM guided_navi_tab
 GROUP BY GROUPING SETS (
 (customer, year, product),
 (customer, year),
 (customer, product),
 (year, product),
 (customer),
 (year),
 (product));
 
 CUSTOMER YEAR PRODUCT SUM(SALES) GROUPING_ID(CUSTOMER,YEAR,PRODUCT)
 1 C1 2009 P1 100 0
 2 C1 2010 P1 50 0
 3 C2 2009 P1 200 0
 4 C2 2010 P1 100 0
 5 C1 2009 P2 200 0
 6 C1 2010 P2 150 0
 7 C2 2009 P2 300 0
 8 C2 2010 P2 150 0
 9 C1 2009 a 300 1
 10 C1 2010 a 200 1
 11 C2 2009 a 500 1
 12 C2 2010 a 250 1
 13 C1 a P1 150 2
 14 C2 a P1 300 2
 15 C1 a P2 350 2
 16 C2 a P2 450 2
 17 a 2009 P1 300 4
 18 a 2010 P1 150 4
 19 a 2009 P2 500 4
 20 a 2010 P2 300 4
 21 C1 a a 500 3
 22 C2 a a 750 3
 23 a 2009 a 800 5
 24 a 2010 a 450 5
 25 a a P1 450 6 26 a a P2 800 6
128 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
2.8.1.68 HAMMING_DISTANCE Function (String)
Returns the hamming distance of the two specified arguments.
Syntax
HAMMING_DISTANCE(<lhs>, <rhs>)
Description
Hamming distance reflects differences between two specified arguments, and reflects the number of 
corresponding positions that differ from each other across the two arguments. Integer and binary arguments 
are compared bitwise, where as string arguments are compared bytewise.
This function returns the hamming distance of the arguments <lhs> and <rhs>. Returns -1 if the length of the 
two arguments is different, and NULL if any of arguments is NULL.
Examples
The following example returns -1 because the arguments are of different length:
SELECT HAMMING_DISTANCE('abc', 'ca') "hamming_distance" FROM DUMMY;
The following example returns 0 because the arguments are identical:
SELECT HAMMING_DISTANCE('abc', 'abc') "hamming_distance" FROM DUMMY;
The following example returns 0 because the arguments are identical:
SELECT HAMMING_DISTANCE(4, 4) "hamming_distance" FROM DUMMY;
The following example returns 3 because all positions in the two arguments are different from the other string:
SELECT HAMMING_DISTANCE('abc', 'cab') "hamming_distance" FROM DUMMY;
The following example returns 4 to reflect the bitwise comparison of the arguments:
SELECT HAMMING_DISTANCE(to_binary('abc'), to_binary('cab')) "hamming_distance" 
FROM DUMMY;
The following example returns 3 to reflect the bitwise comparison of the arguments:
SELECT HAMMING_DISTANCE(4, 9) "hamming_distance" FROM DUMMY;
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 129
The following example returns -1 because the binary arguments are of different length:
SELECT HAMMING_DISTANCE(to_binary('abc'), to_binary('ca')) "hamming_distance" 
FROM DUMMY;
2.8.1.69 HASH_SHA256 Function (Miscellaneous)
Returns a 32 byte hash value of the concatenated arguments.
Syntax
HASH_SHA256 (<argument> [{, <argument>}...])
Syntax Elements
<argument> ::= <string_literal>
An input argument of type VARBINARY.
Description
Returns a 32 byte VARBINARY hash value of the concatenated arguments. The hash is calculated using a 
SHA256 algorithm.
This function concatenates its arguments.
The following queries both return 
7D1A54127B222502F5B79B5FB0803061152A44F92B37E23C6527BAF665D4DA9A.
SELECT HASH_SHA256(to_binary('abcd'),to_binary('efg')) "test1" FROM DUMMY;
SELECT HASH_SHA256(to_binary('abc'), to_binary('defg')) "test2" FROM DUMMY;
To ensure unique results, delimit the arguments with another string, for example '00'.
This query returns 156D73B945474C6FB04D7CCAC1E31ACA9425F756801AD487C3561FBE6661A659.
SELECT HASH_SHA256(to_binary('abcd'), '00', to_binary('efg')) "test3" FROM DUMMY;
This query returns 6DE75B6290747BFA61C10FD0763344002C436475683B2B7E44C7C31FA920F1E3
SELECT HASH_SHA256(to_binary('abc'), '00', to_binary('defg')) "test4" FROM DUMMY;
130 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
Example
The following query returns a hash value for the specified arguments:
SELECT HASH_SHA256 (to_binary('database')) "hash" FROM DUMMY;
2.8.1.70 HASH_MD5 Function (Miscellaneous)
Returns a 32 byte hash value of the concatenated arguments.
Syntax
HASH_MD5 (<argument> [{, <argument>}...])
Syntax Elements
<argument> ::= <string_literal>
An input argument of type VARBINARY.
Description
Returns a 32 byte VARBINARY hash value of the concatenated arguments. The hash is calculated using a MD5 
algorithm.
This function concatenates its arguments. As a result, the following two queries both return 
7AC66C0F148DE9519B8BD264312C4D64:
SELECT HASH_MD5(to_binary('abcd'), to_binary('efg')) "test1" FROM DUMMY;
SELECT HASH_MD5(to_binary('abc'), to_binary('defg')) "test2" FROM DUMMY;
If you want to ensure unique results, then delimit the arguments with another string, for example 00. The 
following query returns 6BB6BD45C57D57ECC69A9EB81F7409BE :
SELECT HASH_MD5(to_binary('abcd'), '00', to_binary('efg')) "test3" FROM DUMMY;
The following query returns 1CEDEB6EB7ED12D948F66593589FBD23:
SELECT HASH_MD5(to_binary('abc'), '00', to_binary('defg')) "test4" FROM DUMMY;
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 131
Example
The following query generates a hash value based on the provided input:
SELECT HASH_MD5 (to_binary('database')) "hash" FROM DUMMY;
2.8.1.71 HEXTOBIN Function (String)
Converts a hexadecimal value to a binary value.
Syntax
HEXTOBIN (<value>)
Description
Converts a hexadecimal value to a binary value.
Example
The following example converts the hexadecimal value 1a to the BINARY value 1A:
SELECT HEXTOBIN ('1a') "hextobin" FROM DUMMY;
2.8.1.72 HIERARCHY Function (Hierarchy)
Generates a hierarchy based on recursive parent-child source data.
Syntax
HIERARCHY ( <hierarchy_genfunc_source_spec> [<hierarchy_genfunc_start_cond>] [<hierarchy_genfunc_depth_spec>] 
132 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
 [<hierarchy_genfunc_orphan_spec>] [<hierarchy_genfunc_cache_spec>] )
Syntax Elements
hierarchy_genfunc_source_spec
Specifies the source for the hierarchy to be generated from.
<hierarchy_genfunc_source_spec> ::= SOURCE <table_valued_expression> <table_valued_expression> ::= <sql_identifier> | <table_function> | ( <subquery> )
Each row defines a parent-child relation and attributes of a node or edge that may become part of the 
output table, provided that they are reached during traversal. The source specification must define a 
stable sort order for siblings; the sort order of the source determines the sorting of output sibling nodes.
The source columns defining the recursive parent-child relation are identified by naming convention or 
aliases NODE_ID (node) and PARENT_ID (parent). The data type of PARENT_ID and NODE_ID must be 
identical, and must belong to one of the following data types:
● Numeric types: TINYINT, SMALLINT, INTEGER, BIGINT, SMALLDECIMAL, DECIMAL
● Character string types: VARCHAR, NVARCHAR, ALPHANUM, SHORTTEXT
● Datetime types: DATE, TIME, SECONDDATE, TIMESTAMP
● Binary types: VARBINARY
hierarchy_genfunc_start_cond
Specifies the start condition to identify the root nodes.
<hierarchy_genfunc_start_cond> ::= START WHERE <cond>
The start condition is applied as an additional WHERE filter to the SOURCE specification. If a START 
specification is not specified, then root nodes are identified by the condition WHERE PARENT_ID IS 
NULL.Specifies the maximum traversal depth during hierarchy generation.
hierarchy_genfunc_depth_spec
<hierarchy_genfunc_depth_spec> ::= DEPTH <integer>
<hierarchy_genfunc_depth_spec>Specifies the maximum traversal depth during hierarchy can 
improve the performance for ad-hoc queries with known maximum depths. A predefined maximum depth 
can also be useful when working with directed graph topologies. Start nodes/roots have a depth of 0. If 
depth is set to less than 0, then the query returns and empty result set.
hierarchy_genfunc_orphan_spec
Specifies the orphan processing policy.
<hierarchy_genfunc_orphan_spec> ::= ORPHAN IGNORE 
 | ORPHAN ERROR 
 | ORPHAN ADOPT 
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 133
 | ORPHAN ROOT
Orphans are source nodes that cannot be reached from any root node.
<hierarchy_genfunc_orphan_spec> and <hierarchy_genfunc_depth_spec> cannot be used at 
the same time. If a maximum search depth is specified, then orphaned nodes are always ignored.
IGNORE
Orphans are silently ignored. This is the default behavior.
ERROR
The input data contains any orphans, an error is raised.
ROOT
Top-level orphans are treated as root nodes.
ADOPT
Orphans are adopted as children of the last root behind its regular descendants, and their 
HIERARCHY_IS_ORPHAN value is set to 1.
During orphan handling (that is, ORPHAN ROOT or ORPHAN ADOPT), only edges that have not been 
traversed when starting from a regular root node are considered. For these edges, the 
HIERARCHY_IS_ORPHAN value is set to 1. The original source attribute values are retained.
In case of an orphaned cycle, an additional edge is introduced in order to link the orphaned cycle to the 
rest of the hierarchy. Since there is no corresponding input data for this edge, its source attributes are set 
to NULL except for the NODE_ID, which reflects the value of the end point of the newly introduced edge.
hierarchy_genfunc_cache_spec
Specifies the caching policy for the generated hierarchy result.
<hierarchy_genfunc_cache_spec> ::= CACHE 
 | NO CACHE | CACHE FORCE
Caching may improve the performance for subsequent navigations on the same hierarchy.
CACHE
The generated hierarchy is cached if the system assesses the source to be reliably deterministic. This 
is the default behavior.
NO CACHE
The generated hierarchy is not cached.
FORCE CACHE
The generated hierarchy is cached even if the source cannot be assessed to be reliably deterministic.
Description
The HIERARCHY function calculates hierarchical attributes for each edge and vertex based on a tabular 
SOURCE containing an adjacency list (columns that form a recursive parent-child relation between rows of the 
source data). The source columns carrying the particular recursive semantics must be named or aliased as 
NODE_ID and PARENT_ID.
134 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
The result table returned by the HIERARCHY function provides the following hierarchical output attributes. In 
the Value range column, N represents the number of output nodes in the tree representation of the hierarchy.
Output attribute Data type Value range Description
HIERARCHY_RANK BIGINT (NOT NULL) [1,N] The preorder rank of the 
node in the tree 
representation of the result 
set. HIERARCHY_RANK also 
serves as primary key of the 
hierarchy node.
HIERARCHY_TREE_SIZE BIGINT (NOT NULL) [1,N] The number of descendant 
nodes +1.
HIERARCHY_PARENT_RAN
K
BIGINT (NOT NULL) [0,N-1] The preorder rank of the 
parent node. The 
HIERARCHY_PARENT_RAN
K of root nodes is 0.
HIERARCHY_LEVEL INTEGER (NOT NULL) [1,N] The distance from the root 
node +1.
HIERARCHY_IS_CYCLE TINYINT (NOT NULL) [0,1] A value indicating whether 
the current edge has closed 
a cycle (1), or not (0). Closed 
cycles are not recursed 
further.
HIERARCHY_IS_ORPHAN TINYINT (NOT NULL) [0,1] Avalue indicating whether 
the current edge has been 
traversed during orphan 
handling (1) or not (0).
... ... ... All columns of the source 
specification.
Example
All examples are based on the following source dataset:
CREATE SCHEMA "my_schema"; CREATE COLUMN TABLE "my_schema"."t_demo" ( Parent VARCHAR(2), ID VARCHAR(2), 
Type VARCHAR(1), Ord INTEGER, Amount INTEGER );
INSERT INTO "my_schema"."t_demo" VALUES ( null, 'A1', 'a', 1, 50 );
INSERT INTO "my_schema"."t_demo" VALUES ( 'A1', 'B1', 'b', 1, 120 );
INSERT INTO "my_schema"."t_demo" VALUES ( 'A1', 'B2', 'c', 2, 90 );
INSERT INTO "my_schema"."t_demo" VALUES ( 'B1', 'C1', 'a', 1, 40 );
INSERT INTO "my_schema"."t_demo" VALUES ( 'B1', 'C2', 'b', 2, 60 );
INSERT INTO "my_schema"."t_demo" VALUES ( 'B2', 'C3', 'c', 3, 75 );
INSERT INTO "my_schema"."t_demo" VALUES ( 'B2', 'C4', 'a', 4, 30 );
INSERT INTO "my_schema"."t_demo" VALUES ( 'C3', 'D1', 'b', 1, 10 );
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 135
INSERT INTO "my_schema"."t_demo" VALUES ( 'C3', 'D2', 'c', 2, 25 );
INSERT INTO "my_schema"."t_demo" VALUES ( 'C4', 'D3', 'a', 3, 30 );
INSERT INTO "my_schema"."t_demo" VALUES ( null, 'A2', 'b', 2, 80 );
INSERT INTO "my_schema"."t_demo" VALUES ( 'A2', 'B3', 'c', 3, 45 ); INSERT INTO "my_schema"."t_demo" VALUES ( 'A2', 'C4', 'a', 4, 30 );
Example: You calculate all hierarchy attributes of all edges and nodes starting from the default condition 
(WHERE PARENT_ID IS NULL), and force the results to be cached:
SELECT hierarchy_rank AS "rank", hierarchy_tree_size AS "tree_size",
 hierarchy_parent_rank AS "parent_rank",
 hierarchy_level AS "level",
 hierarchy_is_cycle AS "is_cycle",
 hierarchy_is_orphan AS "is_orphan",
 node_id,
 parent_id,
 type 
 FROM HIERARCHY ( 
 SOURCE ( SELECT id AS node_id, parent AS parent_id, type
 FROM "my_schema"."t_demo"
 ORDER BY ord )
 CACHE FORCE ) ORDER BY hierarchy_rank;
RANK TREE_SIZE PARENT_RA
NK
LEVEL IS_CYCLE IS_ORPHAN NODE_ID PARENT_ID TYPE
1 10 0 1 0 0 A1 ? a
2 3 1 2 0 0 B1 A1 b
3 1 2 3 0 0 C1 B1 a
4 1 2 3 0 0 C2 B1 b
5 6 1 2 0 0 B2 A1 c
6 3 5 3 0 0 C3 B2 c
7 1 6 4 0 0 D1 C3 b
8 1 6 4 0 0 D2 C3 c
9 2 5 3 0 0 C4 B2 a
10 1 9 4 0 0 D3 C4 a
11 4 0 1 0 0 A2 ? b
12 1 11 2 0 0 B3 A2 c
13 2 11 2 0 0 C4 A2 a
14 1 13 3 0 0 D3 C4 a
136 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
Nodes that are orphaned, such as in the case of the nodes with HIERARCHY_RANK 10 and 11, retain their 
original PARENT_ID value (NULL in this case, which is represented as a question mark, '?', in SAP HANA 
Studio).
Example: You determine the set of descendants of node A1 with a depth horizon of 2 (that is, down to level C), 
ignoring other nodes:
SELECT node_id FROM HIERARCHY ( SOURCE ( SELECT id AS node_id, parent AS parent_id FROM 
"my_schema"."t_demo" )
 START WHERE id = 'A1'
 DEPTH 2
 ORPHAN IGNORE )
 WHERE hierarchy_level > 1 ORDER BY node_id;
NODE_ID
B1
B2
C1
C2
C3
C4
Example: You calculate all hierarchy attributes starting from B1 and B2, and orphaned nodes become top level 
nodes:
SELECT hierarchy_rank AS "rank", hierarchy_tree_size AS "tree_size",
 hierarchy_parent_rank AS "parent_rank",
 hierarchy_level AS "level",
 hierarchy_is_cycle AS "is_cycle",
 hierarchy_is_orphan AS "is_orphan",
 node_id,
 parent_id,
 type 
 FROM HIERARCHY ( SOURCE ( SELECT id AS node_id, parent AS parent_id, type FROM 
"my_schema"."t_demo" ORDER BY ord )
 START WHERE id IN ('B1', 'B2')
 ORPHAN ROOT ) ORDER BY hierarchy_rank;
RANK TREE_SIZE PARENT_RA
NK
LEVEL IS_CYCLE IS_ORPHAN NODE_ID PARENT_ID TYPE
1 3 0 1 0 0 B1 A1 b
2 1 1 2 0 0 C1 B1 a
3 1 1 2 0 0 C2 B1 b
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 137
RANK TREE_SIZE PARENT_RA
NK
LEVEL IS_CYCLE IS_ORPHAN NODE_ID PARENT_ID TYPE
4 6 0 1 0 0 B2 A1 c
5 3 4 2 0 0 C3 B2 c
6 1 5 3 0 0 D1 C3 b
7 1 5 3 0 0 D2 C3 c
8 2 4 2 0 0 C4 B2 a
9 1 8 3 0 0 D3 C4 a
10 1 0 1 0 1 A1 ? a
11 3 0 1 0 1 A2 ? b
12 1 11 2 0 1 B3 A2 c
13 1 11 2 0 1 C4 A2 a
Example: You calculate all hierarchy attributes starting from all B* nodes, orphaned nodes will be adopted by 
B3, which is the last root node in pre-order traversal:
SELECT hierarchy_rank AS "rank", hierarchy_tree_size AS "tree_size",
 hierarchy_parent_rank AS "parent_rank",
 hierarchy_level AS "level",
 hierarchy_is_cycle AS "is_cycle",
 hierarchy_is_orphan AS "is_orphan",
 node_id,
 parent_id,
 type 
 FROM HIERARCHY ( SOURCE ( SELECT id AS node_id, parent AS parent_id, type FROM 
"my_schema"."t_demo" ORDER BY ord )
 START WHERE id LIKE 'B%'
 ORPHAN ADOPT ) ORDER BY hierarchy_rank;
RANK TREE_SIZE PARENT_RA
NK
LEVEL IS_CYCLE IS_ORPHAN NODE_ID PARENT_ID TYPE
1 3 0 1 0 0 B1 A1 b
2 1 1 2 0 0 C1 B1 a
3 1 1 2 0 0 C2 B1 b
4 6 0 1 0 0 B2 A1 c
5 3 4 2 0 0 C3 B2 c
6 1 5 3 0 0 D1 C3 b
138 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
RANK TREE_SIZE PARENT_RA
NK
LEVEL IS_CYCLE IS_ORPHAN NODE_ID PARENT_ID TYPE
7 1 5 3 0 0 D2 C3 c
8 2 4 2 0 0 C4 B2 a
9 1 8 3 0 0 D3 C4 a
10 4 0 1 0 0 B3 A2 c
11 1 10 2 0 1 A1 ? a
12 2 10 2 0 1 A2 ? b
13 1 12 3 0 1 C4 A2 a
You can tell the parents that adopted the orphaned nodes by looking at the HIERARCHY_PARENT_RANK (or 
PARENT_RANK, in the results) value. For example, orphaned nodes A1 and A2 show they have been adopted 
by HIERARCHY_PARENT_RANK 10, which is node B3.
Example: You determine the ancestors of node D1 up to the roots (note the reversal of NODE_ID, PARENT_ID 
columns in the SOURCE specification):
SELECT parent_id, node_id FROM HIERARCHY ( SOURCE ( SELECT parent AS node_id, id AS parent_id FROM 
"my_schema"."t_demo" ORDER BY ord )
 START WHERE id = 'D1'
 ORPHAN IGNORE ) ORDER BY hierarchy_rank;
PARENT_ID NODE_ID
D1 C3
C3 B2
B2 A1
Example: You determine siblings of node C4, including C4:
WITH h AS ( SELECT * FROM HIERARCHY ( SOURCE ( SELECT parent AS node_id, id AS parent_id FROM 
"my_schema"."t_demo" ORDER BY ord ) ) )
 SELECT DISTINCT h2.node_id
 FROM h AS h1, h AS h2
 WHERE h1.node_id = 'C4' AND h1.parent_id = h2.parent_id ORDER BY h2.node_id;
NODE_ID
B3
C3
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 139
NODE_ID
C4
Example: You sort hierarchy result in post order:
SELECT hierarchy_rank AS "rank", hierarchy_tree_size AS "tree_size",
 hierarchy_parent_rank AS "parent_rank",
 hierarchy_level AS "level",
 hierarchy_is_cycle AS "is_cycle",
 hierarchy_is_orphan AS "is_orphan",
 node_id,
 parent_id,
 type 
 FROM HIERARCHY ( SOURCE ( SELECT id AS node_id, 
 parent AS parent_id, 
 type
 FROM "my_schema"."t_demo"
 ORDER BY ord ) ) ORDER BY hierarchy_rank + hierarchy_tree_size ASC, hierarchy_rank DESC;
RANK TREE_SIZE PARENT_RA
NK
LEVEL IS_CYCLE IS_ORPHAN NODE_ID PARENT_ID TYPE
3 1 2 3 0 0 C1 B1 a
4 1 2 3 0 0 C2 B1 b
2 3 1 2 0 0 B1 A1 b
7 1 6 4 0 0 D1 C3 b
8 1 6 4 0 0 D2 C3 c
6 3 5 3 0 0 C3 B2 c
10 1 9 4 0 0 D3 C4 a
9 2 5 3 0 0 C4 B2 a
5 6 1 2 0 0 B2 A1 c
1 10 0 1 0 0 A1 ? a
12 1 11 2 0 0 B3 A2 c
14 1 13 3 0 0 D3 C4 a
13 2 11 2 0 0 C4 A2 a
11 4 0 1 0 0 A2 ? b
Example: You perform a connectivity test between two sets of nodes, following edges in both directions:
WITH h AS ( 
140 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
 SELECT * FROM HIERARCHY ( SOURCE ( SELECT id AS node_id, parent AS parent_id 
FROM "my_schema"."t_demo" ) ) )
 SELECT DISTINCT h1.node_id AS node_set_1, h2.node_id AS node_set_2
 FROM h AS h1, h AS h2
 WHERE h1.node_id IN ( SELECT id FROM "my_schema"."t_demo" WHERE type = 
'a' ) -- node_set_1
 AND h2.node_id IN ( SELECT id FROM "my_schema"."t_demo" WHERE id LIKE 'D%' ) -- node_set_2
 AND ( h2.hierarchy_rank BETWEEN h1.hierarchy_rank AND h1.hierarchy_rank + 
h1.hierarchy_tree_size - 1
 OR h1.hierarchy_rank BETWEEN h2.hierarchy_rank AND h2.hierarchy_rank + 
h2.hierarchy_tree_size - 1 ) ORDER BY node_set_1, node_set_2;
NODE_SET_1 NODE_SET_2
A1 D1
A1 D2
A1 D3
C4 D3
D3 D3
Example: You perform an adhoc query of a hierarchy that has composite node identifiers (keys). The 
individual components are projected as well:
CREATE COLUMN TABLE "my_schema"."t_demo_composite" ( parent_1 VARCHAR(1), 
 parent_2 INTEGER, 
 id_1 VARCHAR(1), 
 id_2 INTEGER, 
 type VARCHAR(1), 
 ord INTEGER );
INSERT INTO "my_schema"."t_demo_composite" VALUES ( 'R', 0, 'A', 1, 'a', 1 );
INSERT INTO "my_schema"."t_demo_composite" VALUES ( 'A', 1, 'B', 1, 'b', 1 );
INSERT INTO "my_schema"."t_demo_composite" VALUES ( 'A', 1, 'B', 2, 'c', 2 );
SELECT hierarchy_rank AS "rank", 
 hierarchy_tree_size AS "tree_size",
 hierarchy_parent_rank AS "parent_rank",
 hierarchy_level AS "level",
 hierarchy_is_cycle AS "is_cycle",
 hierarchy_is_orphan AS "is_orphan",
 node_id,
 parent_id,
 type 
 FROM HIERARCHY ( SOURCE ( SELECT id_1||id_2 AS node_id,
 parent_1||parent_2 AS parent_id,
 id_1,
 id_2,
 parent_1,
 parent_2,
 type
 FROM "my_schema"."t_demo_composite"
 ORDER BY ord )
 START WHERE parent_1 = 'R' ) ORDER BY hierarchy_rank;
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 141
RANK TREE_SIZE PARENT_RA
NK
LEVEL IS_CYCLE IS_ORPHAN NODE_ID PARENT_ID TYPE
1 3 0 1 0 0 A1 R0 a
2 1 1 2 0 0 B1 A1 b
3 1 1 2 0 0 B2 A1 c
Related Information
Hierarchy Functions [page 277]
HIERARCHY_ANCESTORS Function (Hierarchy) [page 142]
HIERARCHY_DESCENDANTS Function (Hierarchy) [page 146]
HIERARCHY_SIBLINGS Function (Hierarchy) [page 150]
SAP HANA Platform
2.8.1.73 HIERARCHY_ANCESTORS Function (Hierarchy)
Returns all ancestors of a set of start nodes in a hierarchy.
Syntax
HIERARCHY_ANCESTORS ( <hierarchy_navfunc_source_spec> <hierarchy_navfunc_start_spec> [<opt_hierarchy_navfunc_distance_spec>] )
Syntax Elements
hierarchy_navfunc_source_spec
Specifies a hierarchy for the function to operate on.
<hierarchy_navfunc_source_spec> ::= SOURCE { <table> | <hierarchy_generator_function> }
table
142 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
http://help.sap.com/hana_platform/
Specifies a view or materialized result set, such as a table, containing all of the attributes computed by 
the HIERARCHY generator function.
hierarchy_generator_function
Specifies the unfiltered results of a hierarchy generator function (for example, the HIERARCHY 
function) containing all of the attributes computed by the HIERARCHY generator function.
hierarchy_navfunc_start_spec
Specifies the start nodes as an additional input table or as a filter condition on the source.
<hierarchy_navfunc_start_spec> ::= START { <table_valued_expression> | WHERE <cond> }
table_valued_expression
Specifies a table-valued expression containing, at minimum, a column called START_RANK that has a 
data type that can be cast to BIGINT.
cond
Specifies a starting condition that is semantically equivalent to START ( SELECT hierarchy_rank 
AS start_rank FROM <source> WHERE <cond>).
opt_hierarchy_navfunc_distance_spec
Specifies a distance window filtering the function result.
<opt_hierarchy_navfunc_distance_spec> ::= DISTANCE { FROM <expression> | TO <expression> | FROM <expression> TO <expression> }
If FROM <expression> is not specified, the hierarchy source's maximum depth, multiplied by -1, is taken 
as the default distance. If TO <expression> is not specified, 0 is taken as the default distance.
Description
The HIERARCHY_ANCESTORS function extracts upward-directed branches from a given hierarchy starting 
from and including a known set of start nodes. Due to its flexibility, the HIERARCHY_ANCESTORS function 
provides an efficient means for several types of typical hierarchy navigation such as the determination of 
parents, relevant roots and the respective paths, or connectivity tests.
Column-wise, the function projects all attributes of the source hierarchy plus a lateral projections of the 
corresponding START record. Additionally, a HIERARCHY_DISTANCE column is generated.
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 143
Example
The following examples are based on a materialized hierarchy result set created with the following statements. 
However, typically such a hierarchy is generated by a hierarchy generator function.
CREATE SCHEMA "my_schema"; CREATE COLUMN TABLE "my_schema"."h_demo" ( 
 hierarchy_rank BIGINT,
 hierarchy_tree_size BIGINT,
 hierarchy_parent_rank BIGINT,
 hierarchy_level INTEGER,
 hierarchy_is_cycle TINYINT,
 hierarchy_is_orphan TINYINT,
 parent_id VARCHAR(2),
 node_id VARCHAR(2),
 type VARCHAR(1),
 amount INTEGER );
 
INSERT INTO "my_schema"."h_demo" VALUES ( 1, 10, 0, 1, 0, 0, null, 'A1', 'a', 
50 );
INSERT INTO "my_schema"."h_demo" VALUES ( 2, 3, 1, 2, 0, 0, 'A1', 'B1', 'b', 
120 );
INSERT INTO "my_schema"."h_demo" VALUES ( 3, 1, 2, 3, 0, 0, 'B1', 'C1', 'a', 
40 );
INSERT INTO "my_schema"."h_demo" VALUES ( 4, 1, 2, 3, 0, 0, 'B1', 'C2', 'b', 
60 );
INSERT INTO "my_schema"."h_demo" VALUES ( 5, 6, 1, 2, 0, 0, 'A1', 'B2', 'c', 
90 );
INSERT INTO "my_schema"."h_demo" VALUES ( 6, 3, 5, 3, 0, 0, 'B2', 'C3', 'c', 
75 );
INSERT INTO "my_schema"."h_demo" VALUES ( 7, 1, 6, 4, 0, 0, 'C3', 'D1', 'b', 
10 );
INSERT INTO "my_schema"."h_demo" VALUES ( 8, 1, 6, 4, 0, 0, 'C3', 'D2', 'c', 
25 );
INSERT INTO "my_schema"."h_demo" VALUES ( 9, 2, 5, 3, 0, 0, 'B2', 'C4', 'a', 
30 );
INSERT INTO "my_schema"."h_demo" VALUES ( 10, 1, 9, 4, 0, 0, 'C4', 'D3', 'a', 
30 );
INSERT INTO "my_schema"."h_demo" VALUES ( 11, 4, 0, 1, 0, 0, null, 'A2', 'b', 
80 );
INSERT INTO "my_schema"."h_demo" VALUES ( 12, 1, 11, 2, 0, 0, 'A2', 'B3', 'c', 
45 );
INSERT INTO "my_schema"."h_demo" VALUES ( 13, 2, 11, 2, 0, 0, 'A2', 'C4', 'a', 
30 ); INSERT INTO "my_schema"."h_demo" VALUES ( 14, 1, 13, 3, 0, 0, 'C4', 'D3', 'a', 
30 );
You determine the set of ancestors of node C4:
SELECT DISTINCT node_id, hierarchy_distance FROM HIERARCHY_ANCESTORS ( SOURCE "my_schema"."h_demo" 
 START WHERE node_id = 'C4' ) ORDER BY node_id;
NODE_ID HIERARCHY_DISTANCE
A1 -2
A2 -1
B2 -1
144 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
NODE_ID HIERARCHY_DISTANCE
C4 0
You calculate the grandparents of nodes C1 and D1
SELECT start_id, 
 node_id AS grandparent_id, 
 hierarchy_level
 FROM HIERARCHY_ANCESTORS ( SOURCE "my_schema"."h_demo"
 START ( SELECT hierarchy_rank AS start_rank, node_id 
AS start_id 
 FROM "my_schema"."h_demo" WHERE node_id IN 
('C1', 'D1') )
 DISTANCE FROM -2 TO -2 ) ORDER BY start_rank ASC, hierarchy_rank DESC;
START_ID GRANDPARENT_ID HIERARCHY_LEVEL
C1 A1 1
D1 B2 2
Find the nearest common ancestor of nodes D1 and D3, either based on a set operation (syntax 1 below), or 
based on a join and hierarchy attribute calculations (syntax 2 below):
SELECT TOP 1 node_id,
 hierarchy_level FROM ( SELECT node_id, hierarchy_level 
 FROM HIERARCHY_ANCESTORS ( SOURCE 
"my_schema"."h_demo" START WHERE node_id = 'D1' )
 INTERSECT
 SELECT node_id, hierarchy_level 
 FROM HIERARCHY_ANCESTORS ( SOURCE 
"my_schema"."h_demo" START WHERE node_id = 'D3') 
 ) ORDER BY hierarchy_level DESC;SELECT TOP 1 a.node_id,
 a.hierarchy_level
 FROM HIERARCHY_ANCESTORS (
 SOURCE "my_schema"."h_demo"
 START WHERE node_id = 'D1' ) AS a
 INNER JOIN "my_schema"."h_demo" AS h ON h.node_id = 'D3'
 AND h.hierarchy_rank BETWEEN a.hierarchy_rank AND a.hierarchy_rank + 
a.hierarchy_tree_size - 1 ORDER BY a.hierarchy_level DESC;
Results from either syntax:
NODE_ID HIERARCHY_LEVEL
B2 2
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 145
Related Information
Hierarchy Functions [page 277]
HIERARCHY Function (Hierarchy) [page 132]
HIERARCHY_DESCENDANTS Function (Hierarchy) [page 146]
HIERARCHY_SIBLINGS Function (Hierarchy) [page 150]
SAP HANA Platform
2.8.1.74 HIERARCHY_DESCENDANTS Function (Hierarchy)
Returns all descendants of a set of start nodes in a hierarchy.
Syntax
HIERARCHY_DESCENDANTS ( <hierarchy_navfunc_source_spec> <hierarchy_navfunc_start_spec> [<opt_hierarchy_navfunc_distance_spec>] )
Syntax Elements
hierarchy_navfunc_source_spec
Specifies a hierarchy for the function to operate on.
<hierarchy_navfunc_source_spec> ::= SOURCE { <table> | <hierarchy_generator_function> }
table
Specifies a view or materialized result set, such as a table, containing all of the attributes computed by 
the HIERARCHY generator function.
hierarchy_generator_function
Specifies the unfiltered results of a hierarchy generator function (for example, the HIERARCHY 
function) containing all of the attributes computed by the HIERARCHY generator function.
hierarchy_navfunc_start_spec
Specifies the start nodes as an additional input table or as a filter condition on the source.
<hierarchy_navfunc_start_spec> ::= START { <table_valued_expression> | WHERE <cond> 
146 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
http://help.sap.com/hana_platform/
 }
table_valued_expression
Specifies a table-valued expression containing, at minimum, a column called START_RANK that has a 
data type that can be cast to BIGINT.
cond
Specifies a starting condition that is semantically equivalent to START ( SELECT hierarchy_rank 
AS start_rank FROM <source> WHERE <cond>).
opt_hierarchy_navfunc_distance_spec
Specifies a distance window filtering the function result.
<opt_hierarchy_navfunc_distance_spec> ::= DISTANCE { FROM <expression> | TO <expression> | FROM <expression> TO <expression> }
If FROM <expression> is not specified, then 0 is taken as the default distance. If TO <expression> is 
not specified, then the maximum depth of the hierarchy's source is used as the default distance. For 
descendants navigation, all valid distances are greater than or equal to 0.
Description
The HIERARCHY_DESCENDANTS function extracts partial trees from a given hierarchy starting from and 
including a known set of start nodes. The result can be prefiltered by a distance window.
Column-wise, the function projects all attributes of the source hierarchy plus a lateral projections of the 
corresponding START record. Additionally, a HIERARCHY_DISTANCE column is generated.
Due to its flexibility, the HIERARCHY_DESCENDANTS function provides an efficient means for several typical 
types of hierarchy navigation such as the determination of children, subordinate leaves, subtrees, or 
connectivity tests.
Example
The following examples are based on a materialized hierarchy result set created with the following statements. 
However, typically such a hierarchy is generated by a hierarchy generator function.
CREATE SCHEMA "my_schema"; CREATE COLUMN TABLE "my_schema"."h_demo" ( 
 hierarchy_rank BIGINT,
 hierarchy_tree_size BIGINT,
 hierarchy_parent_rank BIGINT,
 hierarchy_level INTEGER,
 hierarchy_is_cycle TINYINT,
 hierarchy_is_orphan TINYINT,
 parent_id VARCHAR(2),
 node_id VARCHAR(2),
 type VARCHAR(1),
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 147
 amount INTEGER );
 
INSERT INTO "my_schema"."h_demo" VALUES ( 1, 10, 0, 1, 0, 0, null, 'A1', 'a', 
50 );
INSERT INTO "my_schema"."h_demo" VALUES ( 2, 3, 1, 2, 0, 0, 'A1', 'B1', 'b', 
120 );
INSERT INTO "my_schema"."h_demo" VALUES ( 3, 1, 2, 3, 0, 0, 'B1', 'C1', 'a', 
40 );
INSERT INTO "my_schema"."h_demo" VALUES ( 4, 1, 2, 3, 0, 0, 'B1', 'C2', 'b', 
60 );
INSERT INTO "my_schema"."h_demo" VALUES ( 5, 6, 1, 2, 0, 0, 'A1', 'B2', 'c', 
90 );
INSERT INTO "my_schema"."h_demo" VALUES ( 6, 3, 5, 3, 0, 0, 'B2', 'C3', 'c', 
75 );
INSERT INTO "my_schema"."h_demo" VALUES ( 7, 1, 6, 4, 0, 0, 'C3', 'D1', 'b', 
10 );
INSERT INTO "my_schema"."h_demo" VALUES ( 8, 1, 6, 4, 0, 0, 'C3', 'D2', 'c', 
25 );
INSERT INTO "my_schema"."h_demo" VALUES ( 9, 2, 5, 3, 0, 0, 'B2', 'C4', 'a', 
30 );
INSERT INTO "my_schema"."h_demo" VALUES ( 10, 1, 9, 4, 0, 0, 'C4', 'D3', 'a', 
30 );
INSERT INTO "my_schema"."h_demo" VALUES ( 11, 4, 0, 1, 0, 0, null, 'A2', 'b', 
80 );
INSERT INTO "my_schema"."h_demo" VALUES ( 12, 1, 11, 2, 0, 0, 'A2', 'B3', 'c', 
45 );
INSERT INTO "my_schema"."h_demo" VALUES ( 13, 2, 11, 2, 0, 0, 'A2', 'C4', 'a', 
30 ); INSERT INTO "my_schema"."h_demo" VALUES ( 14, 1, 13, 3, 0, 0, 'C4', 'D3', 'a', 
30 );
You determine the set of descendants of node A1 with a depth horizon of 2 (that is, down to level C):
SELECT node_id, HIERARCHY_DISTANCE FROM HIERARCHY_DESCENDANTS ( SOURCE "my_schema"."h_demo"
 START WHERE node_id = 'A1'
 DISTANCE FROM 1 TO 2 ) ORDER BY hierarchy_rank;
NODE_ID HIERARCHY_DISTANCE
B1 1
C1 2
C2 2
B2 1
C3 2
C4 2
You calculate the complete partial hierarchies with all attributes starting from B1 and B2:
SELECT hierarchy_rank AS "rank", hierarchy_tree_size AS "tree_size",
 hierarchy_parent_rank AS "parent_rank",
 hierarchy_level AS "level",
 hierarchy_is_cycle AS "is_cycle",
 hierarchy_is_orphan AS "is_orphan",
 parent_id,
148 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
 node_id,
 type, 
 amount AS "amt",
 hierarchy_distance AS "distance",
 start_rank AS "s_rank",
 start_id AS "s_id"
 FROM HIERARCHY_DESCENDANTS ( SOURCE "my_schema"."h_demo"
 START ( SELECT hierarchy_rank AS start_rank, 
node_id AS start_id 
 FROM "my_schema"."h_demo" WHERE node_id 
IN ('B1', 'B2') ) 
 ) ORDER BY hierarchy_rank;
Rank Tree_Si
ze
Parent_
Rank
Level Cycle Is_Orph
an
Parent Node TYPE Amt DISTAN
CE
S_-
Rank
S_ID
2 3 1 2 0 A1 B1 b 120 0 2 B1
3 1 2 3 0 B2 C1 a 40 1 2 B1
4 1 2 3 0 B1 C2 b 60 1 2 B1
5 6 1 2 0 A1 B2 c 90 0 5 B2
6 3 5 3 0 B2 C3 c 75 1 5 B2
7 1 6 4 0 C3 D1 b 10 2 5 B2
8 1 6 4 0 C3 D2 c 25 2 5 B2
9 2 5 3 0 B2 C4 a 30 1 5 B2
10 1 9 4 0 C4 D3 a 30 2 5 B2
Count the leaves below all nodes of type 'b':
SELECT start_id AS node_id,
 COUNT(*) AS num_leaves
 FROM ( SELECT start_id 
 FROM HIERARCHY_DESCENDANTS ( SOURCE "my_schema"."h_demo"
 START ( SELECT hierarchy_rank AS start_rank, 
node_id AS start_id 
 FROM "my_schema"."h_demo" WHERE 
type ='b' ) )
 WHERE hierarchy_tree_size = 1 
 ) GROUP BY start_id;
NODE_ID NUM_LEAVES
B1 2
C2 1
D1 1
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 149
NODE_ID NUM_LEAVES
A2 2
Related Information
Hierarchy Functions [page 277]
HIERARCHY Function (Hierarchy) [page 132]
HIERARCHY_ANCESTORS Function (Hierarchy) [page 142]
HIERARCHY_SIBLINGS Function (Hierarchy) [page 150]
SAP HANA Platform
2.8.1.75 HIERARCHY_SIBLINGS Function (Hierarchy)
Returns all siblings of a set of start nodes, including the start nodes, in a hierarchy.
Syntax
HIERARCHY_SIBLINGS ( <hierarchy_navfunc_source_spec> <hierarchy_navfunc_start_spec> )
Syntax Elements
hierarchy_navfunc_source_spec
Specifies a hierarchy for the function to operate on.
<hierarchy_navfunc_source_spec> ::= SOURCE { <table> | <hierarchy_generator_function>}
table
Specifies a view or materialized result set, such as a table, containing all of the attributes computed by 
the HIERARCHY generator function.
hierarchy_generator_function
Specifies the unfiltered results of a hierarchy generator function (for example, the HIERARCHY 
function) containing all of the attributes computed by the HIERARCHY generator function.
150 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
http://help.sap.com/hana_platform/
hierarchy_navfunc_start_spec
Specifies the start nodes as an additional input table or as a filter condition on the source.
<hierarchy_navfunc_start_spec> ::= START { <table_valued_expression> | WHERE <cond> }
table_valued_expression
Specifies a table-valued expression containing, at minimum, a column called START_RANK that has a 
data type that can be cast to BIGINT.
cond
Specifies a starting condition that is semantically equivalent to START ( SELECT hierarchy_rank 
AS start_rank FROM <source> WHERE <cond>).
Description
The HIERARCHY_SIBLINGS function returns siblings of a given node with particular relative locations, such as 
the first sibling (minimum distance), next preceding sibling (highest distance less than 0), next following 
sibling (lowest distance greater than 0), and last sibling (maximum distance).
Column-wise, the function projects all attributes of the source hierarchy plus a lateral projections of the 
corresponding START record. Additionally, a HIERARCHY_SIBLING_DISTANCE column is generated.
Example
The following examples are based on a materialized hierarchy result set created with the following statements. 
However, typically such a hierarchy is generated by a hierarchy generator function.
CREATE SCHEMA "my_schema"; CREATE COLUMN TABLE "my_schema"."h_demo" ( 
 hierarchy_rank BIGINT,
 hierarchy_tree_size BIGINT,
 hierarchy_parent_rank BIGINT,
 hierarchy_level INTEGER,
 hierarchy_is_cycle TINYINT,
 hierarchy_is_orphan TINYINT,
 parent_id VARCHAR(2),
 node_id VARCHAR(2),
 type VARCHAR(1),
 amount INTEGER );
 
INSERT INTO "my_schema"."h_demo" VALUES ( 1, 10, 0, 1, 0, 0, null, 'A1', 'a', 
50 );
INSERT INTO "my_schema"."h_demo" VALUES ( 2, 3, 1, 2, 0, 0, 'A1', 'B1', 'b', 
120 );
INSERT INTO "my_schema"."h_demo" VALUES ( 3, 1, 2, 3, 0, 0, 'B1', 'C1', 'a', 
40 );
INSERT INTO "my_schema"."h_demo" VALUES ( 4, 1, 2, 3, 0, 0, 'B1', 'C2', 'b', 
60 );
INSERT INTO "my_schema"."h_demo" VALUES ( 5, 6, 1, 2, 0, 0, 'A1', 'B2', 'c', 
90 );
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 151
INSERT INTO "my_schema"."h_demo" VALUES ( 6, 3, 5, 3, 0, 0, 'B2', 'C3', 'c', 
75 );
INSERT INTO "my_schema"."h_demo" VALUES ( 7, 1, 6, 4, 0, 0, 'C3', 'D1', 'b', 
10 );
INSERT INTO "my_schema"."h_demo" VALUES ( 8, 1, 6, 4, 0, 0, 'C3', 'D2', 'c', 
25 );
INSERT INTO "my_schema"."h_demo" VALUES ( 9, 2, 5, 3, 0, 0, 'B2', 'C4', 'a', 
30 );
INSERT INTO "my_schema"."h_demo" VALUES ( 10, 1, 9, 4, 0, 0, 'C4', 'D3', 'a', 
30 );
INSERT INTO "my_schema"."h_demo" VALUES ( 11, 4, 0, 1, 0, 0, null, 'A2', 'b', 
80 );
INSERT INTO "my_schema"."h_demo" VALUES ( 12, 1, 11, 2, 0, 0, 'A2', 'B3', 'c', 
45 );
INSERT INTO "my_schema"."h_demo" VALUES ( 13, 2, 11, 2, 0, 0, 'A2', 'C4', 'a', 
30 ); INSERT INTO "my_schema"."h_demo" VALUES ( 14, 1, 13, 3, 0, 0, 'C4', 'D3', 'a', 
30 );
You determine the set of siblings of node C4:
SELECT DISTINCT node_id, hierarchy_sibling_distance FROM HIERARCHY_SIBLINGS ( SOURCE "my_schema"."h_demo"
 START WHERE node_id = 'C4' ) ORDER BY node_id;
NODE_ID HIERARCHY_SIBLING_DISTANCE
B3 -1
C3 -3
C4 0
You find the next following sibling of node B1:
SELECT TOP 1 node_id FROM HIERARCHY_SIBLINGS ( SOURCE "my_schema"."h_demo"
 START WHERE node_id = 'B1' )
 WHERE hierarchy_sibling_distance > 0 ORDER BY hierarchy_sibling_distance ASC;
NODE_ID
B2
Related Information
Hierarchy Functions [page 277]
HIERARCHY Function (Hierarchy) [page 132]
HIERARCHY_ANCESTORS Function (Hierarchy) [page 142]
HIERARCHY_DESCENDANTS Function (Hierarchy) [page 146]
SAP HANA Platform
152 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
http://help.sap.com/hana_platform/
2.8.1.76 HOUR Function (Datetime)
Returns an integer representation of the hour for the specified time.
Syntax
HOUR (<t>)
Description
Returns an integer representation of the hour for time <t>.
Example
The following example returns the hour 12:
SELECT HOUR ('12:34:56') "hour" FROM DUMMY;
2.8.1.77 IFNULL Function (Miscellaneous)
Returns the first non-NULL input expression.
Syntax
IFNULL (<expression1>, <expression2>)
Description
IFNULL(<expression1>, <expression2>) returns <expression1> or <expression2>. If the data types of 
<expression1> and <expression2> are different, SAP HANA chooses the data type with the higher 
precedence. For example, between TIMESTAMP and STRING, TIMESTAMP has the higher precedence. See 
the Data Types documentation for more information about data type precedence.
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 153
● Returns <expression1> if <expression1> is not NULL.
● Returns <expression2> if <expression1> is NULL.
● Returns NULL if both input expressions are NULL.
Example
The following query returns diff:
SELECT IFNULL ('diff', 'same') "ifnull" FROM DUMMY
The following query returns same:
SELECT IFNULL (NULL, 'same') "ifnull" FROM DUMMY
The following query returns NULL:
SELECT IFNULL (NULL, NULL) "ifnull" FROM DUMMY
Related Information
Data Types [page 26]
2.8.1.78 INDEXING_ERROR_CODE Function (Fulltext) 
Returns the error code of the corresponding cell(s).
Syntax
INDEXING_ERROR_CODE(<column_name>)
Syntax Elements
<column_name> ::= <identifier>
The column where the INDEXING_ERROR_CODE type should be detected.
154 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
Description
You must have a fulltext index for the specified column.
Examples
Create a table and specify a mimetype:
DROP TABLE T; CREATE COLUMN TABLE T (CONTENT varchar(50));
 CREATE FULLTEXT INDEX I ON T(CONTENT) ASYNC MIME TYPE 'text/xml' FAST 
PREPROCESS OFF;
 INSERT INTO T VALUES ('This is an example'); INSERT INTO T VALUES ('<xml>This is an example</xml>');
Select the content and detect the ERROR_CODE type of the entries:
SELECT INDEXING_ERROR_CODE(CONTENT),CONTENT FROM T;
The query returns the following result:
10102;This is an example 0;<xml>This is an example</xml>
2.8.1.79 INDEXING_ERROR_MESSAGE Function (Fulltext)
Returns the error message of the corresponding cell(s).
Syntax
INDEXING_ERROR_MESSAGE (<column_name>)
Syntax Elements
<column_name> ::= <identifier>
The column where the INDEXING_ERROR_MESSAGE type should be detected.
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 155
Description
The function INDEXING_ERROR_MESSAGE (<column_name>) returns the error message of the 
corresponding cell(s). You must have a fulltext index for the specified column.
Examples
Create a table and specify a mimetype:
CREATE COLUMN TABLE T (CONTENT VARCHAR(50)); CREATE FULLTEXT INDEX I ON T(CONTENT) ASYNC MIME TYPE 'text/xml' FAST 
PREPROCESS OFF;
 INSERT INTO T VALUES ('This is an example'); INSERT INTO T VALUES ('<xml>This is an example</xml>');
Select the content and get the ERROR_MESSAGE of the entries:
SELECT INDEXING_ERROR_MESSAGE(CONTENT),CONTENT FROM T;
The query returns the following result:
Xerces parser error;This is an example No error;<xml>This is an example</xml>
2.8.1.80 INDEXING_STATUS Function (Fulltext)
Returns the indexing status of the corresponding cell(s).
Syntax
INDEXING_STATUS (<column_name>)
Syntax Elements
<column_name> ::= <identifier>
The column where the INDEXING_STATUS should be detected.
156 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
Description
You must have an existing fulltext index for the specified column.
Examples
Create a table, specifying a mimetype and suspendingthe queue:
CREATE COLUMN TABLE T (CONTENT varchar(50)); CREATE fulltext index I on T(CONTENT) ASYNC MIME TYPE 'text/xml' FAST 
PREPROCESS OFF;
 ALTER FULLTEXT INDEX I SUSPEND QUEUE;
 INSERT INTO T VALUES ('This is an example'); INSERT INTO T VALUES ('<xml>This is an example</xml>');
Select the content and get the INDEXING_STATUS of the entries:
SELECT INDEXING_STATUS(CONTENT),CONTENT FROM T; 
The query returns the following result:
QUEUED;This is an example QUEUED;<html>This is an example</html> 
Activate the Queue, and select the content and INDEXING_STATUS again.
ALTER FULLTEXT INDEX I ACTIVATE QUEUE; SELECT INDEXING_STATUS(CONTENT),CONTENT FROM T;
The query returns the following result:
ERROR;This is an example INDEXED;<xml>This is an example</xml>
2.8.1.81 IS_SQL_INJECTION_SAFE Function (Security)
Checks a specified SQL identifier for possible SQL injection.
Syntax
IS_SQL_INJECTION_SAFE(<value>[, <max_tokens>])
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 157
Syntax Elements
<value> ::= <string>
The string to be checked.
<max_tokens> ::= <integer>
The maximum number of tokens that is allowed to be in <value>. The default value is 1.
Description
Checks for possible SQL injection in a parameter which is to be used as an SQL identifier. Returns 1 if no 
possible SQL injection is found, otherwise 0.
Example
The following query returns 0 if the number of tokens in the argument exceeds the expected number of a 
single token (default value).
SELECT IS_SQL_INJECTION_SAFE('tab,le') "safe" FROM DUMMY
The following query returns 1 if the number of tokens in the argument does not exceed the maximum number 
of 3 tokens and does not contain critical content.
SELECT IS_SQL_INJECTION_SAFE('CREATE STRUCTURED PRIVILEGE', 3) "safe" FROM DUMMY
The following query returns 0 because comments are not allowed.
SELECT IS_SQL_INJECTION_SAFE('mytab /*', 4) "safe" FROM DUMMY
2.8.1.82 ISOWEEK Function (Datetime)
Returns the ISO year and week numbers of the specified date.
Syntax
ISOWEEK (<d>)
158 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
Description
Returns the ISO year and week numbers of date <d>. The week number is prefixed by the letter W.
Example
The following example returns the value 2011-W22 for the ISO year and week numbers of the specified date:
SELECT ISOWEEK (TO_DATE('2011-05-30', 'YYYY-MM-DD')) "isoweek" FROM DUMMY;
Related Information
WEEK Function (Datetime) [page 265]
2.8.1.83 JSON_QUERY Function (Miscellaneous)
Extracts JSON text from a JSON context item by using a SQL/JSON path expression.
Syntax
JSON_QUERY ( <JSON_API_common_syntax> [ <JSON_output_clause> ] [ <JSON_query_wrapper_behavior> ] [ <JSON_query_empty_behavior> ON EMPTY ] [ <JSON_query_error_behavior> ON ERROR ] )
Syntax Elements
JSON_API_common_syntax
Specifies a JSON context item and a path to the context item, using common syntax for the JSON API.
<JSON_API_common_syntax> ::= <JSON_context_item>, <JSON_path_specification>
JSON_context_item
Specifies the JSON document to operate on.
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 159
JSON_path_specification
Specifies the path to <JSON_context_item>.
<JSON_path_specification> ::= <JSON_path_mode> <JSON_path_wff> <JSON_path_mode> ::= STRICT | LAX
If a structural error occurs within a JSON filter expression and <JSON_path_mode> is set to STRICT, 
then the error handling of a JSON filter expression applies. Otherwise, a structural error is an 
unhandled error.
When the path is set to LAX, one of the following options occurs:
● If an operation requires an SQL/JSON array but the operand is not an SQL/JSON array, then the 
operand is wrapped in an SQL/JSON array prior to performing the operation.
● If an operation requires something other than an SQL/JSON array, but the operand is an SQL/
JSON array, then the operand is unwrapped by converting its elements into an SQL/JSON 
sequence prior to performing the operation.
If there is still a structural error after applying these resolutions, then the result is an empty SQL/
JSON sequence.
<JSON_path_wff> indicates an actual JSON path (for example, '$.item1').
JSON_output_clause
Specifies the output created by the JSON_QUERY function.
<JSON_output_clause> ::= RETURNING <data_type>
data_type
Specifies the data type to be set as the return type of the JSON QUERY function. Supported data 
types: NVARCHAR(<length>), VARCHAR(<length>).
JSON_query_wrapper_behavior WRAPPER
Specifies the wrapper behavior of the JSON query.
<JSON_query_wrapper_behavior> WRAPPER <JSON_query_wrapper_behavior> ::= WITHOUT [ ARRAY ] | WITH [ CONDITIONAL | UNCONDITIONAL ] [ ARRAY ]
The default is WITHOUT ARRAY WRAPPER. However, if WITH is specified, then the default is 
UNCONDITIONAL ARRAY WRAPPER.
JSON_query_empty_behavior ON EMPTY
Specifies the behavior of the function if the related data is not in the context item. The default is NULL ON 
EMPTY.
<JSON_query_empty_behavior> ON EMPTY <JSON_query_empty_behavior> ::= ERROR
 | NULL
 | EMPTY ARRAY | EMPTY OBJECT
ERROR ON EMPTY returns an error if the related data is not in the context item. NULL ON EMPTY returns 
a NULL if the related data is not in the context item. EMPTY ARRAY ON EMPTY returns an empty array if 
160 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
the related data is not in the context item. EMPTY OBJECT ON EMPTY returns an empty JSON object if the 
related data is not in the context item.
JSON_query_error_behavior ON ERROR
Specifies the behavior of the function when the query throws an error. The default is NULL ON ERROR.
<JSON_query_error_behavior> ON ERROR <JSON_query_error_behavior> ::= ERROR
 | NULL
 | EMPTY ARRAY | EMPTY OBJECT
ERROR ON ERROR returns an error if the function result includes an error. NULL ON ERROR returns a 
NULL if the function result includes an error. EMPTY ARRAY ON ERROR returns an empty array if the 
function result includes an error. EMPTY OBJECT ON ERROR returns an empty JSON object if the function 
result includes an error.
Description
Extracts JSON text from a JSON context item using a SQL/JSON path expression.
The following tokens are supported in <JSON_API_common_syntax>:
Table 36:
Token Description Example
$ The context item (the first argument of 
the function).
'$'
. The member of an object. '$.item.description'
[ The array index specifier (open).
] The array index specifier (closed). '$[1]'
'$.item.list[1]'
to The array index range. '$[3 to 5]'
= '$[3,4,5]'
* The wild card. '$.*.description'
'$.item.list[*]'
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 161
Example
The following query returns the value {"item1":1,"item2":2,"item3":3}.
SELECT JSON_QUERY('{"item1":1, "item2":2, "item3":3}', '$') AS JSONQUERY FROM 
DUMMY;
The following query returns the value [1].
SELECT JSON_QUERY('{"item1":1, "item2":2, "item3":3}', '$.item1' WITH WRAPPER ) 
AS JSONQUERY FROM DUMMY;
2.8.1.84 JSON_TABLE Function (Miscellaneous)
Queries a JSON text and presents it as a relational table.
Syntax
JSON_TABLE ( <JSON_API_common_syntax> <JSON_table_columns_clause> [ <JSON_table_error_behavior> ON ERROR ] )
Syntax Elements
JSON_API_common_syntax
Specifies a JSON context item and a path to the context item, using common syntax for the JSON API.
<JSON_API_common_syntax> ::= <JSON_context_item>, <JSON_path_specification>
JSON_context_item
Specifies the JSON document to operate on.
JSON_path_specification
Specifies the path to <JSON_context_item>.
<JSON_path_specification> ::= <JSON_path_mode> <JSON_path_wff> <JSON_path_mode> ::= STRICT | LAX
If a structural error occurs within a JSON filter expression and <JSON_path_mode> is set to STRICT, 
then the error handling of a JSON filter expression applies. Otherwise, a structural error is an 
unhandled error.
162 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
When the path is set to LAX,one of the following options occurs:
● If an operation requires an SQL/JSON array but the operand is not an SQL/JSON array, then the 
operand is wrapped in an SQL/JSON array prior to performing the operation.
● If an operation requires something other than an SQL/JSON array, but the operand is an SQL/
JSON array, then the operand is unwrapped by converting its elements into an SQL/JSON 
sequence prior to performing the operation.
If there is still a structural error after applying these resolutions, then the result is an empty SQL/
JSON sequence.
<JSON_path_wff> indicates an actual JSON path (for example, '$.item1').
JSON_table_columns_clause
Specifies the columns that are created.
<JSON_table_columns_clause> ::= COLUMNS ( <JSON_table_column_definition> [,... ] ) <JSON_table_column_definition> ::= <JSON_table_ordinality_column_definition> | <JSON_table_regular_column_definition> | <JSON_table_formatted_column_definition> | <JSON_table_nested_columns>
JSON_table_column_definition
Defines the columns generated.
JSON_table_ordinality_column_definition
Defines an ordinality column. An ordinality column is similar to a column defined using the 
ROW_NUMBER window function.
<JSON_table_ordinality_column_definition> ::= <column_name> FOR ORDINALITY
JSON_table_regular_column_definition
Defines the regular columns. Each result (row) of a regular JSON table column is equivalent to a 
JSON_VALUE function result.
<JSON_table_regular_column_definition> ::= <column_name> <data_type> [ PATH <JSON_table_column_path_specification> ] [ JSON <table_column_empty_behavior> ON EMPTY ] [ <JSON_table_column_error_behavior> ON ERROR ] <JSON_table_column_path_specification> ::= <JSON_path_specification> <JSON_table_column_empty_behavior> ::= ERROR
 | NULL | DEFAULT <value_expression> <JSON_table_column_error_behavior> ::= ERROR
 | NULL | DEFAULT <value_expression>
column_name
Specifies the name of the column.
data_type
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 163
Specifies the data type. Supported data types for regular columns are VARCHAR(<n>), 
NVARCHAR(<n>), INT, BIGINT, and DECIMAL.
JSON_table_column_path_specification
Specifies the JSON path that specifies which JSON value the JSON context item is extracted from.
table_column_empty_behavior ON EMPTY
Specifies the behavior of the function when the created column is empty. The default is DEFAULT 
<value_expression> ON EMPTY.
ERROR ON EMPTY returns an error when the created column is empty. NULL ON EMPTY returns 
a NULL when the created column is empty. DEFAULT <value_expression> ON EMPTY returns 
<value_expression> when the created column is empty.
JSON_table_column_error_behavior ON ERROR
Specifies the behavior of the function when there is an error during column creation. The default is 
DEFAULT <value_expression> ON ERROR.
ERROR ON ERROR results in an error being thrown if the function result includes an error. NULL 
ON ERROR returns a NULL if the function result includes an error. DEFAULT 
<value_expression> ON ERROR returns <value_expression> if the function result includes 
an error.
JSON_table_formatted_column_definition
Specifies the column definition for formatted columns where the records in the column are formatted 
in JSON syntax. Each result (row) of a regular JSON table column is equivalent to a JSON_QUERY 
function result.
<JSON_table_formatted_column_definition> ::= <column_name> <data_type> FORMAT <JSON_representation> [ PATH <JSON_table_column_path_specification> ] [ <JSON_table_formatted_column_wrapper_behavior> WRAPPER ] [ <JSON_table_formatted_column_empty_behavior> ON EMPTY ] [ <JSON_table_formatted_column_error_behavior> ON ERROR ]
column_name
Specifies the name of the column.
data_type
Specifies the data type to be set as the return type of the function. Supported data types for 
formatted columns are VARCHAR(<n>) and NVARCHAR(<n>).
JSON_representation
Specifies the JSON encoding to use.
<JSON_representation> ::= 'JSON'
 | 'JSON ENCODING { UTF8 }'
 | 'JSON ENCODING { UTF16 }' | 'JSON ENCODING { UTF32 }'
JSON_table_column_path_specification
Specifies the JSON path that specifies which JSON value the JSON context item is extracted from.
JSON_table_formatted_column_wrapper_behavior WRAPPER
164 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
Specifies the wrapper behavior of the formatted column.
<JSON_table_formatted_column_wrapper_behavior> ::= WITHOUT [ ARRAY ] | WITH [ CONDITIONAL | UNCONDITIONAL ] [ ARRAY ]
When WITHOUT [ ARRAY ] WRAPPER is specified, the formatted column is not represented as a JSON 
array. When WITH [ CONDITIONAL | UNCONDITIONAL ] [ ARRAY ] WRAPPER is specified, the 
formatted column is set with a conditional/unconditional array. With an unconditional array, the result 
is always formatted as a JSON array. With a conditional array, the result is formatted as a JSON array 
if the result is neither a JSON array nor a JSON object.
JSON_table_formatted_column_empty_behavior ON EMPTY
Specifies the JSON behavior if the related data is not in the context item.
<JSON_table_formatted_column_empty_behavior> ::= ERROR
 | NULL
 | EMPTY ARRAY | EMPTY OBJECT
ERROR ON EMPTY returns an error if the related data is not in the context item. NULL ON EMPTY 
returns a NULL if the related data is not in the context item. EMPTY ARRAY ON EMPTY returns an 
empty array if the related data is not in the context item. EMPTY OBJECT ON EMPTY returns an 
empty JSON object if the related data is not in the context item.
JSON_table_formatted_column_error_behavior ON ERROR
Specifies the behavior when the formatted column throws an error.
<JSON_table_formatted_column_error_behavior> ::= ERROR
 | NULL
 | EMPTY ARRAY | EMPTY OBJECT
ERROR ON ERROR returns an error if the function returns no result. NULL ON ERROR returns a NULL 
if the function returns no result. EMPTY ARRAY ON ERROR returns an empty array if the result of the 
formatted column is empty. EMPTY OBJECT ON ERROR returns an empty JSON object if the result of 
the formatted column is empty.
JSON_table_nested_columns
Defines nested columns.
<JSON_table_nested_columns> ::= NESTED [ PATH ] 
<JSON_table_nested_path_specification> <JSON_table_columns_clause> <JSON_table_nested_path_specification> ::= <JSON_path_specification>
● <JSON_table_columns_clause>: Specifies the columns that are created with the function.
● <JSON_path_specification>: The JSON path which specifies which JSON value from the 
JSON context item is extracted.
JSON_table_error_behavior
Specifies the behavior of the function when an error occurs.
<JSON_table_error_behavior> ::= ERROR 
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 165
 | EMPTY
ERROR
If the function result includes an error, the the error is returned.
EMPTY
If the function result is empty, then it returns empty.
Description
Queries a JSON text and presents it as a relational table.
The following tokens are supported in <JSON_API_common_syntax>:
Table 37:
Token Description Example
$ The context item (the first argument of 
the function).
'$'
. The member of an object. '$.item.description'
[ The array index specifier (open).
] The array index specifier (closed). '$[1]'
'$.item.list[1]'
to The array index range. '$[3 to 5]'
= '$[3,4,5]'
* The wild card. '$.*.description'
'$.item.list[*]'
Example
The following examples use the table created below:
CREATE TABLE T1 (A INT, B NVARCHAR(5000)); INSERT INTO T1 VALUES (1, '
{
 "PONumber": 1,
 "Reference": "MSULLIVA-20141102",
 "Requestor": "Martha Sullivan",
 "User": "MSULLIVA",
 "CostCenter": "A50",
 "ShippingInstructions":
 {
 "name": "Martha Sullivan",
166 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
 "Address":
 {
 "street": "200 Sporting Green","city": "South San Francisco",
 "state": "CA",
 "zipCode": 99236,
 "country": "United States of America"
 },
 "Phone": [{"type": "Office", "number": "979-555-6598"}]
 },
 "SpecialInstructions": "Surface Mail",
 "LineItems": [
 {"ItemNumber": 1, "Part": {"Description": "Run Lola Run", 
"UnitPrice": 19.95, "UPCCode": 43396040144}, "Quantity": 7},
 {"ItemNumber": 2, "Part": {"Description": "Felicia's Journey", 
"UnitPrice": 19.95, "UPCCode": 12236101345}, "Quantity": 1},
 {"ItemNumber": 3, "Part": {"Description": "Lost and Found", 
"UnitPrice": 19.95, "UPCCode": 85391756323}, "Quantity": 8},
 {"ItemNumber": 4, "Part": {"Description": "Karaoke: Rock & Roll 
Hits of 80's & 90's 8", "UnitPrice": 19.95, "UPCCode": 13023009592}, "Quantity": 
8},
 {"ItemNumber": 5, "Part": {"Description": "Theremin: An 
Electronic Odyssey", "UnitPrice": 19.95, "UPCCode": 27616864451}, "Quantity": 8}
 ]
} ');
The following example selects from an ordinality column and a regular column:
SELECT JT.* FROM JSON_TABLE(T1.B, '$.LineItems[*]'
COLUMNS
 (
 RN FOR ORDINALITY,
 ITEM_NUMBER INT PATH '$.ItemNumber',
 UPC_CODE BIGINT PATH '$.Part.UPCCode'
 ) ) AS JT;
RN ITEM_NUMBER UPC_CODE
1 1 43396040144
2 2 12236101345
3 3 85391756323
4 4 13023009592
5 5 27616864451
The following example selects from a formatted column:
SELECT * FROM JSON_TABLE(T1.B, '$.ShippingInstructions'
COLUMNS
 (
 PHONE VARCHAR(200) FORMAT JSON PATH '$.Phone'
 ) ) AS JT;
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 167
PHONE
[{"type": "Office", "number":"979-555-6598"}]
The following example selects from a nested column:
SELECT * FROM JSON_TABLE(T1.B, '$.ShippingInstructions'
COLUMNS
 (
 NESTED PATH '$.Address'
 COLUMNS
 (
 STREET NVARCHAR(50) PATH '$.street',
 CITY NVARCHAR(50) PATH '$.city'
 )
 ) ) AS JT;
STREET CITY
200 Sporting Green South San Francisco
The following example selects from an ordinality column with nested columns:
SELECT * FROM JSON_TABLE(T1.B, '$'
 COLUMNS
 (
 RN FOR ORDINALITY,
 USER_NAME NVARCHAR(20) PATH '$.User',
 NESTED PATH '$.LineItems[1,2]'
 COLUMNS
 (
 ORDER_NUMBER FOR ORDINALITY,
 ITEM_NUMBER INT PATH '$.ItemNumber',
 QUANTITY INT PATH '$.Quantity'
 )
 ) ) AS JT;
RN USER_NAME ORDER_NUMBER ITEM_NUMBER QUANTITY
1 MSULLIVA 1 2 1
1 MSULLIVA 2 3 8
168 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
2.8.1.85 JSON_VALUE Function (Miscellaneous)
Extracts an SQL value of a predefined type from a JSON value.
Syntax
JSON_VALUE ( <JSON_API_common_syntax> [ <JSON_returning_clause> ] [ <JSON_value_empty_behavior> ON EMPTY ] [ <JSON_value_error_behavior> ON ERROR ] )
Syntax Elements
JSON_API_common_syntax
Specifies a JSON context item and a path to the context item, using common syntax for the JSON API.
<JSON_API_common_syntax> ::= <JSON_context_item>, <JSON_path_specification>
JSON_context_item
Specifies the JSON document to operate on.
JSON_path_specification
Specifies the path to <JSON_context_item>.
<JSON_path_specification> ::= <JSON_path_mode> <JSON_path_wff> <JSON_path_mode> ::= STRICT | LAX
When <JSON_path_mode> is set to STRICT, if the structural error occurs within a JSON filter 
expression, then the error handling of a JSON filter expression applies. Otherwise, a structural error is 
an unhandled error.
When the path is set to LAX, one of the following options occurs:
● If an operation requires an SQL/JSON array but the operand is not an SQL/JSON array, then the 
operand is wrapped in an SQL/JSON array prior to performing the operation.
● If an operation requires something other than an SQL/JSON array, but the operand is an SQL/
JSON array, then the operand is unwrapped by converting its elements into an SQL/JSON 
sequence prior to performing the operation.
If there is still a structural error after applying these resolutions, then the result is an empty SQL/
JSON sequence.
<JSON_path_wff> indicates an actual JSON path (for example, '$.item1').
JSON_returning_clause
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 169
Defines the data type of the result.
<JSON_returning_clause> ::= RETURNING <data_type> <data_type> ::= INTEGER 
 | BIGINT 
 | DECIMAL | VARCHAR(<integer>) | NVARCHAR(<integer>)
JSON_value_empty_behavior ON EMPTY
Specifies the behavior of the function when the related data is not in the context item. The default is NULL 
ON EMPTY
<JSON_value_empty_behavior> ON EMPTY <JSON_value_empty_behavior> ::= ERROR
 | NULL | DEFAULT <value_expression>
ERROR ON EMPTY returns an error if the related data is not in the context item. NULL ON EMPTY returns 
a NULL if the related data is not in the context item. DEFAULT <value_expression> ON EMPTY returns 
<value_expression> if the related data is not in the context item.
JSON_value_error_behavior ON ERROR
Specifies the behavior of the JSON_VALUE function when an error occurs. The default is NULL ON ERROR.
<JSON_value_error_behavior> ON ERROR <JSON_value_error_behavior> ::= ERROR
 | NULL | DEFAULT <value_expression>
ERROR ON ERROR returns an error if the function results include an error. NULL ON ERROR returns a 
NULL if the function results include an error. DEFAULT <value_expression> ON ERROR returns 
<value_expression> if the function results include an error.
Description
Extracts an SQL value of a predefined type from a JSON value.
The following tokens are supported in <JSON_API_common_syntax>:
Table 38:
Token Description Example
$ The context item (the first argument of 
the function).
'$'
. The member of an object. '$.item.description'
[ The array index specifier (open).
170 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
Token Description Example
] Array index specifier (closed). '$[1]'
'$.item.list[1]'
to The array index range. '$[3 to 5]'
= '$[3,4,5]'
* The wild card. '$.*.description'
'$.item.list[*]'
Example
The following statement returns a value of 10:
SELECT JSON_VALUE('{"item1":10}', '$.item1') AS "value" FROM DUMMY;
The following statement returns a value of 5:
SELECT JSON_VALUE('{"item1":{"sub1":10}, "item2":{"sub2":5}, "item3":{"sub3":
7}}', '$.*.sub2') AS "value" FROM DUMMY;
The following statement returns a value of 0:
SELECT JSON_VALUE('[0, 1, 2, 3]', '$[0]') AS "value" FROM DUMMY;
The following statement returns the value "No last name found":
SELECT JSON_VALUE('{"firstname":"John"}', '$.lastname' DEFAULT 'No last name 
found' ON EMPTY) AS "Last Name" FROM DUMMY;
The following statement causes a type conversion error to demonstrate the behavior for ERROR ON ERROR:
SELECT JSON_VALUE('{"item":"string"}', '$.item' RETURNING DECIMAL ERROR ON 
ERROR) AS "Item" FROM DUMMY;
The following statement demonstrates what happens when there is no value (the object does not have the 
name "last name"):
SELECT JSON_VALUE('{"firstname":"John"}', 'strict $.lastname' ERROR ON ERROR) AS 
"Last Name" FROM DUMMY;
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 171
2.8.1.86 LANGUAGE Function (Fulltext)
Returns the language of the specified column entries.
Syntax
LANGUAGE (<column_name>)
Syntax Elements
<column_name> ::= <identifier>
The column where the language detection is to occur.
Description
You must have an existing fulltext index for the specified column.
Example
Create a table with two detectable languages, English and German, and populate it with some entries.
CREATE COLUMN TABLE T (CONTENT TEXT FAST PREPROCESS OFF LANGUAGE 
DETECTION('EN','DE')); INSERT INTO T VALUES('This is a very short example.'); INSERT INTO T VALUES('Diesist ein ganz kurzes Beispiel.');
Execute the following query to select the content and detect the language of the entries.
SELECT LANGUAGE(CONTENT),CONTENT FROM T;
The query returns the language of each column:
en;This is a very short example. de;Dies ist ein ganz kurzes Beispiel.
172 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
2.8.1.87 LAST_DAY Function (Datetime)
Returns the date of the last day of the month that contains the specified date.
Syntax
LAST_DAY (<d>)
Description
Returns the date of the last day of the month that contains the date <d>.
Example
The following example returns the value 2010-01-31:
SELECT LAST_DAY (TO_DATE('2010-01-04', 'YYYY-MM-DD')) "last day" FROM DUMMY;
2.8.1.88 LAST_VALUE Function (Aggregate)
Returns the value of the last element of a column.
Syntax
LAST_VALUE (<column1> ORDER BY <column2>)
Description
Returns the value of the last element in <column1> as ordered by <column2>.
Null is returned if the value is null or if <column1> is empty.
The output of LAST_VALUE function can be non-deterministic among tie values.
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 173
Example
The example below returns the last value in COL1 column when the table is ordered by COL2. The query 
returns 4.
CREATE TABLE T (COL1 DOUBLE, COL2 DOUBLE); INSERT INTO T VALUES(1, 1);
INSERT INTO T VALUES(4, 5);
INSERT INTO T VALUES(7, 3); SELECT LAST_VALUE (COL1 ORDER BY COL2) FROM T;
2.8.1.89 LCASE Function (String)
Converts all characters in a string to lowercase.
Syntax
LCASE(<str>)
Description
Converts all characters in string <str> to lowercase.
The LCASE function is identical to the LOWER function.
Example
This example converts all characters of the given string TesT to lowercase and returns the value test.
SELECT LCASE ('TesT') "lcase" FROM DUMMY;
174 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
2.8.1.90 LEAST Function (Miscellaneous)
Returns the lesser value of two specified arguments.
Syntax
LEAST (<n1> [, <n2>]...)
Description
Returns the lesser value of the arguments (<n1>, <n2>...).
Example
The following query returns aa.
SELECT LEAST('aa', 'ab', 'ba', 'bb') "least" FROM DUMMY;
2.8.1.91 LEFT Function (String)
Returns the first characters/bytes from the beginning of a string.
Syntax
LEFT (<str>, <n>)
Description
Returns the first <n> characters/bytes from the beginning of string <str>.
Returns an empty string value if <n> is less than 1.
Returns string <str> without blank padding if the value of <n> is greater than the length of string <str>.
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 175
Example
The following example returns the leftmost 3 characters of the given string (Hel):
SELECT LEFT ('Hello', 3) "left" FROM DUMMY;
The following example returns the given string (Hello) because the value 10 exceeds the string length:
SELECT LEFT ('Hello', 10) "left" FROM DUMMY;
2.8.1.92 LENGTH Function (String)
Returns the number of characters in a string.
Syntax
LENGTH(<str>)
Description
Returns the number of characters in string <str>.
In the case that the type of str is a VARCHAR, the LENGTH(<str>) will not return the number of bytes. In this 
case the number of characters like NVARCHAR-typed strings are returned instead.
Supplementary plane Unicode characters, each of which occupies 6 bytes in CESU-8 encoding, are counted as 
two characters.
Example
This example returns the number of characters (14) contained in the given string:
SELECT LENGTH ('length in char') "length" FROM DUMMY;
176 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
2.8.1.93 LIKE_REGEXPR Function (String)
Performs regular expression matching.
Syntax
<regex_subject_string> LIKE_REGEXPR <pattern> [ FLAG <flag> ]
Syntax Elements
<regex_subject_string> ::= <string>
This parameter specifies the string that the search pattern should be applied to. If 
<regex_subject_string> is empty, the result will be empty.
<pattern> ::= !!Perl Compatible Regular Expression
A search pattern based on Perl Compatible Regular Expression (PCRE).
<flag>
The matching behaviour of the function can be defined by the flag literal. The following options are available:
Table 39: Flag options
Flag option Description
i Enables case-insensitive matching
m Enables multiline mode, where the <subject_string> will be treated as multiple lines and the ex­
pression ^ and $ match just after or just before, respectively, a line terminator or the end of the input 
sequence
s Enables the expression <.> as a wildcard to match any character, including a line terminator
x Permits whitespace and comments in the pattern
Description
This function performs regular expression matching.
If any of the following parameters is NULL: <pattern>, <flag> or <regex_subject_string>, the function 
will return False.
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 177
Example
This example searches for text like them or this from the table mytab:
SELECT * FROM mytab WHERE text LIKE_REGEXPR ' them|this ';
2.8.1.94 LN Function (Numeric)
Returns the natural logarithm of the specified argument.
Syntax
LN (<n>)
Description
Returns the natural logarithm of the numeric argument <n>.
Example
This example returns the value 2.1972245773362196 for "ln":
SELECT LN (9) "ln" FROM DUMMY;
2.8.1.95 LOCALTOUTC Function (Datetime)
A timestamp parameter holding the time to be converted between UTC and local time.
Syntax
LOCALTOUTC (<t>, <timezone> [, <timezone_dataset>])
178 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
Syntax Elements
<t> ::= <timestamp>
A timestamp parameter holding the time to be converted between UTC and local time.
<timezone> ::= <string_literal>
A string parameter holding the timezone defining the local time. For a list of available timezones, see the 
TIMEZONES system view.
<timezone_dataset> ::= <string_literal>
A string parameter that specifies the dataset in which to search for the given timezone. Possible values of this 
parameter are
● sap specifies to search in the currently used SAP dataset.
● platform specifies to search in the dataset provided by the operating system.
Description
Converts the local time t from a timezone to the UTC(GMT) time.
The usage of local timestamps is discouraged. It is a best practice to use UTC times instead. The use of local 
times or conversion between local time zones might require additional handling in application code.
Examples
The following example returns the value 2012-01-01 06:00:00.0 for the UTC date and time:
SELECT LOCALTOUTC (TO_TIMESTAMP('2012-01-01 01:00:00', 'YYYY-MM-DD HH24:MI:SS'), 
'EST') "localtoutc" FROM DUMMY;
The following example returns the value 2012-01-01 06:00:00.0 for the UTC date and time:
SELECT LOCALTOUTC (TO_TIMESTAMP('2012-01-01 01:00:00', 'YYYY-MM-DD HH24:MI:SS'), 
'EST', 'sap') "localtoutc" FROM DUMMY;
Related Information
TIMEZONES System View [page 1476]
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 179
2.8.1.96 LOCATE Function (String)
Returns the position of a substring within a string.
Syntax
LOCATE (<haystack>, <needle>, <start_position>, <occurrences>)
Description
Returns the position of a substring <needle> within a string <haystack>.
Returns 0 if <needle> is not found within <haystack>, or if <occurrences> is set to less than 1. Returns 
NULL if <haystack> or <needle> is NULL.
● If <start_position> is not specified or is 0, the search starts at the beginning of the string 
<haystack>.
● If <start_position> is negative, the search starts at the ending of the string <haystack>.
● If <occurrences> is not specified, the first matched position will be returned.
Examples
The following example returns 1 because <needle> is an empty string.
SELECT LOCATE ('length in char', '') "locate" FROM DUMMY;
The following example returns the starting position (1) of length in the string lengthin char:
SELECT LOCATE ('length in char', 'length') "locate" FROM DUMMY;
The following example returns 0 because the search pattern zchar cannot be found in the given string:
SELECT LOCATE ('length in char', 'zchar') "locate" FROM DUMMY;
180 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
2.8.1.97 LOCATE_REGEXPR Function (String)
Searches a string for a regular expression pattern and returns an integer indicating the beginning position, or 
the ending position plus 1, of one occurrence of the matched substring.
Syntax
LOCATE_REGEXPR ( [ <regex_position_start_or_after> ] <pattern> [ FLAG <flag> ] IN <regex_subject_string> [ FROM <start_position> ] [ OCCURRENCE <regex_occurrence> ] [ GROUP <regex_capture_group> ] )
Syntax Elements
<regex_position_start_or_after> ::= START | AFTER 
Searches a string for a regular expression pattern and returns an integer indicating the beginning position, or 
the ending position plus 1, of one occurrence of the matched substring.
If <regex_position_start_or_after> is not specified, then START is implicit.
<pattern>::= !!Perl Compatible Regular Expression 
A search pattern based on Perl Compatible Regular Expression (PCRE).
<flag> ::= 'i' | 'm' | 's' | 'x' 
The matching behaviour of the function can be defined by the <flag> literal. The following options are 
available:
Table 40: Flag options
Flag option Description
i Enables case-insensitive matching
m Enables multiline mode, where the <subject_string> will be treated as multiple lines and the ex­
pression ^ and $ match just after or just before, respectively, a line terminator or the end of the input 
sequence
s Enables the expression <.> as a wildcard to match any character, including a line terminator
x Permits whitespace and comments in the pattern
<regex_subject_string> 
<start_position>
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 181
The <start_position> parameter is a positive integer and indicates the character of 
<regex_subject_string> where the search is started. If <start_position> is not a positive integer, then 
0 is returned.
<regex_occurrence>
The <regex_occurrence> parameter is a positive integer and indicates the occurrence of the <pattern> in 
<regex_subject_string>. The default is 1.
If <regex_occurrence> is not a positive integer, then 0 is returned.
<regex_capture_group>
The <regex_capture_group> parameter is a nonnegative integer and indicates the number of the captured 
substring's group by the regular expression. Default is 0.
If <regex_capture_group> is a negative integer, then 0 is returned.
Description
Searches a string for a regular expression pattern and returns an integer indicating the beginning position, or 
the ending position plus 1, of one occurrence of the matched substring.
If any of the following parameters is NULL: <pattern>, <flag>, <regex_subject_string>, , 
<start_position>, <regex_occurrence> or <regex_capture_group>, the function returns NULL.
Example
This example returns the start position of the day part from the date value 20140401:
SELECT LOCATE_REGEXPR(START '([[:digit:]]{4})([[:digit:]]{2})([[:digit:]]{2})' 
IN '20140401' GROUP 3) "locate_regexpr" FROM DUMMY;
2.8.1.98 LOG Function (Numeric)
Returns the natural logarithm of a specified number of a specified base.
Syntax
LOG (<b>, <n>)
182 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
Description
Returns the natural logarithm of a number <n> base <b>, where <b> must be a positive value greater than 1, 
and <n> must be any positive value.
Example
The following example returns the value 0.30102999566398114 for "log":
SELECT LOG (10, 2) "log" FROM DUMMY;
2.8.1.99 LOWER Function (String)
Converts all characters in a string to lowercase.
Syntax
LOWER(<str>)
Description
Converts all characters in string <str> to lowercase.
The LOWER function is identical to the LCASE function.
Example
This example converts the given string AnT to lowercase, and returns the value and:
SELECT LOWER ('AnT') "lower" FROM DUMMY;
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 183
2.8.1.100 LPAD Function (String)
Pads the start of string with spaces to make a string a specified number of characters in length.
Syntax
LPAD (<str>, <n> [, <pattern>])
Description
Pads the start of string <str> with spaces to make a string of <n> characters in length. If the <pattern> 
argument is provided, string <str> will be padded using sequences of these characters until the required 
length is met.
Example
The following example pads the start of string end with the pattern 12345 to make a string of 15 characters in 
length, and returns the value 123451234512end:
SELECT LPAD ('end', 15, '12345') "lpad" FROM DUMMY;
2.8.1.101 LTRIM Function (String)
Returns a string, trimmed of all leading spaces.
Syntax
LTRIM (<str> [, <remove_set>])
184 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
Description
Returns string <str>, trimmed of all leading spaces. If <remove_set> is specified, LTRIM removes all the 
characters contained in this set from the start of string <str>. This process continues until a character that is 
not the in <remove_set> is reached.
<remove_set> is treated as a set of characters and not as a search string.
Example
This example removes all leading a and b characters from the given string and returns the value Aabend:
SELECT LTRIM ('babababAabend','ab') "ltrim" FROM DUMMY;
2.8.1.102 MAP Function (Miscellaneous)
Searches for an expression within a set of search values and returns the corresponding result.
Syntax
MAP (<expression>, <search>, <result> [{, <search>, <result>}...] [, 
default_result])
Description
Searches for an expression within a set of search values and returns the corresponding result.
● If the expression value is not found and default_result is defined, MAP returns default_result.
● If the expression value is not found and default_result is not defined, MAP returns NULL.
Search values and corresponding results are always provided in search-result pairs.
Example
The following query returns the value Two.
SELECT MAP(2, 0, 'Zero', 1, 'One', 2, 'Two', 3, 'Three', 'Default') "map" FROM 
DUMMY;
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 185
The following query returns the value Default.
SELECT MAP(99, 0, 'Zero', 1, 'One', 2, 'Two', 3, 'Three', 'Default') "map" FROM 
DUMMY;
The following query returns the value NULL.
SELECT MAP(99, 0, 'Zero', 1, 'One', 2, 'Two', 3, 'Three') "map" FROM DUMMY;
2.8.1.103 MEDIAN Function (Aggregate)
Finds the statistical median of an input column with a numeric data type.
Syntax
MEDIAN (<column>) [OVER([PARTITION BY <col1>, ...] [ORDER BY <col1>, ... [<window_frame>]])]
Syntax Elements
<column> ::= <identifier>
This parameter specifies the input data column for the MEDIAN function.
<col1> ::= <identifier>
This parameter specifies a column for the OVER clause.
<window_frame> ::= {ROWS|GROUPS} UNBOUNDED PRECEDING | {ROWS|GROUPS} BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW | {ROWS|GROUPS} BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
If ORDER BY is not specified, the default frame is UNBOUNDED PRECEEDING TO UNBOUNDED FOLLOWING; 
otherwise, the default frame is GROUPS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW.
Description
Finds the statistical median of an input column with a numeric data type.
Null values are eliminated. If there is an even number of elements, the average of the two middle elements is 
returned. Otherwise, the middle element is returned.
The result type is the type that would be selected for the expression "x/2" for an x value of the input data type.
186 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
Examples
Example 1 - Median of integer input
The example below returns a median value of 2.
CREATE TABLE T (class CHAR(10), date DAYDATE, val INT); INSERT INTO T VALUES('A', '01.01.1972',1);
INSERT INTO T VALUES('A', '02.01.1972', 3);
INSERT INTO T VALUES('A', '03.01.1972', null);
INSERT INTO T VALUES('A', '04.01.1972', 2); SELECT MEDIAN(val) "median value" FROM T;
If the number of non-null values is even, the average of the two middle values are returned. For the example 
below, the average of 2 and 3 is returned. Since the input and output types are the same, the integer is 
rounded. The returned result is 3.
INSERT INTO T VALUES('A', '05.01.1972', 4); SELECT MEDIAN(val) "median value" FROM T;
Example 2 - Median of double input
The example below uses double values instead of integers. The returned result is 2.5.
CREATE TABLE T (TS_ID CHAR(10), date DAYDATE, val DOUBLE); INSERT INTO T VALUES('A', '01.01.1972', 1.0);
INSERT INTO T VALUES('A', '02.01.1972', 3.0);
INSERT INTO T VALUES('A', '03.01.1972', null);
INSERT INTO T VALUES('A', '04.01.1972', 2.0);
INSERT INTO T VALUES('A', '05.01.1972', 4.0); SELECT MEDIAN(val) "median value" FROM T;
Example 3 - Median as a window function
The example below uses double values instead of integers. The returned result is [2.5, 2.5, 2.5, 2.5, 
2.5].
CREATE TABLE T (TS_ID CHAR(10), date DAYDATE, val DOUBLE); INSERT INTO T VALUES('A', '01.01.1972', 1.0);
INSERT INTO T VALUES('A', '02.01.1972', 3.0);
INSERT INTO T VALUES('A', '03.01.1972', null);
INSERT INTO T VALUES('A', '04.01.1972', 2.0);
INSERT INTO T VALUES('A', '04.01.1972', 4.0); SELECT MEDIAN(val) OVER (PARTITION BY TS_ID ) AS WF1 FROM T;
Example 4 - Median of sliding window (GROUPS BETWEEN..)
Both of the SELECT statements in the example below produce identical result. The returned result is [1, 2, 
2, 2.5, 2.5].
CREATE TABLE T (TS_ID CHAR(10), date DAYDATE, val DOUBLE); INSERT INTO T VALUES('A', '01.01.1972', 1.0);
INSERT INTO T VALUES('A', '02.01.1972', 3.0);
INSERT INTO T VALUES('A', '03.01.1972', null);
INSERT INTO T VALUES('A', '04.01.1972', 2.0);
INSERT INTO T VALUES('A', '04.01.1972', 4.0);
SELECT MEDIAN(val) OVER (PARTITION BY TS_ID ORDER BY date) AS WF2A FROM T; SELECT MEDIAN(val) OVER (PARTITION BY TS_ID ORDER BY date GROUPS BETWEEN 
UNBOUNDED PRECEDING AND CURRENT ROW) AS WF2B FROM T;
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 187
Example 5 - Median of sliding window (ROWS BETWEEN)
The example below uses "ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW". The returned 
result is [1, 2, 2, 2, 2.5].
CREATE TABLE T (TS_ID CHAR(10), date DAYDATE, val DOUBLE); INSERT INTO T VALUES('A', '01.01.1972', 1.0);
INSERT INTO T VALUES('A', '02.01.1972', 3.0);
INSERT INTO T VALUES('A', '03.01.1972', null);
INSERT INTO T VALUES('A', '04.01.1972', 2.0);
INSERT INTO T VALUES('A', '04.01.1972', 4.0); SELECT MEDIAN(val) OVER (PARTITION BY TS_ID ORDER BY date ROWS BETWEEN UNBOUNDED 
PRECEDING AND CURRENT ROW) AS WF3 FROM T
2.8.1.104 MEMBER_AT Function (Miscellaneous)
Returns values from a specified array position.
Syntax
MEMBER_AT (<array_value_expression>, <position> [, <default_value>])
Description
An array element is accessed by the specifying its ordinal position. The third parameter indicates the value to 
return when the position is greater than the cardinality of the <array_value_expression>. The default is 
the NULL value.
Example
The following examples use the MEMBER_AT function to return values from a certain array position.
CREATE COLUMN TABLE ARRAY_TEST (IDX INT, VAL INT ARRAY); INSERT INTO ARRAY_TEST VALUES (1, ARRAY(1, 2, 3)); INSERT INTO ARRAY_TEST VALUES (2, ARRAY(10, 20, 30, 40));
188 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
Table 41:
Query Returns
SELECT MEMBER_AT(VAL, 4) "member_at" 
FROM ARRAY_TEST;
NULL
40
SELECT MEMBER_AT(VAL, 4, 1) 
"member_at" FROM ARRAY_TEST;
1
40
2.8.1.105 [NOT] MEMBER OF Function (Miscellaneous)
Determines whether a specified value is contained in a specified array.
Syntax
<expression> [NOT] MEMBER OF <array_value_expression>
Description
Testing whether an element is contained in an array.
Example
The following examples test the existence and non-existence of the value 10 in arrays. The first query returns 
the value 2, and the second query returns the value 1.
CREATE COLUMN TABLE ARRAY_TEST (IDX INT, VAL INT ARRAY); INSERT INTO ARRAY_TEST VALUES (1, ARRAY(1, 2, 3)); INSERT INTO ARRAY_TEST VALUES (2, ARRAY(10, 20, 30, 40));
SELECT IDX FROM ARRAY_TEST WHERE 10 MEMBER OF VAL;
SELECT IDX FROM ARRAY_TEST WHERE 10 NOT MEMBER OF VAL;
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 189
2.8.1.106 MIMETYPE Function (Fulltext)
Returns the MIME type of the corresponding cell(s).
Syntax
 MIMETYPE (<column_name>)
Syntax Elements
<column_name> ::= <identifier>
The column where the MIME type detection is to occur.
Description
The function MIMETYPE (<column_name>) returns the MIME type of the corresponding cell(s). Prerequisite, 
is an existing fulltext index for the specified column.
Example
Create a table with two differing types of text content: plain text and HTML.
CREATE COLUMN TABLE T (CONTENT TEXT FAST PREPROCESS OFF); INSERT INTO T VALUES('This is an example'); INSERT INTO T VALUES('<html>This is an example</html>');
Select the content and detect the MIME type of the entries.
SELECT MIMETYPE(CONTENT),CONTENT FROM T;
The query returns the following result:
text/plain;This is an example text/html;<html>This is an example</html>
190 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
2.8.1.107 MINUTE Function (Datetime)
Returns an integer representation of the minute for the specified time.
Syntax
MINUTE (<t>)
Description
Returns an integer representation of the minute for time <t>.
Example
The following example returns the value 34 as the minute from the specified time:
SELECT MINUTE ('12:34:56') "minute" FROM DUMMY;
2.8.1.108 MOD Function (Numeric)
Returns the remainder of a specified number divided by a specified divisor.
Syntax
MOD (<n>, <d>)
Description
Returns the remainder of a number <n> divided by a divisor <d>.
When <n> is negative this function acts differently to the standard computational modulo operation.
The following explains example of what the MOD function returns as the result:
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 191
● If <d> is zero, then <n> is returned.
● If <n> is greater than 0 and <n> is less than <d>, then <n> is returned.
● If <n> is less than 0 and <n> is greater than <d>, then <n> is returned.
● In other case that of those mentioned above, remainder of the absolute value of <n> divided by the 
absolute value of <d> is used to calculate remainder. If <n> is less than 0, then the returned remainder 
from MOD is a negative number, and if <n> is greater than 0, then the returned remainder from MOD is a 
positive number.
Example
The following example returns the value 3 for "modulus":
SELECT MOD (15, 4) "modulus" FROM DUMMY;
The following example returns the value -3 for "modulus":
SELECT MOD (-15, 4) "modulus" FROM DUMMY;
2.8.1.109 MONTH Function (Datetime)
Returns the number of the month from the specified date.
Syntax
MONTH(<d>)
Description
Returns the number of the month from date <d>.
Example
The following example returns the value 5 as the month for the date specified:
SELECT MONTH ('2011-05-30') "month" FROM DUMMY;
192 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
2.8.1.110 MONTHNAME Function (Datetime)
Returns the name of the month for the specified date.
Syntax
MONTHNAME(<d>)
Description
Returns the name of the month in English for date <d>.
Example
The following example returns the value MAY the month name of the specified date:
SELECT MONTHNAME ('2011-05-30') "monthname" FROM DUMMY;
2.8.1.111 MONTHS_BETWEEN Function (Datetime)
Computes the number of months between two dates.
Syntax
MONTHs_BETWEEN (<d1>, <d2>)
Description
Computes the number of months between <d1> and <d2>. Returns NULL if either of <d1> or <d2> is NULL.
SAP HANA SQL and System Views Reference
SQLReference P U B L I C 193
Examples
The following example returns 2 for the months between the two dates:
SELECT MONTHS_BETWEEN(TO_DATE ('2003-01-01'), TO_DATE('2003-03-14')) 
"months_between" FROM DUMMY;
The following example returns -8 for the months between the two dates:
SELECT MONTHS_BETWEEN(TO_DATE ('2003-10-03'), TO_DATE('2003-01-14')) 
"months_between" FROM DUMMY;
The following example returns -9 for the months between the two dates:
SELECT MONTHS_BETWEEN(TO_DATE ('2003-10-15'), TO_DATE('2003-01-14')) 
"months_between" FROM DUMMY;
The following example returns -8 for the months between the two dates:
SELECT MONTHS_BETWEEN(TO_DATE ('2003-10-13'), TO_DATE('2003-01-14')) 
"months_between" FROM DUMMY;
2.8.1.112 NANO100_BETWEEN Function (Datetime)
Computes the time difference between two dates.
Syntax
NANO100_BETWEEN (<d1>, <d2>)
Description
Computes the time difference between date arguments <d1> and <d2>, to the precision of 0.1 microseconds.
Example
The following example returns 864000000000 as the time difference between the two specified dates:
SELECT NANO100_BETWEEN ('2013-01-30', '2013-01-31') "nano100 between" FROM DUMMY;
194 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
2.8.1.113 NCHAR Function (String)
Returns the Unicode character with the specified integer code number.
Syntax
NCHAR (<n>)
Description
Returns the Unicode character with the integer code number <n>.
Example
This example returns the Unicode character (A) with the integer code number 65:
SELECT NCHAR (65) "nchar" FROM DUMMY;
2.8.1.114 NEXT_DAY Function (Datetime)
Returns the date of the next day after the specified date.
Syntax
NEXT_DAY (<d>)
Description
Returns the date of the next day after date <d>.
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 195
Example
The following example returns 2010-01-01 as the next day after the specified date:
SELECT NEXT_DAY (TO_DATE ('2009-12-31', 'YYYY-MM-DD')) "next day" FROM DUMMY;
2.8.1.115 NEWUID Function (Miscellaneous)
Creates a unique identifier within an SAP HANA database.
Syntax
NEWUID
Description
The NEWUID function acts as an alternative to the SYSUUID function. The SYSUUID function generates a 
universally unique identifier, whereas the NEWUID function generates a unique identifier within one SAP HANA 
database. Both functions return VARBINARY(16).
Example
The following example returns returns a unique value such as 0x03000000FA443E000029C139A595E5F1.
SELECT NEWUID FROM DUMMY;
2.8.1.116 NOW Function (Datetime)
Returns the current timestamp.
Syntax
NOW ()
196 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
Description
Returns the current timestamp.
Example
The following example returns the value 2010-01-01 16:34:19.894 for the current timestamp:
SELECT NOW () "now" FROM DUMMY;
2.8.1.117 NTH_VALUE Function (Aggregate)
Returns the value of an element at a specific position in a column.
Syntax
NTH_VALUE (<column1>, <n> ORDER BY <column2>) 
Description
Returns the value of the element at position <n> in <column1> as ordered by <column2>.
Null is returned if the value is null or if <n> is larger than the number of elements in <column1>. An error is 
raised if <n> is less than or equal to 0. The output of NTH_VALUE function can be non-deterministic among tie 
values.
Example
The example below returns the second value in the COL1 column when the table is ordered by COL2:
CREATE TABLE T (COL1 DOUBLE, COL2 DOUBLE); INSERT INTO T VALUES(900, 10);
INSERT INTO T VALUES(400, 50);
INSERT INTO T VALUES(700, 30);
INSERT INTO T VALUES(200, 40); SELECT NTH_VALUE (COL1, 2 ORDER BY COL2) FROM T;
The query returns 700.
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 197
2.8.1.118 NULLIF Function (Miscellaneous)
Determines whether two expressions are equal.
Syntax
NULLIF (expression1, expression2)
Description
NULLIF compares the values of two expressions and returns NULL if the first expression equals the second 
expression.
● If expression1 does not equal expression2, NULLIF returns expression1.
● If expression2 is NULL, NULLIF returns expression1.
Example
The following query returns diff.
SELECT NULLIF ('diff', 'same') "nullif" FROM DUMMY;
The following query returns NULL.
SELECT NULLIF('same', 'same') "nullif" FROM DUMMY;
2.8.1.119 OCCURRENCES_REGEXPR Function (String)
Returns the number of matches of a regular expression search within a string.
Syntax
OCCURRENCES_REGEXPR ( <pattern> [ FLAG <flag> ] IN <regex_subject_string> [ FROM 
<start_position> ] )
198 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
Syntax Elements
<pattern> ::= !!Perl Compatible Regular Expression
A search pattern based on Perl Compatible Regular Expression (PCRE).
<flag>
The matching behaviour of the function can be defined by the flag literal. The following options are available:
Table 42: Flag options
Flag option Description
i Enables case-insensitive matching
m Enables multiline mode, where the <subject_string> will be treated as multiple lines and the ex­
pression ^ and $ match just after or just before, respectively, a line terminator or the end of the input 
sequence
s Enables the expression <.> as a wildcard to match any character, including a line terminator
x Permits whitespace and comments in the pattern
<regex_subject_string> ::= <string>
The string the search pattern should be applied to. If <regex_subject_string> is empty, the result will be 
empty.
<start_position> ::= <integer>
<start_position> a positive integer and indicates the character of <regex_subject_string> where the 
search is started. If <start_position> is not a positive integer, then -1 will be returned.
Description
Returns the number of matches of a regular expression search within a string.
Example
The following example returns the number of occurrences of digits in the specified string, and returns the 
value 2:
SELECT OCCURRENCES_REGEXPR('([[:digit:]])' IN 'a1b2') "occurrences_regexpr" FROM 
DUMMY;
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 199
2.8.1.120 PLAINTEXT Function (Fulltext)
Returns the plain text representation of a value in a column that has a full text index.
Syntax
PLAINTEXT (<column_name>)
Syntax Elements
column_name
Identifier for a column that has a full text index on it.
Description
The PLAINTEXT function returns the plain text representation of a value in a column that has a full text index. 
This function can be useful when you have binary data such as a PDF as a column value; the PLAINTEXT 
function can return to you the textual data for that value.
If the specified column does not have a full text index on it, then an error is returned.
Example
The following fictitious example returns the plain text representation of a column value that is a PDF:
CREATE COLUMN TABLE T (CONTENT BLOB); CREATE FULLTEXT INDEX I ON T(CONTENT); INSERT INTO T VALUES (<somePDF>); SELECT PLAINTEXT(CONTENT),CONTENT FROM T;
Result: This is an example;<somePDF>
200 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
2.8.1.121 POWER Function (Numeric)
Calculates a specified base number raised to the power of a specified exponent.
Syntax
POWER (<b>, <e>)
Description
Calculates the base number <b> raised to the power of an exponent <e>.
Example
The following example returns the value 1024.0 for "power":
SELECT POWER (2, 10) "power" FROM DUMMY;
2.8.1.122 QUARTER Function (Datetime)
Syntax
QUARTER (<d>, [, <start_month> ])
Description
Returns the numerical year quarter of date <d>. The first quarter starts in the month specified by 
<start_month>. If <start_month> is not specified the first quarter is assumed to begin in January.
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 201
Example
The following example returns the value 2011-Q4 as the year and quarter for the specified date:
SELECT QUARTER (TO_DATE('2012-01-01', 'YYYY-MM-DD'),2) "quarter" FROM DUMMY;
2.8.1.123 RAND Function (Numeric)
Returns a pseudo-random value.
Syntax
RAND()
Description
Returns a pseudo-random value in the range of 0 to less than 1.0. Its return value type is DOUBLE.
The resulting values are not safe for cryptographic or security purposes. Use the RAND_SECURE() function 
instead for values that are safe for cryptographic or security purposes.
Example
The following example returns the pseudo-random DOUBLE value 0.4610119133779396:
SELECT RAND() FROM DUMMY;
Related Information
RAND_SECURE Function (Numeric) [page 203]
202 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
2.8.1.124 RAND_SECURE Function (Numeric)
Returns a pseudo-random value that is safe for cryptographic or security purposes.
Syntax
RAND_SECURE()
Description
Returns a value in the range of 0.0 to less than 1.0. The returned value type is DOUBLE.
Resulting values are safe for cryptographic or security purposes.
The RAND() function offers better performance, but returns a value not being safe for cryptographic or 
security purposes.
Example
The following example returns the DOUBLE value 0.9646101191337793.
SELECT RAND_SECURE() from dummy;
Related Information
RAND Function (Numeric) [page 202]
2.8.1.125 REPLACE Function (String)
Searches a string for all occurrences of a specified string and replaces them with another specified string.
Syntax
REPLACE (<original_string>, <search_string>, <replace_string>)
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 203
Description
Searches in <original_string> for all occurrences of <search_string> and replaces them with 
<replace_string>.
● If <original_string> is an empty string, then the result will be an empty string.
● If two overlapping substrings match the <search_string> in the <original_string>, then only the 
first occurrence will be replaced.
● If <original_string> does not contain any occurrence of <search_string>, then 
<original_string> will be returned unchanged.
● If <original_string>, <search_string>, or <replace_string> are NULL then NULL is returned.
Example
The following example changes all occurences of DOWN in the given string to UP and returns the value UPGRADE 
UPWARD:
SELECT REPLACE ('DOWNGRADE DOWNWARD','DOWN', 'UP') "replace" FROM DUMMY;
2.8.1.126 REPLACE_REGEXPR Function (String)
Searches a string for a regular expression pattern and returns the string with either one or every occurrence of 
the regular expression pattern that is replaced using a replacement string.
Syntax
REPLACE_REGEXPR (<pattern> [ FLAG <flag> ] IN <regex_subject_string> [ WITH 
<replacement_string> ] [ FROM <start_position> ] [ OCCURRENCE 
<regex_replace_occurrence> ])
Syntax Elements
<pattern> ::= !!Perl Compatible Regular Expression
A search pattern based on Perl Compatible Regular Expression (PCRE).
<flag> ::= 'i' | 'm' | 's' | 'x'
204 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
The matching behaviour of this function can be defined by the <flag> literal. The following options are 
available:
Table 43: Flag options
Flag option Description
i Enables case-insensitive matching
m Enables multiline mode, where the <subject_string> will be treated as multiple lines and the ex­
pression ^ and $ match just after or just before, respectively, a line terminator or the end of the input 
sequence
s Enables the expression <.> as a wildcard to match any character, including a line terminator
x Permits whitespace and comments in the pattern
<regex_subject_string> ::= <string_literal>
The string that the search pattern should be applied to. If <regex_subject_string> is empty, the result will 
be empty.
<replacement_string> ::= <string_literal>
The string replaces all occurences found by the function. The default is an empty string.
<start_position> ::= <numeric_literal>
Indicates the character of <regex_subject_string> where the search is started, if the value is a positive 
integer. Otherwise, NULL will be returned.
<regex_replace_occurrence> ::= <numeric_literal> | ALL 
A nonnegative integer or ALL, indicates the occurrence of the replace operation. If 
<regex_replace_occurrence> is a negative integer, then the <regex_subject_string> will be returned 
without any change. The default value is ALL.
Description
Searches a string for a regular expression pattern and returns the string with either one or every occurrence of 
the regular expression pattern that is replaced using a replacement string.
If any of the following parameters is NULL: <pattern>, <flag>, <regex subject_string>, 
<replacement_string>, <start_position> or <regex_replace_occurrence>, the function will return 
NULL.
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 205
Example
The following replaces the date format of 2014-04-01 using a regular expression, and returns the value 
01/04/2014:
SELECT REPLACE_REGEXPR('([[:digit:]]{4})-([[:digit:]]{2})-([[:digit:]]{2})' IN 
'2014-04-01' WITH '\3/\2/\1' OCCURRENCE ALL) "replace_regexpr" FROM DUMMY;
2.8.1.127 RESULT_CACHE_ID Function (Miscellaneous)
Returns the cache ID of the specified result cache entry.
Syntax
RESULT_CACHE_ID()
Description
Returns the cache ID of the used result cache entry. If no result cache entry is specified, NULL is returned.
Example
Use the RESULT_CACHE_ID function to find out the result cache ID for V1. This query returns 40000001.
SELECT DISTINCT RESULT_CACHE_ID() FROM V1;
206 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
2.8.1.128 RESULT_CACHE_REFRESH_TIME Function 
(Miscellaneous)
Returns the last cache refresh time of the specified result cache entry.
Syntax
RESULT_CACHE_REFRESH_TIME()
Description
Returns the last cache refresh time of the used result cache entry. If no result cache entry is specified, NULL is 
returned.
Example
You can use the RESULT_CACHE_REFRESH_TIME function to find out the last cache refresh time for V1. The 
query returns a value similar to 2015-11-20 01:01:01.010101.
SELECT DISTINCT RESULT_CACHE_REFRESH_TIME() FROM V1;
2.8.1.129 RIGHT Function (String)
Returns the rightmost specified characters or bytes of a string.
Syntax
RIGHT(<str>, <n>)
Description
Returns the rightmost <n> characters/bytes of string <str>.
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 207
Returns an empty string value of <n> is less than 1.
Returns string <str> without blank padding if the value of <n> is greater than the length of string <str>.
Example
The following example returns the rightmost 3 characters of the given string (789):
SELECT RIGHT('HI0123456789', 3) "right" FROM DUMMY;
The following example returns the entire specified string because the value 20 exceeds the string length:
SELECT RIGHT('HI0123456789', 20) "right" FROM DUMMY;
2.8.1.130 ROUND Function (Numeric)
Rounds the specified argument to the specified amount of places after the decimal point.
Syntax
ROUND (<n> [, <pos> [, <rounding_mode>]])
Description
Rounds argument <n> to the specified <pos> amount of places after the decimal point. By default, the ROUND 
function follows round half up. That is, the value <n> is rounded up to the next round figure. If the value is 
precisely in halfway between two rounded values, it is rounded up away from zero (commercial rounding).
<rounding_mode> defines how the rounding should be carried out. The options for this parameter are as 
follows:
Table 44:
Rounding Mode Rounding Rule
ROUND_HALF_UP The value is rounded up to the next round figure. If the value 
falls precisely halfway between two rounded values, it is 
rounded up away from zero (as is done in commercial 
rounding).
208 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
Rounding Mode Rounding Rule
ROUND_HALF_DOWN The value is rounded down to the next round figure. If the 
value falls precisely halfway between two round values, it is 
rounded down towards zero.
ROUND_HALF_EVEN The value is roundedto the next round figure. If the value 
falls precisely halfway between two rounded values, it is 
rounded to the value whose last decimal place is an even 
number.
ROUND_UP The value is always rounded away from zero, to the larger 
round figure.
ROUND_DOWN The value is always rounded towards zero, to the smaller 
round figure.
ROUND_CEILING The value is always rounded in a positive direction, to the 
larger value.
ROUND_FLOOR The value is always rounded in a negative direction, to the 
smaller value.
By default, ROUND function uses ROUND_HALF_UP.
When using ROUND with floating point types, REAL and DOUBLE, the precision of the numeric representation 
can affect the result that will be obtained. In this case, the actual number of digits after the decimal point is 
influenced by the precision of the type used. For example, the result of the following statement is 
399.7099914550781 not 399.71.
SELECT ROUND(TO_REAL(399.71429443359375),2) from DUMMY;
Examples
The following example returns the value 16.2 for "round":
SELECT ROUND (16.16, 1) "round" FROM DUMMY;
The following example returns the value 20 for "round":
SELECT ROUND (16.16, -1) "round" FROM DUMMY;
The following example returns the value 438.8 for "round":
SELECT ROUND( 438.75, 1, ROUND_HALF_UP) "round" FROM DUMMY;
The following example returns the value 438.7 for "round":
SELECT ROUND( 438.75, 1, ROUND_HALF_DOWN) "round" FROM DUMMY;
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 209
The following example returns the value 438.8 for "round":
SELECT ROUND( 438.75, 1, ROUND_HALF_EVEN) "round" FROM DUMMY;
The following example returns the value 438.8 for "round":
SELECT ROUND( 438.71, 1, ROUND_UP) "round" FROM DUMMY;
The following example returns the value 438.79 for "round":
SELECT ROUND( 438.79, 1, ROUND_DOWN) "round" FROM DUMMY;
The following example returns the value 438.8 for "round":
SELECT ROUND( 438.75, 1, ROUND_CEILING) "round" FROM DUMMY;
The following example returns the value 438.75 for "round":
SELECT ROUND( 438.75, 1, ROUND_FLOOR) "round" FROM DUMMY;
2.8.1.131 RPAD Function (String)
Pads the end of a string with spaces to make a string a specified number of characters in length.
Syntax
RPAD (<str>, <n> [, <pattern>])
Description
Pads the end of string <str> with spaces to make a string of <n> characters in length. If the pattern argument 
is provided, the string <str> will be padded using sequences of the given characters until the required length 
is met.
Example
The following example pads the end of string end with the pattern 12345 to make a string of 15 characters in 
length and returns the value end123451234512:
SELECT RPAD ('end', 15, '12345') "right padded" FROM DUMMY;
210 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
2.8.1.132 RTRIM Function (String)
Returns a string trimmed of all trailing spaces.
Syntax
RTRIM (<str> [,<remove_set> ])
Description
Returns string <str>, trimmed of all trailing spaces. If <remove_set> is specified, RTRIM removes all the 
characters contained in this set from the end of string <str>. This process continues until a character not the 
in <remove_set> has been reached.
<remove_set> is treated as a set of characters and not as a search string.
Example
This example removes all trailing a and b characters from the given string, and returrns the value endabA:
SELECT RTRIM ('endabAabbabab','ab') "rtrim" FROM DUMMY;
2.8.1.133 SCORE Function (Fulltext)
Returns the relevance of a record that has been found.
Syntax
SCORE()
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 211
Description
For search queries using the CONTAINS predicate, you can use the function SCORE to obtain the relevance of 
a record that has been found. SCORE() returns a real value between 0 and 1. The SAP HANA database 
calculates a score based on the following information:
● The relevance, or weighting, of attributes in a search using the CONTAINS predicate. The relevance of a 
match depends on the weight of the column that caused the match. You can specify weights as you create 
the view, or in the CONTAINS predicate.
● Fuzziness in fuzzy search. The more exact matching that occurs, the higher the score is.
● Text ranking (TF-IDF)
Examples
Example 1
Create a table that contains two strings:
CREATE COLUMN TABLE T (CONTENT TEXT FAST PREPROCESS OFF); INSERT INTO T VALUES('This is a test.'); INSERT INTO T VALUES('This was a test.');
Use the SCORE function to check the table contents for relevance against the search string 'is':
SELECT SCORE(), CONTENT FROM T WHERE CONTAINS(CONTENT, 'is', LINGUISTIC);
The query returns the following result:
0.8700000047683716;This is a test. 0.40833336114883423;This was a test.
Example 2
Create a table that contains two strings:
CREATE COLUMN TABLE T (CONTENT TEXT FAST PREPROCESS OFF); INSERT INTO T VALUES('example'); INSERT INTO T VALUES('exomple');
Use the SCORE function to check the table contents for similarity to the string 'example':
SELECT SCORE(), CONTENT FROM T WHERE CONTAINS(CONTENT, 'example',Fuzzy(0.8));
The query returns the following result:
1;example 0.8776556849479675;exomple
212 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
Related Information
CONTAINS Predicate [page 58]
CONTAINS Predicate [page 58]
2.8.1.134 SECOND Function (Datetime)
Returns a value of the seconds for a given time.
Syntax
SECOND (<t>)
Description
Returns a value of the seconds for a given time.
Subseconds are included for TIMESTAMP datatypes.
Examples
The following example returns the value 56 for the second of the specified time:
SELECT SECOND ('12:34:56') "second" FROM DUMMY;
The following example returns the value 56.789 for the subseconds of the specified time:
SELECT SECOND ('2014-03-25 12:34:56.789') "subseconds" FROM DUMMY;
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 213
2.8.1.135 SECONDS_BETWEEN Function (Datetime)
Computes the number of seconds between two specified dates.
Syntax
SECONDS_BETWEEN (<d1>, <d2>)
Description
Computes the number of seconds between date arguments <d1> and <d2>, which is semantically equal to 
(<d2> - <d1>).
Example
The following example returns the value 2678400 as the seconds between the two specified dates:
SELECT SECONDS_BETWEEN ('2009-12-05', '2010-01-05') "seconds between" FROM DUMMY;
2.8.1.136 SERIES_DISAGGREGATE Function (Series Data)
Generates a complete series table with rows disaggregated into defined partitions.
Syntax
SERIES_DISAGGREGATE ( {SERIES TABLE <source_series_table> | <source_increment_by>}, {SERIES TABLE <generate_series_table> | <target_increment_by>} [, <min_value> [, <max_value>]] ) | { SERIES_DISAGGREGATE_TINYINT
 | SERIES_DISAGGREGATE_SMALLINT
 | SERIES_DISAGGREGATE_INTEGER
 | SERIES_DISAGGREGATE_BIGINT
 | SERIES_DISAGGREGATE_SMALLDECIMAL
 | SERIES_DISAGGREGATE_DECIMAL
 | SERIES_DISAGGREGATE_TIME
 | SERIES_DISAGGREGATE_DATE
 | SERIES_DISAGGREGATE_SECONDDATE
 | SERIES_DISAGGREGATE_TIMESTAMP } 
214 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
 (source_increment_by, target_increment_by, min_value, max_value)
Syntax Elements
<source_series_table> ::= <identifier> <generate_series_table> ::= <identifier> <min_value> ::= <real_const> | <datetime_const> <max_value> ::= <real_const> | <datetime_const>
Defines the name of one or two equidistant series tables with the SERIES TABLE syntax. When using this 
syntax, the values of the source increment and/or generated increment are retrieved from the series 
definitions of the respective table references; the min_value is the greater min_value of the two specified 
tables, and the max_value is the lesser max_value of the two specified tables. The min_value and max_value 
can still be manually specified if a SERIES TABLE reference is supplied. Manually specified values override 
those in the series table definition. Thegeneric form of the procedure that takes at least one SERIES TABLE 
reference does not have to use the name of the series data type in the procedure name.
<source_increment_by> ::= <real_const> | <datetime_const> <target_increment_by> ::= <real_const> | <datetime_const>
This parameters set the source increment and target increment values.
<constant_literal> ::= <real_const> | <datetime_const>
The <constant_literal> parameter is defined as a real_const or a datetime_const. It is either an integer 
constant, an interval constant, or a defined number of elements between a minimum and maximum. If the 
period type is a DATETIME, then the number needs to be preceded by INTERVAL followed by a time unit, such 
as YEAR, MONTH, DAY, HOUR, MINUTE, or SECOND. Exponential notation is allowed.
Description
Generates a complete series table with rows disaggregated into partitions defined by the 
<generate_increment_by> parameter.
The resulting table can be joined with a series table to perform horizontal disaggregation.
For date/time types, the <increment_by parameter> should be a string of the form "INTERVAL number 
units"-where units is either YEAR, MONTH, DAY, HOUR, MINUTE, or SECOND-and the number must be an 
integer unless the units type is SECOND and the associated data type is TIMESTAMP.
The <min_value> parameter for the numeric versions of this function does not need to be aligned to numeric 
zero with respect to the <increment_by> value. You can specify a <source_increment> of 2 and a 
<min_value> of 1, which results in a source series of 1, 3, 5, and so on. This behavior differs from the SERIES 
TABLE descriptor, which requires that the values of <min_value> and <max_value> be aligned to zero with 
respect to the <increment_by> value.
This function returns a table with the following columns:
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 215
Table 45:
Column Name Column Type Description 
SOURCE_PERIOD_START PERIOD_TYPE The start of the source period that gen­
erated this row.
SOURCE_PERIOD_END PERIOD_TYPE The end of the source period that gen­
erated this row.
GENERATED_PERIOD_START PERIOD_TYPE The start of the period represented by 
this row, including the period_start. 
This value is a closed interval at the 
start.
GENERATED_PERIOD_END PERIOD_TYPE The end of the period represented by 
this row as an open interval. The period 
represented by this row consists of all 
times that are greater than or equal to 
the start and less than the end.
ELEMENT_NUMBER_IN_SOURCE_PE­
RIOD
BIGINT The element number of this period 
within its source interval.
ELEMENT_NUMBER_IN_GENER­
ATED_SERIES
BIGINT The element number within the whole 
result set.
FRACTION_OF_SOURCE_PERIOD DOUBLE The fraction of the length of the source 
period that this generated period cov­
ers.
FRACTION_OF_MIN_MAX_RANGE DOUBLE The fraction of the length of all gener­
ated periods that this generated period 
covers.
Examples
The example below illustrates how to use disaggregation when inserting data into a series table.
CREATE COLUMN TABLE sourceseries(id INT, ts TIMESTAMP, val DECIMAL(8,2)) SERIES(SERIES KEY(id ) EQUIDISTANT INCREMENT BY INTERVAL 1 YEAR
 MINVALUE '1999-01-01'
 MAXVALUE '2003-01-01'
 PERIOD FOR SERIES (ts));
 
CREATE COLUMN TABLE targetseries(id INT, ts TIMESTAMP, val DECIMAL(8,2))
 SERIES(SERIES KEY(id ) EQUIDISTANT INCREMENT BY INTERVAL 3 MONTH
 MINVALUE '1999-01-01'
 MAXVALUE '2001-01-01'
 PERIOD FOR SERIES (ts));
INSERT INTO targetseries(id , ts, val)
 SELECT id, GENERATED_PERIOD_START AS ts, val * FRACTION_OF_SOURCE_PERIOD AS 
val
 FROM SERIES_DISAGGREGATE(
 SERIES TABLE sourceseries, SERIES TABLE targetseries) SD JOIN sourceseries S ON source_period_start = ts ORDER BY id, ts;
The following result is returned result by the example above.
SOURCE_PERIOD_START;SOURCE_PERIOD_END;GENERATED_PERIOD_START; GENERATED_PERIOD_END;ELEMENT_NUMBER_IN_SOURCE_PERIOD;
216 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
ELEMENT_NUMBER_IN_GENERATED_SERIES;FRACTION_OF_SOURCE_PERIOD;
FRACTION_OF_MIN_MAX_RANGE
1;2;1;1.5;1;1;0.5;0.125
1;2;1.5;2;1;2;0.5;0.125
2;3;2;2.5;2;3;0.5;0.125
2;3;2.5;3;2;4;0.5;0.125
3;4;3;3.5;3;5;0.5;0.125
3;4;3.5;4;3;6;0.5;0.125
4;5;4;4.5;4;7;0.5;0.125 4;5;4.5;5;4;8;0.5;0.125
The example below generates a series of dates ranging from 1999-01-01 to 2001-01-04.
SELECT * FROM SERIES_DISAGGREGATE_DATE ('INTERVAL 1 year', 'INTERVAL 3 MONTH', '1999-01-01', '2001-01-04' );
The following result is returned by the example above.
SOURCE_PERIOD_START;SOURCE_PERIOD_END;GENERATED_PERIOD_START; GENERATED_PERIOD_END;ELEMENT_NUMBER_IN_SOURCE_PERIOD;
 ELEMENT_NUMBER_IN_GENERATED_SERIES;FRACTION_OF_SOURCE_PERIOD;
 FRACTION_OF_MIN_MAX_RANGE
 Jan 1, 1999;Jan 1, 2000;Jan 1, 1999;Apr 1, 
1999;1;1;0.2465753424657534;0.12311901504787962
 Jan 1, 1999;Jan 1, 2000;Apr 1, 1999;Jul 1, 
1999;1;2;0.2493150684931507;0.12448700410396717
 Jan 1, 1999;Jan 1, 2000;Jul 1, 1999;Oct 1, 
1999;1;3;0.25205479452054796;0.12585499316005472
 Jan 1, 1999;Jan 1, 2000;Oct 1, 1999;Jan 1, 
2000;1;4;0.25205479452054796;0.12585499316005472
 Jan 1, 2000;Jan 1, 2001;Jan 1, 2000;Apr 1, 
2000;2;5;0.24863387978142076;0.12448700410396717
 Jan 1, 2000;Jan 1, 2001;Apr 1, 2000;Jul 1, 
2000;2;6;0.24863387978142076;0.12448700410396717
 Jan 1, 2000;Jan 1, 2001;Jul 1, 2000;Oct 1, 
2000;2;7;0.25136612021857924;0.12585499316005472 Jan 1, 2000;Jan 1, 2001;Oct 1, 2000;Jan 1, 
2001;2;8;0.25136612021857924;0.12585499316005472
The example below returns the same result set as the previous example. The most restrictive values of the 
min/max in the series table references are used.
CREATE COLUMN TABLE sourceseries(id INT, ts TIMESTAMP, val DECIMAL(8,2)) SERIES(SERIES KEY(id ) EQUIDISTANT INCREMENT BY INTERVAL 1 YEAR
 MINVALUE '1999-01-01'
 MAXVALUE '2003-01-01'
 PERIOD FOR SERIES (ts));
CREATE COLUMN TABLE targetseries(id INT, ts TIMESTAMP, val DECIMAL(8,2))
 SERIES(SERIES KEY(id ) EQUIDISTANT INCREMENT BY INTERVAL 3 MONTH
 MINVALUE '1999-01-01'
 MAXVALUE '2001-01-01'
 PERIOD FOR SERIES (ts));
SELECT * from SERIES_DISAGGREGATE( SERIES TABLE sourceseries, SERIES TABLE targetseries);
The example below illustrates how to create a series table and perform a horizontal disaggregation.
CREATE COLUMN TABLE testdata AS ( SELECT g.*, CAST(RAND() * 10 AS DECIMAL(5, 2)) AS val
 FROM SERIES_GENERATE_DECIMAL(1,0,10000) g);
 SELECT s.ELEMENT_NUMBER, s.val,
 g.ELEMENT_NUMBER_IN_GENERATED_SERIES,
 s.val * g.FRACTION_OF_SOURCE_PERIOD AS DA
 FROM testdata AS s
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 217
 LEFT JOIN SERIES_DISAGGREGATE_DECIMAL(1, 0.5, 0, 10000) g ON s.GENERATED_PERIOD_START = g.SOURCE_PERIOD_START;
The example above returns a result similar to the following.
 1;1.56;1;0.78 1;1.56;2;0.78
 2;5.4;3;2.7
 2;5.4;4;2.7
 3;7.24;5;3.62
 3;7.24;6;3.62
 4;8.38;7;4.19
 4;8.38;8;4.19 ...
2.8.1.137 SERIES_ELEMENT_TO_PERIOD Function (Series 
Data)
Returns the series period value associated with the specified one-based series element number.
Syntax
SERIES_ELEMENT_TO_PERIOD (<element_number>, { <increment_by>, <min_value>, <max_value> | SERIES TABLE <series_table>})
Syntax Elements
<series_table> ::= <identifier>
If a series table reference is used, then the <increment_by>, <min_value>, and <max_value> values from 
the SERIES TABLE definition are used as the parameters for this function.
<element_number> ::= INTEGER
This parameter specifies the element number.
<increment_by> ::= <real_const> | <interval_const>
Increment_by is defined as a real_const or an interval_const. It is either an integer constant, an interval 
constant, or a defined number of elements between a minimum and maximum. If the period type is a 
DATETIME, then the number needs to be preceded by INTERVAL followed by a time unit, such as YEAR, 
MONTH, DAY, HOUR,MINUTE, or SECOND. Exponential notation is allowed.
<min_value> ::= <real_const> | <datetime_const> <max_value> ::= <real_const> | <datetime_const>
218 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
These parameters specify the minimum and maximum value. The <min_value> and <max_value> 
parameters can either be numeric or date/time values.
Description
Returns the series period value associated with the provided one-based series element number, where 
rounded_period = SERIES_ROUND(period, interval, round_mode) and element = 1 + ( rounded_period - 
min_value ) / interval.
Examples
The example picks the 5th element from a series from 0 to 10 in increments of 2. It returns the result 8.
SELECT SERIES_ELEMENT_TO_PERIOD(5, 2, 0, 10) "val" FROM DUMMY;
The example picks the 6th element from a series from 1 to 10 in increments of 1.25. It returns the result 7.25.
SELECT SERIES_ELEMENT_TO_PERIOD(6, 1.25, 1, 10) "val" FROM DUMMY;
The example picks the 7th element from a date series from 2014-01-01 to 2014-12-31 in increments of 1 day. It 
returns the result Jan 7, 2014.
SELECT SERIES_ELEMENT_TO_PERIOD(7, 'INTERVAL 1 DAY', '2014-01-01', '2014-12-31') "val" FROM DUMMY;
The previous example could be written as follows to refer to an equidistant series table.
CREATE COLUMN TABLE ExampleSeriesTable(id INTEGER, ts TIMESTAMP) SERIES(SERIES KEY(id) EQUIDISTANT INCREMENT BY INTERVAL 1 DAY
 MINVALUE '2014-01-01' MAXVALUE '2014-12-31' PERIOD FOR SERIES(ts)); 
SELECT SERIES_PERIOD_TO_ELEMENT(
 '2014-01-07' ,
 SERIES TABLE ExampleSeriesTable) "element" FROM DUMMY;
The example picks the 7th element from a date series from 2014-01-01 to 2014-12-31 in increments of 1 month. 
It returns the result Jul 1, 2014.
SELECT SERIES_ELEMENT_TO_PERIOD(7, 'INTERVAL 1 MONTH', '2014-01-01', '2014-12-31') "val" FROM DUMMY;
The example picks the 500.000th element from a time series from 2014-01-01 to 2014-12-31 in increments of 
1.5 seconds. It returns the result Jan 9, 2014 4:19:58 PM.500.
SELECT SERIES_ELEMENT_TO_PERIOD(500000, 'INTERVAL 1.5 SECOND', '2014-01-01 00:00:00.000', '2014-12-31') "val" FROM DUMMY;
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 219
2.8.1.138 SERIES_GENERATE Function (Series Data)
Generates a complete series table based on the specified series definition.
Syntax
SERIES_GENERATE (SERIES TABLE <table_name> [, <min_value> [, <max_value>]]) | <series_generate_datatype>
Syntax Elements
table_name
Specifies the name of the series table containing the series definition.
<table_name> ::= <identifier>
min_value
Sets the minimum value of the generated series. This overrides the value defined in the series table, if one 
is specified.
<min_value> ::= <numeric_literal> | <date_literal>
max_value
Sets the maximum value of the generated series. This overrides the value defined in the series table, if one 
is specified.
<max_value> ::= <numeric_literal> | <date_literal>
series_generate_datatype
A version of the function that specifies the data type for the generated parameters.
<series_generate_datatype> ::= SERIES_GENERATE_TINYINT <generate_parameters> | SERIES_GENERATE_SMALLINT <generate_parameters> | SERIES_GENERATE_INTEGER <generate_parameters> | SERIES_GENERATE_BIGINT <generate_parameters> | SERIES_GENERATE_SMALLDECIMAL <generate_parameters> | SERIES_GENERATE_DECIMAL <generate_parameters> | SERIES_GENERATE_TIME <generate_parameters> | SERIES_GENERATE_DATE <generate_parameters> | SERIES_GENERATE_SECONDDATE <generate_parameters> | SERIES_GENERATE_TIMESTAMP <generate_parameters>
generate_parameters
Specifies the increment value used to generate parameters.
<generate_parameters> ::= (<increment_by>, <min_value>, <max_value>)
220 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
 <increment_by> ::= <numeric_literal> | <date_literal>
<increment_by> defines the period size. If the period type is a DATETIME, then the number needs to 
be preceded by INTERVAL followed by a time unit, such as YEAR, MONTH, DAY, HOUR, MINUTE, or 
SECOND.
Description
This function generates a complete series table based on the given series definition.
The range is defined by the <min_value> and <max_value> parameters, and the period size is defined by the 
<increment_by> parameter. The <min_value> and <max_value>Specifies the increment value used to 
generate values must be aligned with the <increment_by> value. The generated intervals have closed-open 
semantics, so the GENERATED_PERIOD_END does not belong to the interval.
Alternatively, the name of an existing series table can be defined with the SERIES TABLE syntax. In this case, 
the values of the increment, <min_value>, and <max_value> are retrieved from the series definition 
associated with that table. The <min_value> and <max_value> can still be manually specified if a SERIES 
TABLE reference is supplied; the manually specified values override those in the series table definition. The 
generic form of the procedure that takes at least one SERIES TABLE reference does not have to use the name 
of the series data type in the procedure name.
The <min_value> parameter for the numeric versions of this function does not need to be aligned to numeric 
zero with respect to the <increment_by> value. You can specify a source increment of 2 and a <min_value> 
of 1, which results in a source series of 1, 3, 5, and so on. This behavior differs from the SERIES TABLE 
descriptor, which requires that the values of <min_value> and <max_value> be aligned to zero with respect 
to the <increment_by> value.
This function returns a table with the following columns:
Table 46:
Column Name Column Type Description 
GENERATED_PERIOD_START PERIOD_TYPE Specifies the start of the period repre­
sented by this row, including the 
<period_start> parameter. This is a 
closed interval at the start.
GENERATED_PERIOD_END PERIOD_TYPE Specifies the end of the period repre­
sented by this row as an open interval. 
The period represented by this row 
consists of all times that are greater 
than or equal to the start, and less than 
the end.
ELEMENT_NUMBER BIGINT Specifies the element number of this 
period within the generated series. This 
value is equivalent to the result set's 
row number.
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 221
FRACTION_OF_MIN_MAX_RANGE DOUBLE Specifies the ratio of the length of this 
period to the length of all periods gen­
erated by this function. The sum of 
FRACTION_OF_MIN_MAX_RANGE is 
close to 1.0. For fixed size intervals, 
such as 1 DAY, the value is computed 
as 1/numPeriods. For non-fixed size in­
tervals, such as MONTH and YEAR, the 
value is computed individually for each 
row, which is calculated by the time 
span of the interval divided by the time 
span of the entire result.
Examples
The example below illustrates how to generate a series table.
CREATE COLUMN TABLE MyTab ( profile_id INT,
 ts TIMESTAMP,
 consumption DECIMAL(4,3))
 SERIES(
 SERIES KEY(profile_id)
 PERIOD FOR SERIES(ts)
 EQUIDISTANT INCREMENT BY INTERVAL 1 HOUR MISSING ELEMENTS ALLOWED
 MINVALUE '2010-01-01'
 MAXVALUE '2015-01-01'); SELECT * FROM SERIES_GENERATE_TIMESTAMP(SERIES TABLE MyTab);
The example below generates a series of decimals ranging from 0 to 10 that increments by 2.5.
SELECT * FROM SERIES_GENERATE_DECIMAL(2.5, 0, 10);
The following result is returned by the example above.
GENERATED_PERIOD_START;GENERATED_PERIOD_END;ELEMENT_NUMBER;FRACTION_OF_MIN_MAX_RA
NGE 0;2.5;1;0.25
 2.5;5;2;0.25
 5;7.5;3;0.25 7.5;10;4;0.25
The example below generates a series of integers ranging from 1 to 5 that increments by 2.
SELECT * FROM SERIES_GENERATE_INTEGER(2, 1, 5);
The following result is returned by the example above.
GENERATED_PERIOD_START;GENERATED_PERIOD_END;ELEMENT_NUMBER;FRACTION_OF_MIN_MAX_RA
NGE 1;3;1;0.5 3;5;2;0.5222 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
The example below illustrates an equivalent way of writing the previous example using the SERIES TABLE 
syntax and a series table named MySeries.
CREATE COLUMN TABLE MySeries(id INTEGER, pos INTEGER) SERIES(SERIES KEY(id) EQUIDISTANT INCREMENT BY 1
 MINVALUE 1 MAXVALUE 5 PERIOD FOR SERIES(pos)); SELECT * FROM SERIES_GENERATE(SERIES TABLE MySeries);
The example below generates a series of timestamps ranging from 1999-01-01 to 1999-01-02 that increments 
by 30 second intervals.
SELECT * FROM SERIES_GENERATE_TIMESTAMP( 'INTERVAL 30 SECOND', '1999-01-01', '1999-01-02');
The following result is returned by the example above.
GENERATED_PERIOD_START;GENERATED_PERIOD_END;ELEMENT_NUMBER;FRACTION_OF_MIN_MAX_RA
NGE Jan 1, 1999 12:00:00 AM.000;Jan 1, 1999 12:00:30 AM.000;1;0.00034722222222222224
 Jan 1, 1999 12:00:30 AM.000;Jan 1, 1999 12:01:00 AM.000;2;0.00034722222222222224
 Jan 1, 1999 12:01:00 AM.000;Jan 1, 1999 12:01:30 AM.000;3;0.00034722222222222224
 Jan 1, 1999 12:01:30 AM.000;Jan 1, 1999 12:02:00 AM.000;4;0.00034722222222222224
 ...
 Jan 1, 1999 11:59:00 PM.000;Jan 1, 1999 11:59:30 PM.
000;2,879;0.00034722222222222224 Jan 1, 1999 11:59:30 PM.000;Jan 2, 1999 12:00:00 AM.
000;2,880;0.00034722222222222224
The example below illustrates how to implement a series of timestamps ranging from 1999-01-01 to 
1999-01-02 that increments by 30 second intervals using a series table named testseries.
CREATE COLUMN TABLE testseries(id INT, ts TIMESTAMP, val DOUBLE) SERIES (SERIES KEY(id) EQUIDISTANT INCREMENT BY INTERVAL 30 SECOND
 MINVALUE '1999-01-01' MAXVALUE '1999-01-02' PERIOD FOR SERIES (ts)); SELECT * FROM SERIES_GENERATE(SERIES TABLE testseries);
The example below illustrates how to generate a date series table with closed-closed semantics where the 
period end belongs to the interval.
SELECT GENERATED_PERIOD_START AS from_date, ADD_DAYS(GENERATED_PERIOD_END, -1) AS to_date FROM SERIES_GENERATE_DATE('INTERVAL 1 MONTH', '2010-01-01', '2011-01-01')
2.8.1.139 SERIES_PERIOD_TO_ELEMENT Function (Series 
Data)
Returns the one-based series element number that the given period value is associated with.
Syntax
SERIES_PERIOD_TO_ELEMENT (<value>, 
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 223
 {<increment_by>, <min_value>, <max_value> [, <rounding_mode>] | SERIES TABLE <series_table> [, <rounding_mode>]})
Syntax Elements
<value> ::= INTEGER | DOUBLE | TIMESTAMP
The <value> parameter can either be a numeric value or a date/time type.
<increment_by> ::= <identifier>
If the value parameter is a date/time type, then the <increment_by> parameter should be a string of the 
form "INTERVAL number units"-where units is either YEAR, MONTH, DAY, HOUR, MINUTE, or SECOND-and 
the number must be an integer unless the units type is SECOND and the associated data type is TIMESTAMP. 
If the value is numeric, then the <increment_by> parameter should be a numeric value that defines the 
period of the series.
<min_value> ::= <integer> <max_value> ::= <integer>
For an equidistant series, there is a mapping between periods and elements. The periods are in the space of 
the period columns, usually timestamps. The elements are always BIGINT. The element 1 represents the first 
period, associated with <min_value>.
<rounding_mode> ::= ROUND_HALF_UP | ROUND_HALF_DOWN
 | ROUND_HALF_EVEN
 | ROUND_UP
 | ROUND_DOWN
 | ROUND_CEILING | ROUND_FLOOR
If the period value is not on a series period value, then it is rounded to the nearest series period value 
according to the rounding mode. The associated element number is then returned. The supported rounding 
modes are:
Table 47:
Rounding mode Description 
ROUND_HALF_UP The value is rounded to the nearest series value. Values that 
fall halfway between two series values are rounded up away 
from zero.
This is the default value.
ROUND_HALF_DOWN The value is rounded to the nearest series value. Values that 
fall halfway between two round values are rounded down to­
wards zero.
ROUND_HALF_EVEN The value is rounded to the nearest series value. Values that 
fall halfway between two rounded values are rounded to the 
even series value based on element number.
224 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
ROUND_UP The value is always rounded away from zero, to the larger 
series value.
ROUND_DOWN The value is always rounded towards zero, to the smaller 
series value.
ROUND_CEILING The value is always rounded in a positive direction, to the 
larger series value.
ROUND_FLOOR The value is always rounded in a negative direction, to the 
smaller series value.
<series_table> ::= <identifier>
If a series table reference is used, then the values for <increment_by>, <min_value>, and <max_value> 
from the SERIES TABLE definition are used as the parameters for this function.
Description
Returns the one-based series element number with which the given period value is associated, where period = 
min_value + ( element - 1 ) * interval.
Examples
The example returns the result 4.
SELECT SERIES_PERIOD_TO_ELEMENT(5, 2, 0, 10, ROUND_HALF_UP) "element" FROM DUMMY;
The example below returns the result 3.
SELECT SERIES_PERIOD_TO_ELEMENT(5, 2, 0, 10, ROUND_HALF_DOWN) "element" FROM 
DUMMY;
The example below picks the next element rounded down from 2014-01-05 12:00:00 from a date series from 
2014-01-01 to 2014-12-32 in increments of 1 day. It returns the result 5.
SELECT SERIES_PERIOD_TO_ELEMENT( '2014-01-05 12:00:00',
 'INTERVAL 1 DAY',
 '2014-01-01',
 '2014-12-31', ROUND_HALF_DOWN) "element" FROM DUMMY;
The previous example could be written as follows to refer to an equidistant series table.
CREATE COLUMN TABLE ExampleSeriesTable(id INTEGER, ts TIMESTAMP) SERIES(SERIES KEY(id) EQUIDISTANT INCREMENT BY INTERVAL 1 DAY
 MINVALUE '2014-01-01' MAXVALUE '2014-12-31' PERIOD FOR SERIES(ts)); SELECT SERIES_PERIOD_TO_ELEMENT('2014-01-05 12:00:00', SERIES TABLE 
ExampleSeriesTable, ROUND_HALF_DOWN) "element" FROM DUMMY;
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 225
2.8.1.140 SERIES_ROUND Function (Series Data)
Rounds a specified value to the series value using a specified increment.
Syntax
SERIES_ROUND (<value>, {<increment_by> | SERIES TABLE <series_table>} [, <rounding_mode> [, 
<alignment_expression>]])
Syntax Elements
<value> ::= <real_const> | <datetime_const>
The value parameter can either be a numeric value or a date/time type.
<increment_by>::= <interval_const>
If the <value> parameter is numeric, then the <increment_by> value must be a numeric value that defines 
the period of the series. If the <value> parameter is a date/time type, then the <increment_by> value must 
be a string of the form "INTERVAL number units"-where units is either YEAR, MONTH, DAY, HOUR, MINUTE, 
or SECOND-and number must be an integer unless the units type is SECOND and the associated data type is 
TIMESTAMP.
<series_table> ::= <identifier>
The maximum and minimum values specified in a provided series table are used to calculate the rounded 
values. If a SERIES TABLE reference is specified, then the <increment_by> value is retrieved from the series 
descriptor of that table. This series must be equidistant.
<rounding_mode> ::= ROUND_HALF_UP | ROUND_HALF_DOWN
 | ROUND_HALF_EVEN
 | ROUND_UP
 | ROUND_DOWN
 | ROUND_CEILING | ROUND_FLOOR
The natural zero that serves as the basis for the rounding depends on the data type and interval. For numeric 
types, zero is the numeric zero. For date types with the interval units of DAY or smaller, zero is midnight. For 
MONTH and YEAR intervals, zero is midnight on the first day of the month, and midnight on the first day of the 
year, respectively. The following rounding modes are supported:
Table 48:
Mode Description 
226 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
ROUND_HALF_UP Defaultvalue.
The value is rounded to the nearest series value. Values that 
fall halfway between two series values are rounded up away 
from zero.
ROUND_HALF_DOWN The value is rounded to the nearest series value. Values that 
fall halfway between two round values are rounded down to­
wards zero.
ROUND_HALF_EVEN The value is rounded to the nearest series value. Values that 
fall halfway between two rounded values are rounded to the 
even series value based on element number.
ROUND_UP The value is always rounded away from zero, to the larger 
series value.
ROUND_DOWN The value is always rounded towards zero, to the smaller 
series value.
ROUND_CEILING The value is always rounded in a positive direction, to the 
larger series value.
ROUND_FLOOR The value is always rounded in a negative direction, to the 
smaller series value.
<alignment_expression> ::= <real_const> | <datetime_const>
This parameter must be convertible to the <value> data type. A <rounding_mode> must be specified when 
using this parameter.
Description
Rounds the value to the series value defined by the <increment_by> parameter.
Examples
The example below horizontally aggregates a series table by using the ROUND_DOWN mode.
CREATE COLUMN TABLE ExampleSeriesTable( sid INTEGER NOT NULL,
 ts TIMESTAMP NOT NULL,
 val DOUBLE)
 SERIES(SERIES KEY(sid) PERIOD FOR SERIES(ts)
 EQUIDISTANT INCREMENT BY INTERVAL 60 SECOND);
SELECT rounded.sid, week, AVG(val) AS weekly_avg FROM(
 SELECT t.sid, SERIES_ROUND(ts, 'INTERVAL 7 DAY', ROUND_DOWN)
 AS week, val FROM ExampleSeriesTable AS t
 ) AS rounded GROUP BY rounded.sid, week;
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 227
The example below illustrates another way to perform horizontal aggregation, using the fictional table 
DailyWeather.
INSERT INTO DailyWeather(id, date, avg_temp) SELECT id, SERIES_ROUND(ts, SERIES TABLE DailyWeather) date, AVG(temp)
 FROM HourlyWeather
 GROUP BY id, SERIES_ROUND(ts, SERIES TABLE DailyWeather) ORDER BY 1, 2;
The example below illustrates different ways of aggregating data when moving from narrower to wider 
intervals.
CREATE COLUMN TABLE SampleSensorData ( machine_id varchar(10),
 ts timestamp,
 power_consumption double,
 flow_rate double,
 primary key(machine_id, ts))
SERIES (
 SERIES KEY(machine_id)
 PERIOD FOR SERIES(ts)
 EQUIDISTANT INCREMENT BY INTERVAL 1 MINUTE MISSING ELEMENTS ALLOWED);
-- Going from 1 minute to 1 day using Standard SQL:
SELECT machine_id,
 TO_DATE(YEAR(ts) || '-' || MONTH(ts) || '-' || DAYOFMONTH(ts),
 'YYYY-MM-DD') AS ts,
 SUM(power_consumption) AS power_consumption
 FROM SampleSensorData
 GROUP BY machine_id, YEAR(ts), MONTH(ts), DAYOFMONTH(ts);
-- Going from 1 minute to 15 minutes using SERIES_ROUND:
SELECT machine_id, ts AS original_ts,
 SERIES_ROUND(ts, 'INTERVAL 15 MINUTE', ROUND_FLOOR) AS rounded_ts
 FROM SampleSensorData
 WHERE machine_id = 'EQ42-P01'
 ORDER BY ts;
-- Going from 1 minute to 15 minutes using SERIES_ROUND (variant #1)
SELECT machine_id, ts, SUM(power_consumption) AS power_consumption
 FROM (
 SELECT machine_id, SERIES_ROUND(ts, 'INTERVAL 15 MINUTE', ROUND_FLOOR)
 AS ts, power_consumption
 FROM SampleSensorData
 )
 GROUP BY machine_id, ts
 ORDER BY machine_id, ts;
-- Going from 1 minute to 15 minutes using SERIES_ROUND (variant #2)
SELECT machine_id, SERIES_ROUND(ts, 'INTERVAL 15 MINUTE', ROUND_FLOOR)
 AS ts, sum(power_consumption) AS power_consumption
 FROM SampleSensorData GROUP BY machine_id, SERIES_ROUND(ts, 'INTERVAL 15 MINUTE', ROUND_FLOOR);
The example below shows how to round up 4.5 to a series incremented by 3. It returns the result 6.
SELECT SERIES_ROUND(4.5, 3, ROUND_HALF_UP) "result" FROM DUMMY;
The example below shows how to round down 4.5 to a series incremented by 3. The example below shows 
returns the result 3.
SELECT SERIES_ROUND(4.5, 3, ROUND_HALF_DOWN) "result" FROM DUMMY;
The previous example could be written as follows to refer to an equidistant series table.
CREATE COLUMN TABLE ExampleSeriesTable(id INTEGER, pos INTEGER) SERIES(SERIES KEY(id) EQUIDISTANT INCREMENT BY 3 PERIOD FOR SERIES(pos));
228 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
SELECT SERIES_ROUND(4.5, SERIES TABLE ExampleSeriesTable, ROUND_HALF_DOWN) "result" FROM DUMMY;
The example below shows how to round down a date to the beginning of the year. It returns the result Jan 1, 
2013.
SELECT SERIES_ROUND('2013-05-24', 'INTERVAL 1 YEAR', ROUND_DOWN) "result" FROM DUMMY;
The example below shows how to round up a time to the next 10 minute interval. It returns the result 4:30:00 
AM.
SELECT SERIES_ROUND('04:25:01', 'INTERVAL 10 MINUTE') "result" FROM DUMMY;
2.8.1.141 SESSION_CONTEXT Function (Miscellaneous)
Returns the value of the specified session variable assigned to the current user.
Syntax
SESSION_CONTEXT(session_variable)
Description
Returns the value of session_variable assigned to the current user.
The session_variable accessed can either be predefined or user-defined. Predefined session variables that can 
be set by the client are 'APPLICATION', 'APPLICATIONUSER', and 'TRACEPROFILE'.
Session variables can be defined or modified using a SET [SESSION] <variable_name> = <value> 
statement, and unset using an UNSET [SESSION] <variable_name> statement.
SESSION_CONTEXT returns an NVARCHAR with a maximum length of 512 characters.
This feature is used with restrictions and/or is extended by the following SAP HANA option(s):
● SAP HANA smart data integration
Example
The following query returns the value HDBStudio:
SELECT SESSION_CONTEXT('APPLICATION') "session context" FROM DUMMY;
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 229
Related Information
SET [SESSION] Statement (Session Management) [page 527]
UNSET [SESSION] Statement (Session Management) [page 529]
Session Management Statements [page 522]
SESSION_USER Function (Miscellaneous) [page 230]
M_SESSION_CONTEXT System View [page 1324]
2.8.1.142 SESSION_USER Function (Miscellaneous)
Returns the user name of the current session.
Syntax
SESSION_USER
Description
Returns the user name of the current session.
Example
The following query returns SYSTEM.
SELECT SESSION_USER "session user" FROM DUMMY;
Consider the following definer-mode procedure that is declared by USER_A:
CREATE PROCEDURE USER_A.PROC1 LANGUAGE SQLSCRIPT SQL SECURITY DEFINER AS BEGIN
 SELECT SESSION_USER "session user" FROM DUMMY; END;
The following query returns USER_B when USER_B executes USER_A.PROC.
CALL USER_A.PROC1;
Consider the following invoker-mode procedure that is declared by USER_A
CREATE PROCEDURE USER_A.PROC2 LANGUAGE SQLSCRIPT SQL SECURITY INVOKER AS BEGIN
230 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
 SELECT SESSION_USER "session user" FROM DUMMY; END; 
The following query returns USER_B when USER_B executes USER_A.PROC.
CALL USER_A.PROC2;
Related Information
Session Management Statements [page 522]
M_SESSION_CONTEXT System View [page 1324]
SESSION_CONTEXT Function (Miscellaneous) [page 229]
2.8.1.143 SIGN Function (Numeric)
Returns the sign (positive or negative) of the specified numeric argument.
Syntax
SIGN (<n>)
Description
Returns the sign (positive or negative) of the numeric argument <n>.
Returns 1 if <n> is a positive value, -1 if <n> is a negative value, 0 if <n> is equal to zero, and NULL if <n> is 
equal to NULL.
Example
The following example returns the value -1 for "sign":
SELECT SIGN (-15) "sign" FROM DUMMY;
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 231
2.8.1.144 SIN Function (Numeric)
Returns the sine of an angle expressed in radians.
Syntax
SIN (<n>)
Description
Returns the sine of <n>, where <n> is an angle expressed in radians.
Example
The following example returns the value 1.0 for "sine":SELECT SIN ( 3.141592653589793/2) "sine" FROM DUMMY;
2.8.1.145 SINH Function (Numeric)
Returns the hyperbolic sine of an angle expressed in radians.
Syntax
SINH (<n>)
Description
Returns the hyperbolic sine of <n>, where the argument is an angle expressed in radians.
232 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
Example
The following example returns the value 0.0 for "sinh":
SELECT SINH (0.0) "sinh" FROM DUMMY;
2.8.1.146 SQRT Function (Numeric)
Returns the square root of the specified argument.
Syntax
SQRT (n)
Description
Returns the square root of the numeric argument <n>.
Example
The following example returns the value 1.4142135623730951 for "sqrt":
SELECT SQRT (2) "sqrt" FROM DUMMY;
2.8.1.147 STDDEV_POP Function (Aggregate)
Returns the standard deviation of a given expression as the square root of VAR_POP function.
Syntax
STDDEV_POP(<expression>)
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 233
Description
Returns the standard deviation of the given expression as the square root of VAR_POP function.
Examples
The following examples returns 0 for the standard deviation of the specified expression:
CREATE ROW TABLE RTABLE (A INT); INSERT INTO RTABLE VALUES (1); SELECT STDDEV_POP(A) "STDDEVPOP" FROM RTABLE;
The following examples returns 0.5 for the standard deviation of the specified expression:
INSERT INTO RTABLE VALUES (2); SELECT STDDEV_POP(A) "STDDEVPOP" FROM RTABLE;
2.8.1.148 STDDEV_SAMP Function (Aggregate)
Returns the standard deviation of the given expression as the square root of VAR_SAMP function.
Syntax
STDDEV_SAMP(<expression>)
Description
Returns the standard deviation of the given expression as the square root of VAR_SAMP function.
Examples
The following example returns NULL for the standard deviation of the specified expression, as the square root 
of VAR_SAMP function:
CREATE ROW TABLE RTABLE (A INT); INSERT INTO RTABLE VALUES (1); SELECT STDDEV_SAMP(A) "STDDEVSAMP" FROM RTABLE;
234 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
The following example returns 0.707107 for the standard deviation of the specified expression, as the square 
root of VAR_SAMP function:
INSERT INTO RTABLE VALUES (2); SELECT STDDEV_SAMP(A) "STDDEVSAMP" FROM RTABLE;
2.8.1.149 STRING_AGG Function (Aggregate)
Returns the concatenation string of the specified expression.
Syntax
STRING_AGG(<expression>[, <delimiter>] [<order_by_clause>])
Syntax Elements
expression
A VARCHAR or NVARCHAR value to be concatenated. If<expression> is a different data type, then 
implicit casting is performed.
For example, if the "NUM" column has five integer values (1, 2, 3, 4, 5), then STRING_AGG("NUM",0) 
returns '102030405'.
delimiter
Specifies the character to use as a delimiter when aggregating <expression>.
order_by_clause
Sorts records by expressions or positions.
<order_by_clause> ::= ORDER BY<order_by_expresion>[, ...] <order_by_expression> ::= <expression>[ASC | DESC] [NULLS FIRST | NULLS LAST]
Description
NULL values are treated as empty strings.
The default ordering is ASC NULLS FIRST. If DESC is specified, then the ORDER BY expression becomes DESC 
NULLS LAST.
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 235
Example
Create table r1 and populate it with data.
CREATE ROW TABLE r1(a INT, str VARCHAR(20), grp INT); INSERT INTO r1 VALUES (3,'str2',0);
INSERT INTO r1 VALUES (0,'str1',0);
INSERT INTO r1 VALUES (NULL,'NULL',0);
INSERT INTO r1 VALUES (5,'str3',0);
INSERT INTO r1 VALUES (3,'val3',1);
INSERT INTO r1 VALUES (6,'val6',1);
INSERT INTO r1 VALUES (NULL,'NULL',1); INSERT INTO r1 VALUES (1,'val1',1);
Execute the following statement to return the concatenation string of each record from table r1 in 
ascending order.
SELECT grp, STRING_AGG(str,','ORDER BY a)AS agg FROM R1 GROUP BY grp;
The statement above returns the following results.
Table 49:
GRP AGG
0 NULL,str1,str2,str3
1 NULL,val1,val3,val6
Execute the following statement to return the concatenation string of each record from table r1 in 
descending order.
SELECT grp, STRING_AGG(str,','ORDER BY a DESC) AS agg FROM r1 GROUP BY grp;
The statement above returns the following results.
Table 50:
GRP AGG
0 str3,str2,str1,NULL
1 val6,val3,val1,NULL
236 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
2.8.1.150 STRTOBIN Function (String)
Converts all characters in a string into a binary encoding using the specified codepage.
Syntax
STRTOBIN (<str>, <codepage>)
Description
Converts all characters in string <str> into a binary encoding using the defined codepage.
Example
This example converts all characters in the given string to binary UTF-16BE encoding, and returns the value 
0041006E0074:
SELECT STRTOBIN ('Ant', 'UTF-16BE') "strtobin" FROM DUMMY;
2.8.1.151 SUBARRAY Function (Miscellaneous)
Returns a subset of values from the specified array beginning from the specified start position.
Syntax
SUBARRAY (<array_value_expression>, <start_position> , <length>)
Description
Returns values set of <array_value_expression> starting from <start_position> within the string. The 
number of values is determined by <length>.
If <start_position> is less than or equal to 0, then it is considered as 1.
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 237
If the <length> is less than or equal to 0, or it is greater than the number of remaining part of 
<array_value_expression>, SUBARRAY returns the remaining part from the <start_position>.
Example
The following examples use the SUBARRAY function to return subsets from arrays.
CREATE COLUMN TABLE ARRAY_TEST (IDX INT, VAL INT ARRAY); INSERT INTO ARRAY_TEST VALUES (1, ARRAY(1, 2, 3)); INSERT INTO ARRAY_TEST VALUES (2, ARRAY(10, 20, 30, 40));
Table 51:
Query Returns
SELECT SUBARRAY(VAL, 1, 2) "subarray" 
FROM ARRAY_TEST;
1, 2 10, 20
SELECT SUBARRAY(VAL, 1, 10) 
"subarray" FROM ARRAY_TEST;
1, 2, 3 10, 20, 30, 40
2.8.1.152 SUBSTR_AFTER Function (String)
Returns a substring of a specified string that follows the first occurrence of the pattern argument.
Syntax
SUBSTR_AFTER (<str>, <pattern>)
Description
Returns a substring of string <str> that follows the first occurrence of the pattern argument.
● If <str> does not contain the <pattern> substring, then an empty string is returned.
● If <pattern> is an empty string, then <str> is returned.
● If <str> or <pattern> is NULL, then NULL is returned.
238 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
Example
This example returns the part of the given string that is to the right of the first occurence of My (Friend):
SELECT SUBSTR_AFTER ('Hello My Friend','My ') "substr after" FROM DUMMY;
2.8.1.153 SUBSTR_BEFORE Function (String)
Returns a substring of a specified string before the first occurrence of the pattern argument in the target 
string.
Syntax
SUBSTR_BEFORE (<str>, <pattern>)
Description
Returns a substring of string <str> before the first occurrence of the pattern argument in the target string.
● If <str> does not contain the <pattern> substring, then an empty string is returned.
● If <pattern> is an empty string, then <str> is returned.
● If <str> or <pattern> is NULL, then NULL is returned.
Example
The following example returns the part of the given string that is left to the first occurence of My (Hello):
SELECT SUBSTR_BEFORE ('Hello My Friend','My') "substr before" FROM DUMMY;
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 239
2.8.1.154 SUBSTRING_REGEXPR Function (String)
Searches a string for a regular expression pattern and returns one occurrence of the matching substring.
Syntax
SUBSTRING_REGEXPR | SUBSTR_REGEXPR ( <pattern> [ FLAG <flag> ] IN 
<regex_subject_string> [ FROM <start_position> ] [ OCCURRENCE 
<regex_occurrence> ] [ GROUP <regex_capture_group> ] )
Syntax Elements
<pattern> ::= !!Perl Compatible Regular Expression
A search pattern based on Perl CompatibleRegular Expression (PCRE).
<flag> ::= 'i' | 'm' | 's' | 'x'
The matching behaviour of the function can be defined by the flag literal. The following options are available:
Table 52: Flag options
Flag option Description
i Enables case-insensitive matching
m Enables multiline mode, where the <subject_string> will be treated as multiple lines and the ex­
pression ^ and $ match just after or just before, respectively, a line terminator or the end of the input 
sequence
s Enables the expression <.> as a wildcard to match any character, including a line terminator
x Permits whitespace and comments in the pattern
<regex_subject_string> ::= <string>
This parameter defines the string the search pattern should be applied to. If <regex_subject_string> is 
empty, the result will be empty.
<start_position> ::= <numeric_literal>
If this parameter is set to a positive integer, it indicates the character of <regex_subject_string> where 
the search is started. If <start_position> is not a positive integer, NULL will be returned.
<regex_occurrence> ::= <numeric_literal >
240 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
If this parameter is set to a positive integer, it indicates the occurrence of the <pattern> in 
<regex_subject_string>. The default is 1 and will return the first occurence. If <regex_occurrence> is 
not a positive integer, then NULL will be returned.
<regex_capture_group> ::= <integer>
This parameter is a nonnegative integer and indicates the number of the captured substring's group by the 
regular expression. Default is 0. If <regex_capture_group> is a negative integer, then 0 will be returned.
Description
Searches a string for a regular expression pattern and returns one occurrence of the matching substring.
If any of the following parameters is NULL: <pattern>, <flag>, <regex_subject_string>, 
<start_position>, <regex_occurrence> or <regex_capture_group>, the function will return NULL.
Example
The following example returns the day 01 from the date value 20140401:
SELECT SUBSTR_REGEXPR('([[:digit:]]{4})([[:digit:]]{2})([[:digit:]]{2})' IN 
'20140401' GROUP 3) "substring_regexpr" FROM DUMMY;
2.8.1.155 SUBSTRING Function (String)
Returns a substring of a specified string starting from a specified position within the string.
Syntax
SUBSTRING (<str>, <start_position> [, <string_length>])
Description
Returns a substring of string <str> starting from <start_position> within the string. SUBSTRING can 
return the remaining part of a string from the <start_position> or optionally, a number of characters set by 
the <string_length> parameter.
● If <start_position> is less than 0, then it is considered to be 1.
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 241
● If <string_length> is less than 1, then an empty string is returned.
● If <string_length> is greater than the length of remaining part of <str>, then the remaining part is 
returned without blank padding.
Example
The following example selects two characters from the string 1234567890 starting at position 4, and returns 
the value 45:
SELECT SUBSTRING ('1234567890',4,2) "substring" FROM DUMMY;
2.8.1.156 SYSUUID Function (Miscellaneous)
Returns a new universally unique identifier that is generated by the connected SAP HANA instance.
Syntax
SYSUUID
Description
Returns a new universally unique identifier, generated by the connected SAP HANA instance. Each call of 
SYSUUID returns a new UUID value. SYSUUID calls from multiple connections are internally serialized to 
guarantee unique value generation.
Example
The following query returns the value 4DE3CD576C79511BE10000000A3C2220.
SELECT SYSUUID FROM DUMMY;
242 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
2.8.1.157 TAN Function (Numeric)
Returns the tangent of a specified number, where the argument is an angle expressed in radians.
Syntax
TAN (<n>)
Description
Returns the tangent of <n>, where <n> is an angle expressed in radians.
Example
The following example returns the value 0.0 for "tan":
SELECT TAN (0.0) "tan" FROM DUMMY;
2.8.1.158 TANH Function (Numeric)
Returns the hyperbolic tangent of the specified numeric argument.
Syntax
TANH (n)
Description
Returns the hyperbolic tangent of the numeric argument <n>.
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 243
Example
The following example returns the value 0.7615941559557649 for "tanh":
SELECT TANH (1.0) "tanh" FROM DUMMY;
2.8.1.159 TO_ALPHANUM Function (Data Type Conversion)
Converts a given value to an ALPHANUM data type.
Syntax
TO_ALPHANUM (<value>)
Description
Converts a given value to an ALPHANUM data type.
Example
The following example converts the value 10 to the ALPHANUM value 10.
SELECT TO_ALPHANUM ('10') "to alphanum" FROM DUMMY;
2.8.1.160 TO_BIGINT Function (Data Type Conversion)
Converts a value to a BIGINT data type.
Syntax
TO_BIGINT (<value>)
244 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
Description
Converts a value to a BIGINT data type.
If the input value has a mantissa, these digits are truncated during the conversion process.
Examples
The following example converts the value 10 to a BIGINT value 10:
SELECT TO_BIGINT ('10') "to bigint" FROM DUMMY;
The following example converts the value 10 to a BIGINT value 10, truncating the mantissa:
SELECT TO_BIGINT (10.5) "to bigint" FROM DUMMY;
2.8.1.161 TO_BINARY Function (Data Type Conversion)
Converts a value to a BINARY data type.
Syntax
TO_BINARY (<value>)
Description
Converts a value to a BINARY data type.
Example
The following example converts the value abc to the BINARY value 616263.
SELECT TO_BINARY ('abc') "to binary" FROM DUMMY;
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 245
2.8.1.162 TO_BLOB Function (Data Type Conversion)
Converts a binary string to a BLOB data type.
Syntax
TO_BLOB (<value>)
Description
Converts a value to a BLOB data type. <value> must be a binary string.
Example
The following example converts the value abcde to the BLOB value abcde:
SELECT TO_BLOB (TO_BINARY('abcde')) "to blob" FROM DUMMY;
2.8.1.163 TO_CLOB Function (Data Type Conversion)
Converts a value to a CLOB data type.
Syntax
TO_CLOB (<value>)
Description
Converts a value to a CLOB data type.
246 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
Example
The following example converts the value TO_CLOB converts the value to a CLOB data type, to the 
CLOB value TO_CLOB converts the value to a CLOB data type.
SELECT TO_CLOB ('TO_CLOB converts the value to a CLOB data type') "to clob" FROM 
DUMMY;
2.8.1.164 TO_DATE Function (Data Type Conversion)
Converts a date string into a DATE data type.
Syntax
TO_DATE (<d> [, <format>])
Description
Converts a date string <d> into a DATE data type. If the format specifier is omitted, the conversion is 
performed using the date format model.
Example
The following example converts the string 2010-01-12 to a DATE value with the format YYYY-MM-DD, and 
returns the value 2010-01-12.
SELECT TO_DATE('2010-01-12', 'YYYY-MM-DD') "to date" FROM DUMMY;
Related Information
Data Types [page 26]
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 247
2.8.1.165 TO_DATS Function (Data Type Conversion)
Converts a date string into an ABAP DATE string.
Syntax
TO_DATS (<d>)
Description
Converts a date string d into an ABAP DATE string with format 'YYYYMMDD'.
Example
The following example converts the value 2010-01-12 the ABAP DATE string20100112.
SELECT TO_DATS ('2010-01-12') "abap date" FROM DUMMY;
2.8.1.166 TO_DECIMAL Function (Data Type Conversion)
Converts a value to a DECIMAL data type.
Syntax
TO_DECIMAL (<value> [, <precision>, <scale>])
Description
Converts a value to a DECIMAL data type.
<precision> is the total number of significant digits and can range from 1 to 34.
<scale> is the number of digits from the decimal point to the least significant digit andcan range from -6,111 
to 6,176. This means that the scale specifies the range of the exponent in the decimal number from 10-6111 to 
248 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
106176. If the scale is not specified, it defaults to 0. Scale is positive when the number has significant digits to 
the right of the decimal point, and negative when the number has significant digits to the left of the decimal 
point.
<value> can be a variable; however, <precision> and <scale> must be a string constant.
When precision and scale are not specified, DECIMAL becomes a floating-point decimal number. In this case, 
precision and scale can vary within the range described above, 1~34 for precision and -6,111~6,176 for scale 
depending on the stored value.
Unrequired least significant digits in the mantissa of the input value are truncated during the conversion 
process.
Example
The following example converts the value 7654321.888888 to a DECIMAL data type with 10 digits precision 
and a scale of 3, and returns the value 7654321.888.
SELECT TO_DECIMAL(7654321.888888, 10, 3) "to decimal" FROM DUMMY;
2.8.1.167 TO_DOUBLE Function (Data Type Conversion)
Converts a value to a DOUBLE data type.
Syntax
TO_DOUBLE (<value>)
Description
Converts a specified value to a DOUBLE (double precision) data type.
Example
The following example multiplies the value 15.12 by 3 and converts the result to a DOUBLE, returning the 
value 45.36:
SELECT 3*TO_DOUBLE ('15.12') "to double" FROM DUMMY;
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 249
2.8.1.168 TO_FIXEDCHAR Function (Data Type Conversion)
Converts a specified number of characters of a string starting at the first character in the string.
Syntax
TO_FIXEDCHAR (<string>, <size>)
Description
Converts the specified string to a CHAR value of fixed size as specified by <size>, starting at the first 
character. <size> cannot be a variable.
Example
The following example converts the value Ant to a CHAR of length 2, and returns the value An.
SELECT TO_FIXEDCHAR ('Ant', 2) "to_fixedchar" FROM DUMMY;
2.8.1.169 TO_INT Function (Data Type Conversion)
Converts a value to an INT data type.
Syntax
TO_INT (<value>)
Description
Converts a value to an INT data type.
If the input value has a mantissa, the mantissa is truncated during the conversion process.
250 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
Examples
The following example converts the value 10 to the INT value 10:
SELECT TO_INT('10') "to int" FROM DUMMY;
The following example converts the value 10.5 to the INT value 10, truncating the mantissa.
SELECT TO_INT(10.5) "to int" FROM DUMMY;
2.8.1.170 TO_INTEGER Function (Data Type Conversion)
Converts the value to an INTEGER data type.
Syntax
TO_INTEGER (<value>)
Description
Converts the value to an INTEGER data type.
If the input value has a mantissa, these digits are truncated during the conversion process.
Examples
The following example converts the value 10 to the INTEGER value 10:
SELECT TO_INTEGER ('10') "to int" FROM DUMMY;
The following example converts the value 10.5 to the INTEGER value 10, truncating the mantissa:
SELECT TO_INTEGER(10.5) "to int" FROM DUMMY;
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 251
2.8.1.171 TO_NCLOB Function (Data Type Function)
Converts a value to a NCLOB data type.
Syntax
TO_NCLOB (<value>)
Description
Converts a value to a NCLOB data type.
Example
The following example converts the value TO_NCLOB converts the value to a NCLOB data type to 
the NCLOB value TO_NCLOB converts the value to a NCLOB data type.
SELECT TO_NCLOB ('TO_NCLOB converts the value to a NCLOB data type') "to nclob" 
FROM DUMMY;
2.8.1.172 TO_NVARCHAR Function (Data Type Conversion)
Converts the specified value to a NVARCHAR unicode character data type.
Syntax
TO_NVARCHAR (<value> [, <format>])
Description
Converts the value to a NVARCHAR unicode character data type.
If the format specifier is omitted, the conversion is performed using the date format model.
252 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
The following data types can be converted to NVARCHAR using the TO_NVARCHAR function:
● ALPHANUM, BIGINT, DATE, DECIMAL, DOUBLE, FIXED12, FIXED16, FIXED8, INTEGER, REAL, 
SECONDDATE, SMALLDECIMAL, SMALLINT, TIME, TIMESTAMP, TINYINT, VARBINARY, VARCHAR
● CLOB, NCLOB, TEXT (if the value is longer than maximum length of NVARCHAR, an exception will be 
thrown)
Example
The following example coverts the value 2009/12/31 to the NVARCHAR value 09-12-31.
SELECT TO_NVARCHAR(TO_DATE('2009/12/31'), 'YY-MM-DD') "to nvarchar" FROM DUMMY;
Related Information
Data Types [page 26]
2.8.1.173 TO_REAL Function (Data Type Conversion)
Converts a value to a REAL data type.
Syntax
TO_REAL (<value>)
Description
Converts a value to a REAL (single precision) data type.
Example
The following converts the value 15.12 to a REAL value, and multiplies it by 3 to return the value 
45.36000061035156.
SELECT 3*TO_REAL ('15.12') "to real" FROM DUMMY;
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 253
2.8.1.174 TO_SECONDDATE Function (Data Type 
Conversion)
Converts a date string d into a SECONDDATE data type.
Syntax
TO_SECONDDATE (<d> [, <format>])
Description
Converts a date string <d> into a SECONDDATE data type.
If the format specifier is omitted, the conversion is performed using the date format model.
Example
The following example converts the value 2010-01-11 13:30:00 to a SECONDDATE data type with format 
YYYY-MM-DD HH24:MI:SS and returns the value 2010-01-11 13:30:00.0.
SELECT TO_SECONDDATE ('2010-01-11 13:30:00', 'YYYY-MM-DD HH24:MI:SS') "to 
seconddate" FROM DUMMY;
Related Information
Data Types [page 26]
254 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
2.8.1.175 TO_SMALLDECIMAL Function (Data Type 
Conversion)
Converts the specified value to a SMALLDECIMAL data type.
Syntax
TO_SMALLDECIMAL (<value>)
Description
Converts the specified value to a SMALLDECIMAL data type.
Example
The following example converts the value 7654321.89 to the SMALLDECIMAL value 7654321.89
SELECT TO_SMALLDECIMAL(7654321.89) "to smalldecimal" FROM DUMMY;
2.8.1.176 TO_SMALLINT Function (Data Type Conversion)
Converts a value to a SMALLINT data type.
Syntax
TO_SMALLINT (<value>)
Description
Converts a value to a SMALLINT data type.
If the input value has a mantissa, these digits are truncated during the conversion process.
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 255
Examples
The following example converts the value 10 to a SMALLINT and returns the value 10:
SELECT TO_SMALLINT ('10') "to smallint" FROM DUMMY;
The following example converts the value 10 to a SMALLINT and returns the value 10, truncating the mantissa:
SELECT TO_SMALLINT(10.5) "to int" FROM DUMMY;
2.8.1.177 TO_TIME Function (Data Type Conversion)
Converts a time string into a TIME data type.
Syntax
TO_TIME (<t> [, <format>])
Description
Converts a time string <t> into the TIME data type.
If the format specifier is omitted, the conversion is performed using the time format model.
Example
The following example converts the value 08:30 AM to a TIME value with format HH:MI AM and returns the 
value 08:30:00.
SELECT TO_TIME ('08:30 AM', 'HH:MI AM') "to time" FROM DUMMY;
Related Information
Data Types [page 26]
256 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
2.8.1.178 TO_TIMESTAMP Function (Data Type Conversion)
Converts a date string into a TIMESTAMP data type.
Syntax
TO_TIMESTAMP (<d> [, <format>])
Description
Converts a date string d into the TIMESTAMP data type.
If the format specifier is omitted, the conversion is performed using the date format model.
Example
The following example converts the value 2010-01-11 13:30:00 to the TIMESTAMP value 2010-01-11 
13:30:00.0 using the format YYYY-MM-DD HH24:MI:SS.SELECT TO_TIMESTAMP ('2010-01-11 13:30:00', 'YYYY-MM-DD HH24:MI:SS') "to 
timestamp" FROM DUMMY;
Related Information
Data Types [page 26]
2.8.1.179 TO_TINYINT Function (Data Type Conversion)
Converts a value to a TINYINT data type.
Syntax
TO_TINYINT (<value>)
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 257
Description
Converts the value to a TINYINT data type.
If the input value has a mantissa, these digits are truncated during the conversion process.
Examples
The following example converts the value 10 to the TINYINT value 10.
SELECT TO_TINYINT ('10') "to tinyint" FROM DUMMY;
The following example converts the value 10.5 to the TINYINT value 10, truncating the mantissa.
SELECT TO_TINYINT(10.5) "to tinyint" FROM DUMMY;
2.8.1.180 TO_VARCHAR Function (Data Type Conversion)
Converts a given value to a VARCHAR character data type.
Syntax
TO_VARCHAR (<value> [, <format>])
Description
Converts a given value to a VARCHAR character data type.
If the format specifier is omitted, the conversion is performed using the date format model.
Example
The following example converts the value 2009-12-31 to a date value with format YYYY/MM/DD and then 
converts it again to a VARCHAR type, and returns the value 2009/12/31
SELECT TO_VARCHAR (TO_DATE('2009-12-31'), 'YYYY/MM/DD') "to char" FROM DUMMY;
258 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
Related Information
Data Types [page 26]
2.8.1.181 TRIM Function (String)
Returns a string after removing leading and trailing spaces.
Syntax
TRIM ([[LEADING | TRAILING | BOTH] <trim_char> FROM] <str> )
Description
Returns string <str> after removing leading and trailing spaces. The trimming operation is carried out either 
from the start (LEADING), end (TRAILING) or both (BOTH) ends of string str.
● If either <str> or <trim_char> are a null values, then a NULL is returned.
● If no options are specified, TRIM removes both the leading and trailing substring <trim_char> from string 
<str>.
● If <trim_char> is not specified, then a single blank space is used.
Example
The following example removes the character a both at the beginning and the end of the specified string and 
returns the value 123456789:
SELECT TRIM ('a' FROM 'aaa123456789aa') "trim both" FROM DUMMY;
The following example removes the character a at the begin of the specified string, and returns the value 
123456789aa:
SELECT TRIM (LEADING 'a' FROM 'aaa123456789aa') "trim leading" FROM DUMMY;
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 259
2.8.1.182 TRIM_ARRAY Function (Miscellaneous)
Removes the specified number of elements from the end of an array.
Syntax
TRIM_ARRAY (<array_value_expression>, <truncate_length>)
Description
Returns an array to be removed the given number of elements from the end of an array.
If <truncate_length> is less than or equal to 0, an exception is thrown.
Example
The following example demonstrates the removal of three elements from two arrays. The query returns 10.
CREATE COLUMN TABLE ARRAY_TEST (IDX INT, VAL INT ARRAY); INSERT INTO ARRAY_TEST VALUES (1, ARRAY(1, 2, 3));
INSERT INTO ARRAY_TEST VALUES (2, ARRAY(10, 20, 30, 40)); SELECT TRIM_ARRAY(VAL, 3) "trim_array" FROM ARRAY_TEST;
2.8.1.183 UCASE Function (String)
Converts all characters in the specified string to uppercase.
Syntax
UCASE (<str>)
Description
Converts all characters in string <str> to uppercase.
260 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
The UCASE function is identical to the UPPER function.
Example
This example converts the given string to uppercase, and returns the value ANT:
SELECT UCASE ('Ant') "ucase" FROM DUMMY;
2.8.1.184 UMINUS Function (Numeric)
Returns the negated value of the specified numeric argument.
Syntax
UMINUS (<n>)
Description
Returns the negated value of the numeric argument <n>.
Example
The following example returns the value 765 for "uminus":
SELECT UMINUS(-765) "uminus" FROM DUMMY;
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 261
2.8.1.185 UNICODE Function (String)
Returns an integer containing the Unicode code point of the first character in the specified string.
Syntax
UNICODE(<c>)
Description
Returns an integer containing the Unicode code point of the first character in the string <c>, or NULL if the first 
character is not a valid encoding.
Example
This example returns the Unicode code point for the given character (35):
SELECT UNICODE ('#') "unicode" FROM DUMMY;
2.8.1.186 UPPER Function (String)
Converts all characters in a string to uppercase.
Syntax
UPPER (<str>)
Description
Converts all characters in string <str> to uppercase.
The UPPER function is identical to the UCASE function.
262 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
Example
This example converts the given string Ant to uppercase and returns the value ANT:
SELECT UPPER ('Ant') "uppercase" FROM DUMMY;
2.8.1.187 UTCTOLOCAL Function (Datetime)
Converts the specified timestamp between UTC and local time.
Syntax
UTCTOLOCAL (<t>, <timezone> [, <timezone_dataset>])
Syntax Elements
<t> ::= <timestamp>
A timestamp parameter holding the time to be converted between UTC and local time.
<timezone> ::= <string_literal>
A string parameter holding the timezone defining the local time.
<timezone_dataset> ::= <string_literal>
A string parameter that specifies the dataset in which to search for the given timezone. Possible values of this 
parameter are:
● sap specifies to search in the currently used SAP dataset.
● platform specifies to search in the dataset provided by the operating system.
Description
Converts the UTC(GMT) time t to the local time in a timezone.
The usage of local timestamps is discouraged. It is a best practice to use UTC times instead. The use of local 
times or conversion between local time zones might require additional handling in application code.
SAP HANA SQL and System Views Reference
SQL Reference P U B L I C 263
Examples
The following example returns the value 2011-12-31 20:00:00.0 as the local time equivalent (in EST) of the 
specified UTC time:
SELECT UTCTOLOCAL (TO_TIMESTAMP('2012-01-01 01:00:00', 'YYYY-MM-DD 
HH24:MI:SS'), 'EST') "utctolocal" FROM DUMMY;
The following example returns the value 2011-12-31 20:00:00.0 as the local time equivalent (in EST) of the 
specified UTC time:
 SELECT UTCTOLOCAL (TO_TIMESTAMP('2012-01-01 01:00:00', 'YYYY-MM-DD 
HH24:MI:SS'), 'EST', 'sap') "utctolocal" FROM DUMMY;
2.8.1.188 VAR_POP Function (Aggregate)
Returns the population variance of an expression.
Syntax
VAR_POP(<expression>)
Description
Returns the population variance of the expression as the sum of squares of the difference of <expression> 
from the mean of <expression>, divided by the number of rows remaining.
Examples
The following example returns 0 as the population variance for the specified expression:
CREATE ROW TABLE RTABLE (A INT); INSERT INTO RTABLE VALUES (1); SELECT VAR_POP(A) "VARPOP" FROM RTABLE;
The following example returns 0.25 as the population variance for the specified expression:
INSERT INTO RTABLE VALUES (2); SELECT VAR_POP(A) "VARPOP" FROM RTABLE;
264 P U B L I C
SAP HANA SQL and System Views Reference
SQL Reference
2.8.1.189 VAR_SAMP Function (Aggregate)
Returns the sample variance of an expression.
Syntax
VAR_SAMP(<expression>)
Description
Returns the sample variance of the expression as the sum of squares of the difference of <expression> from 
the mean of <expression>, divided by the number of rows remaining minus 1 (one). This functions is similar 
to VAR, the only difference is that it returns NULL when the number of rows is 1.
Examples
The following example returns NULL as the sample variance of the specified expression:
CREATE ROW TABLE RTABLE (A INT); INSERT INTO RTABLE VALUES (1);SELECT VAR_SAMP(A) "VARSAMP" FROM RTABLE;
The following example returns 0.5 as the sample variance of the specified

Mais conteúdos dessa disciplina