SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

723
PUBLIC SAP HANA Platform SPS 06 Document Version: 1.1 - 17-07-2013 SAP HANA SQL and System Views References

description

SAP_HANA_SQL_and_System_Views_Reference

Transcript of SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Page 1: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

PUBLIC

SAP HANA Platform SPS 06Document Version: 1.1 - 17-07-2013

SAP HANA SQL and System Views References

Page 2: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Table of Contents1 SQL Reference Manual. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91.1 Notation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91.2 Introduction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111.3 Data Types. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141.4 Predicates. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30

1.4.1 Comparison Predicates. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 311.4.2 Range Predicate. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 321.4.3 In Predicate. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 331.4.4 Exists Predicate. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .331.4.5 LIKE Predicate. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 341.4.6 NULL Predicate. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 351.4.7 CONTAINS Predicate. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .36

1.5 Operators. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 381.6 Expressions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 421.7 SQL Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44

1.7.1 Data Type Conversion Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .441.7.2 DateTime Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .591.7.3 Fulltext Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 791.7.4 Number Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .831.7.5 String Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1011.7.6 Window Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1171.7.7 Miscellaneous Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121

1.8 SQL Statements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1321.8.1 Data Definition Statements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1321.8.2 Data Manipulation Statements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2161.8.3 System Management Statements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2481.8.4 Session Management Statements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2751.8.5 Transaction Management Statements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2821.8.6 Access Control Statements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2871.8.7 Data Import Export Statements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3251.8.8 Procedural Statements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 336

1.9 Restrictions for SQL Statements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3561.10 SQL Error Codes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 357

2 System Views Reference. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3762.1 Statistics Server Tables. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3822.2 AFL_AREAS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4432.3 AFL_FUNCTIONS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4432.4 AFL_FUNCTION_PROPERTIES. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 444

2P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesTable of Contents

Page 3: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

2.5 AFL_PACKAGES. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4452.6 AUDIT_POLICIES. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4452.7 AUTHORIZATION_GRAPH. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4462.8 CONSTRAINTS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4482.9 CREDENTIALS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4492.10 CS_BO_VIEWS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4502.11 CS_FREESTYLE_COLUMNS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4502.12 CS_JOIN_CONDITIONS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4502.13 CS_JOIN_CONSTRAINTS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4512.14 CS_JOIN_PATHS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4522.15 CS_JOIN_TABLES. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4532.16 CS_KEY_FIGURES. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4532.17 CS_VIEW_COLUMNS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4542.18 DATA_STATISTICS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4552.19 DATA_TYPES. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4572.20 EFFECTIVE_PRIVILEGES. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4592.21 EFFECTIVE_ROLES. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4602.22 EXPLAIN_PLAN_TABLE. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4612.23 FULLTEXT_INDEXES. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4652.24 FUNCTIONS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4672.25 FUNCTION_PARAMETERS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4672.26 GEOCODE_INDEXES. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4682.27 GRANTED_PRIVILEGES. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4692.28 GRANTED_ROLES. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4702.29 INDEXES. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4702.30 INDEX_COLUMNS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4712.31 INVALID_CONNECT_ATTEMPTS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4722.32 M_ATTACHED_STORAGES. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4732.33 M_BACKUP_CATALOG. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4732.34 M_BACKUP_CATALOG_FILES. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4742.35 M_BACKUP_CONFIGURATION. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4762.36 M_BLOCKED_TRANSACTIONS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4762.37 M_CACHES. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4772.38 M_CACHES_RESET. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4782.39 M_CACHE_ENTRIES. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4792.40 M_CATALOG_MEMORY. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4792.41 M_CE_CALCSCENARIOS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4802.42 M_CE_CALCVIEW_DEPENDENCIES. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4812.43 M_CE_DEBUG_INFOS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4812.44 M_CE_DEBUG_JSONS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4822.45 M_CE_DEBUG_NODE_MAPPING. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 483

SAP HANA SQL and System Views ReferencesTable of Contents

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 3

Page 4: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

2.46 M_CE_PLE_CALCSCENARIOS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4842.47 M_CLIENT_VERSIONS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4842.48 M_COMPACTION_THREAD. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4852.49 M_CONDITIONAL_VARIABLES. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4882.50 M_CONDITIONAL_VARIABLES_RESET. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4892.51 M_CONNECTIONS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4892.52 M_CONNECTION_STATISTICS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4922.53 M_CONTAINER_DIRECTORY. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4972.54 M_CONTAINER_NAME_DIRECTORY. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4982.55 M_CONTEXT_MEMORY. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4992.56 M_CONTEXT_MEMORY_RESET. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5012.57 M_CONVERTER_STATISTICS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5012.58 M_CONVERTER_STATISTICS_RESET. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5032.59 M_CS_ALL_COLUMNS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5042.60 M_CS_COLUMNS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5062.61 M_CS_PARTITIONS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5082.62 M_CS_TABLES. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5092.63 M_CS_UNLOADS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5132.64 M_DATABASE. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5132.65 M_DATABASE_HISTORY. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5142.66 M_DATA_VOLUMES. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5142.67 M_DATA_VOLUME_PAGE_STATISTICS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5152.68 M_DATA_VOLUME_PAGE_STATISTICS_RESET. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5162.69 M_DATA_VOLUME_SUPERBLOCK_STATISTICS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5172.70 M_DEBUG_CONNECTIONS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5172.71 M_DEBUG_SESSIONS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5182.72 M_DELTA_MERGE_STATISTICS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5192.73 M_DISKS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5212.74 M_ERROR_CODES. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5212.75 M_EVENTS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5222.76 M_EXPENSIVE_STATEMENTS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5232.77 M_EXPORT_BINARY_STATUS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5262.78 M_EXTRACTORS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5272.79 M_FEATURES. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5272.80 M_FULLTEXT_QUEUES. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5282.81 M_FUZZY_SEARCH_INDEXES. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5292.82 M_GARBAGE_COLLECTION_STATISTICS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5302.83 M_GARBAGE_COLLECTION_STATISTICS_RESET. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5322.84 M_HEAP_MEMORY. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5332.85 M_HEAP_MEMORY_RESET. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5352.86 M_HISTORY_INDEX_LAST_COMMIT_ID. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 535

4P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesTable of Contents

Page 5: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

2.87 M_HOST_INFORMATION. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5362.88 M_HOST_RESOURCE_UTILIZATION. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5392.89 M_IMPORT_BINARY_STATUS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5402.90 M_INIFILES. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5412.91 M_INIFILE_CONTENTS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5422.92 M_JOB_PROGRESS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5422.93 M_LANDSCAPE_HOST_CONFIGURATION. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5442.94 M_LICENSE. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5472.95 M_LICENSE_USAGE_HISTORY. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5482.96 M_LIVECACHE_CONTAINER_STATISTICS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5482.97 M_LIVECACHE_CONTAINER_STATISTICS_RESET. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5502.98 M_LIVECACHE_LOCKS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5502.99 M_LIVECACHE_LOCK_STATISTICS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5512.100 M_LIVECACHE_LOCK_STATISTICS_RESET. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5532.101 M_LIVECACHE_OMS_VERSIONS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5532.102 M_LIVECACHE_PROCEDURE_STATISTICS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5542.103 M_LIVECACHE_PROCEDURE_STATISTICS_RESET. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5632.104 M_LIVECACHE_SCHEMA_STATISTICS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5632.105 M_LIVECACHE_SCHEMA_STATISTICS_RESET. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5632.106 M_LOCK_WAITS_STATISTICS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5642.107 M_LOG_BUFFERS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5642.108 M_LOG_BUFFERS_RESET. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5662.109 M_LOG_PARTITIONS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5662.110 M_LOG_PARTITIONS_RESET. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5692.111 M_LOG_SEGMENTS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5702.112 M_LOG_SEGMENTS_RESET. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5712.113 M_MEMORY_OBJECTS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5712.114 M_MEMORY_OBJECTS_RESET. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5732.115 M_MEMORY_OBJECT_DISPOSITIONS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5732.116 M_MERGED_TRACES. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5752.117 M_MONITORS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5762.118 M_MONITOR_COLUMNS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5772.119 M_MUTEXES. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5782.120 M_MUTEXES_RESET. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5792.121 M_MVCC_TABLES. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5802.122 M_OBJECT_LOCKS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5802.123 M_OBJECT_LOCK_STATISTICS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5812.124 M_OBJECT_LOCK_STATISTICS_RESET. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5822.125 M_PAGEACCESS_STATISTICS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5822.126 M_PAGEACCESS_STATISTICS_RESET. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5832.127 M_PASSWORD_POLICY. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .583

SAP HANA SQL and System Views ReferencesTable of Contents

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 5

Page 6: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

2.128 M_PERFTRACE. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5852.129 M_PERSISTENCE_ENCRYPTION_KEYS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5862.130 M_PERSISTENCE_ENCRYPTION_STATUS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5862.131 M_PERSISTENCE_MANAGERS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5872.132 M_PERSISTENCE_MANAGERS_RESET. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5902.133 M_PLUGIN_MANIFESTS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5902.134 M_PREPARED_STATEMENTS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5902.135 M_READWRITELOCKS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5942.136 M_READWRITELOCKS_RESET. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5962.137 M_RECORD_LOCKS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5972.138 M_REMOTE_CONNECTIONS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5972.139 M_REMOTE_STATEMENTS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5982.140 M_REORG_ALGORITHMS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5992.141 M_REPO_TRANSPORT_FILES. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5992.142 M_RS_INDEXES. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6002.143 M_RS_MEMORY. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6022.144 M_RS_TABLES. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6032.145 M_RS_TABLE_VERSION_STATISTICS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6042.146 M_SAVEPOINTS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6062.147 M_SAVEPOINT_STATISTICS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6092.148 M_SAVEPOINT_STATISTICS_RESET. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6122.149 M_SEMAPHORES. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6122.150 M_SEMAPHORES_RESET. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6142.151 M_SEQUENCES. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6142.152 M_SERVICES. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6152.153 M_SERVICE_COMPONENT_MEMORY. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6162.154 M_SERVICE_MEMORY. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6172.155 M_SERVICE_NETWORK_IO. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6182.156 M_SERVICE_NETWORK_IO_RESET. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6192.157 M_SERVICE_REPLICATION. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6192.158 M_SERVICE_STATISTICS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6212.159 M_SERVICE_THREADS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6242.160 M_SERVICE_THREAD_CALLSTACKS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6252.161 M_SERVICE_TRACES. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6262.162 M_SERVICE_TYPES. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6262.163 M_SESSION_CONTEXT. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6272.164 M_SHARED_MEMORY. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6312.165 M_SNAPSHOTS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6322.166 M_SQL_PLAN_CACHE. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6332.167 M_SQL_PLAN_CACHE_OVERVIEW. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6382.168 M_SQL_PLAN_CACHE_RESET. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 640

6P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesTable of Contents

Page 7: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

2.169 M_SYSTEM_INFORMATION_STATEMENTS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6412.170 M_SYSTEM_LIMITS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6412.171 M_SYSTEM_OVERVIEW. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6422.172 M_TABLES. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6422.173 M_TABLE_LOB_FILES. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6432.174 M_TABLE_LOCATIONS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6442.175 M_TABLE_PERSISTENCE_LOCATIONS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6452.176 M_TABLE_PERSISTENCE_STATISTICS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6452.177 M_TABLE_VIRTUAL_FILES. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6462.178 M_TEMPORARY_OBJECT_DEPENDENCIES. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6472.179 M_TEMPORARY_TABLES. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6482.180 M_TEMPORARY_TABLE_COLUMNS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6502.181 M_TEMPORARY_VIEWS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6522.182 M_TEMPORARY_VIEW_COLUMNS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6532.183 M_TENANTS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6542.184 M_TEXT_ANALYSIS_LANGUAGES. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6552.185 M_TEXT_ANALYSIS_MIME_TYPES. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6552.186 M_TOPOLOGY_TREE. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6552.187 M_TRACEFILES. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6562.188 M_TRACEFILE_CONTENTS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6572.189 M_TRACE_CONFIGURATION. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6582.190 M_TRACE_CONFIGURATION_RESET. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6592.191 M_TRANSACTIONS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6592.192 M_UNDO_CLEANUP_FILES. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6622.193 M_VERSION_MEMORY. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6632.194 M_VOLUMES. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6642.195 M_VOLUME_FILES. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6652.196 M_VOLUME_IO_DETAILED_STATISTICS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6662.197 M_VOLUME_IO_DETAILED_STATISTICS_RESET. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6682.198 M_VOLUME_IO_PERFORMANCE_STATISTICS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6692.199 M_VOLUME_IO_PERFORMANCE_STATISTICS_RESET. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6762.200 M_VOLUME_IO_RETRY_STATISTICS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6772.201 M_VOLUME_IO_RETRY_STATISTICS_RESET. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6792.202 M_VOLUME_IO_STATISTICS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6792.203 M_VOLUME_IO_STATISTICS_RESET. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6832.204 M_VOLUME_IO_TOTAL_STATISTICS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6832.205 M_VOLUME_IO_TOTAL_STATISTICS_RESET. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6852.206 M_VOLUME_SIZES. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6852.207 M_WORKLOAD. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6862.208 M_XS_APPLICATIONS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6872.209 M_XS_APPLICATION_ISSUES. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 688

SAP HANA SQL and System Views ReferencesTable of Contents

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 7

Page 8: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

2.210 OBJECTS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 688

2.211 OBJECT_DEPENDENCIES. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 689

2.212 OWNERSHIP. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .689

2.213 PRIVILEGES. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 690

2.214 PROCEDURES. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 690

2.215 PROCEDURE_OBJECTS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 691

2.216 PROCEDURE_PARAMETERS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 692

2.217 QUERY_PLANS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 693

2.218 REFERENTIAL_CONSTRAINTS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .694

2.219 REMOTE_SOURCES. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 695

2.220 REORG_OVERVIEW. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 695

2.221 REORG_PLAN. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 696

2.222 REORG_PLAN_INFOS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 697

2.223 REORG_STEPS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 698

2.224 ROLES. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 699

2.225 SAML_PROVIDERS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 700

2.226 SAML_USER_MAPPINGS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 700

2.227 SCHEMAS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 701

2.228 SEARCH_RULE_SETS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 701

2.229 SEARCH_RULE_SET_CONDITIONS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .702

2.230 SEQUENCES. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 703

2.231 SESSION_COOKIES. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .704

2.232 SQLSCRIPT_TRACE. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 704

2.233 STATISTICS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 705

2.234 STRUCTURED_PRIVILEGES. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 706

2.235 SYNONYMS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 707

2.236 TABLES. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 708

2.237 TABLE_COLUMNS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 710

2.238 TABLE_COLUMNS_ODBC. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .712

2.239 TABLE_GROUPS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 714

2.240 TRANSACTION_HISTORY. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .714

2.241 TRIGGERS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 714

2.242 USERS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 715

2.243 USER_PARAMETERS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 717

2.244 VIEWS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 717

2.245 VIEW_COLUMNS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 718

2.246 VIRTUAL_COLUMNS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 720

2.247 VIRTUAL_TABLES. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 721

2.248 X509_USER_MAPPINGS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 722

8P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesTable of Contents

Page 9: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

1 SQL Reference Manual

● Notation● Introduction● Data Types● Predicates● Operators● Expressions● SQL Functions● SQL Statements● Restrictions for SQL Statements● SQL Error Codes

1.1 Notation

This reference use BNF (Backus Naur Form) which is 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

Symbol Description

< > Angle brackets are used to surround the name of a syntactic element (BNF nonterminal) of the SQL language.

::= The definition operator is used to provide definitions of the element appeared on the left side of the operator in a production rule.

[ ] Square brackets are used to indicate optional elements in a formula. Optional elements may be specified or omitted.

{ } Braces group elements in a formula. Repetitive elements (zero or more elements) can be specified within brace symbols.

| The alternative operator indicates that the portion of the formula following the bar is an alternative to the portion preceding the bar.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 9

Page 10: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Symbol Description

... The ellipsis indicates that the element may be repeated any number of times. If ellipsis appears after grouped elements specifying that the grouped elements enclosed with braces are repeated. If ellipsis appears after a single element, only that element is repeated.

!! Introduces normal English text. This is used when the definition of a syntactic element is not expressed in BNF.

BNF Lowest Terms Representations

Throughout the BNF used in this manual each syntax term will be 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 <underscore> ::= _

<hash_symbol> ::= #

<dollar_sign> ::= $

<any_character> !!= any character.

<single_quote> ::= '

<double_quotes> ::= " <identifier> ::= <simple_identifier> | <special_identifier>

<simple_identifier> ::= {<letter> | <underscore>} [{<letter> | <digit> | <underscore> | <hash_symbol> | <dollar_sign>}...]

<special_identifier> ::= <double_quotes><any_character><double_quotes>

<string_literal> ::= <single_quote><string_content><single_quote>

<string_content> = {<letter> | <digit>}...

<identifier> ::= <letter> {<letter> | <digit>}...

<password> ::= {<letter> | <digit>}...

<hostname> ::= {<letter> | <digit>}[{ <letter> | <digit> | <period> | - }...]

<port_number> ::= <unsigned_integer>

1

10P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 11: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

<sign> ::= + | -

<period> ::= .

<unsigned_integer> ::= <digit>...

<signed_integer> ::= [<sign>] <unsigned_integer>

<signed_numeric_literal> ::= [<sign>] <unsigned_numeric_literal>

<unsigned_numeric_literal> ::= <exact_numeric_literal> | <approximate_numeric_literal>

<exact_numeric_literal> ::= <unsigned_integer> [<period>[<unsigned_integer>]] | <period> <unsigned_integer>

<approximate_numeric_literal> ::= <mantissa>E<exponent>

<mantissa> ::= <exact_numeric_literal>

<exponent> ::= <signed_integer>

<numeric_literal> ::= <signed_numeric_literal | <signed_integer>

1.2 Introduction

● SQL● Supported Languages and Code Pages● Comment● Identifiers● SQL Reserved Words

This chapter describes the SAP HANA Database implementation of Structured Query Language (SQL). It explains the characteristics of SQL, also how to manage comments and reserve words.

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

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 11

Page 12: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

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.

Comment

You can add comments to improve readability and maintainability of your SQL statements. Comments are delimited in SQL statements as follows: <ul> <li> Double hyphens "--". Everything after the double hyphen until the end of a line is ignored by the SQL parser.</li> <li> "/*" 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.</li> </ul>

Identifiers

Syntax:

<identifier> ::= <simple_identifier> | <special_identifier>

<simple_identifier> ::= {<letter>|<underscore>} [{<letter> | <digit> | <underscore> | <hash_symbol> | <dollar_sign>}...]

<special_identifier> ::= <double_quotes><any_character><double_quotes>

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, then the identifier can contain any character including special characters. For example, "AB$%CD" is a valid identifier name.

● Limitations:

○ "_SYS_" is reserved exclusively for database engine, hence not allowed at the beginning of schema object names.

○ Role name and user name must be specified as undelimited identifiers.○ Maximum length for the identifiers is 127 characters.

Single Quotation Mark

Single quotation marks are used to delimit string literals and single quotation mark itself can be represented using two single quotation marks.

12P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 13: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Double Quotation Mark

Double quotation marks are used to delimit identifiers and double quotation mark itself can be represented using two double quotation marks.

SQL Reserved Words

Reserved words are words which have a special meaning to the SQL parser in the SAP HANA Database that cannot be used as a user-defined name. 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.

The following table lists all the current and future reserved words for the SAP HANA Database.

Table 1: Table 1. Reserved Words

ALL ALTER AS BEFORE

BEGIN BOTH CASE CHAR

CONDITION CONNECT CROSS CUBE

CURRENT_CONNECTION CURRENT_DATE CURRENT_SCHEMA CURRENT_TIME

CURRENT_TIMESTAMP CURRENT_USER CURRENT_UTCDATE CURRENT_UTCTIME

CURRENT_UTCTIMESTAMP

CURRVAL CURSOR DECLARE

DISTINCT ELSE ELSEIF ELSIF

END EXCEPT EXCEPTION EXEC

FOR FROM FULL GROUP

HAVING IF IN INNER

INOUT INTERSECT INTO IS

JOIN LEADING LEFT LIMIT

LOOP MINUS NATURAL NEXTVAL

NULL ON ORDER OUT

PRIOR RETURN RETURNS REVERSE

RIGHT ROLLUP ROWID SELECT

SET SQL START SYSDATE

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 13

Page 14: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

SYSTIME SYSTIMESTAMP SYSUUID TOP

TRAILING UNION USING UTCDATE

UTCTIME UTCTIMESTAMP VALUES WHEN

WHERE WHILE WITH

1.3 Data Types

This section describes the data types used in the SAP HANA Database.

Data type specifies the characteristics of a data value. A special value of NULL is included in every data type to indicate the absence of a value. The following table shows the built-in data types available in the SAP HANA Database.

● Classification of Data Types● Datetime Types

○ Date Formats○ Time Formats○ Timestamp Formats○ Additional Formats○ Supported Functions for Date/Time types

● Numeric Types● Character String Types● Binary Types● Large Object (LOB) Types● Mapping between SQL Data Type and Column Store Data Type● Data Type Conversion● Typed Constant

Classification of Data Types

In the SAP HANA Database each data type can be classified by its characteristic as follows:

Table 2: 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

14P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 15: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Classification Data Type

Character string types VARCHAR, NVARCHAR, ALPHANUM, SHORTTEXT

Binary types VARBINARY

Large Object types BLOB, CLOB, NCLOB, TEXT

Datetime Types

● DATEThe 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 date value is 0001-01-01 through 9999-12-31.

● TIMEThe 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.

● SECONDDATEThe 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 hour, MI represents minute, and SS represents seconds. The range of date value is 0001-01-01 00:00:01 through 9999-12-31 24:00:00.

● TIMESTAMPThe 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 timestamp value is 0001-01-01 00:00:00.0000000 through 9999-12-31 23:59:59.9999999.

For details on supported formats for datetime types, refer to Table 4, Table 5, Table 6 and Table 7 below.

Date Formats

The following date/time formats can be used when parsing a string into a date/time type and converting a date/time type value into a string value. Please note that format for Timestamp is the combination of Date and Time with the additional support for fractional seconds.

Table 3: Table 4: 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

INSERT INTO my_tbl VALUES ('1957-06-13');

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 15

Page 16: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Format Description Examples

than two digits, or day has less than two digits, then values will be padded by one or more zeros. For example, a two digit year 45 will be saved as year 0045, a one digit month 9 will be saved as 09, and a one digit day 2 will be 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');

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 - DECEMBER).

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

Table 4: Table 5: Supported formats for Time

Format Description Examples

HH24:MI:SS Default format

HH:MI[:SS][AM|PM]

HH12:MI[:SS][AM|PM]

HH from 0 to 23. MI from 0 to 59. SS from 0 to 59. FFF from 0 to 999.

INSERT INTO my_tbl VALUES ('23:59:59');

16P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 17: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Format Description Examples

HH24:MI[:SS] If one digit hour, minute, second is specified, then 0 will be inserted into the value. For example, 9:9:9 will be saved as 09:09:09.

HH12 indicates 12 hour clock and HH24 indicates 24 hour clock.

AM or PM can be specified as a suffix to indicate the time value is before or after noon.

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: Table 6: 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 second portion of the date time value returned. If a digit is not specified, the default 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: Table 7: Additional formats for Datetime

Format Description Example

D Day of week (1-7). TO_CHAR(CURRENT_TIMESTAMP,'D')

DAY Name of day (MONDAY - SUNDAY). TO_CHAR(CURRENT_TIMESTAMP,'DAY')

DY Abbreviated name of day (MON - SUN).

TO_CHAR(CURRENT_TIMESTAMP,'DY')

MON Abbreviated month name (JAN - DEC)

TO_CHAR(CURRENT_TIMESTAMP,'MON')

MONTH Full month name (JANUARY - DECEMBER)

TO_CHAR(CURRENT_TIMESTAMP,'MONTH')

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 17

Page 18: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Format Description Example

RM Roman numeral month (I - XII; I is for January)

TO_CHAR(CURRENT_TIMESTAMP,'RM')

Q Quarter of year (1, 2, 3, 4) TO_CHAR(CURRENT_TIMESTAMP,'Q')

W Week of month (1-5). TO_CHAR(CURRENT_TIMESTAMP,'W')

WW Week of year (1-53). TO_CHAR(CURRENT_TIMESTAMP,'WW')

Supported Functions for Date/Time types

● ADD_DAYS● ADD_MONTHS● ADD_SECONDS● ADD_YEARS● COALESCE● CURRENT_DATE● CURRENT_TIME● CURRENT_TIMESTAMP● CURRENT_UTCDATE● CURRENT_UTCTIME● CURRENT_UTCTIMESTAMP● DAYNAME● DAYOFMONTH● DAYOFYEAR● DAYS_BETWEEN● EXTRACT● GREATEST● GREATEST● HOUR● IFNULL● ISOWEEK● LAST_DAY● LEAST● LOCALTOUTC● MINUTE● MONTH● MONTHNAME● NEXT_DAY● NULLIF● QUARTER● SECOND

18P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 19: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

● SECONDS_BETWEEN● TO_DATE● TO_DATS● TO_TIME● TO_TIMESTAMP● UTCTOLOCAL● WEEK● WEEKDAY● YEAR

Numeric Types

● TINYINTThe TINYINT data type stores an 8-bit unsigned integer. The minimum value is 0 and the maximum value is 255 for TINYINT.

● SMALLINTThe SMALLINT data type stores a 16-bit signed integer. The minimum value is -32,768 and the maximum value is 32,767 for SMALLINT.

● INTEGERThe INTEGER data type stores a 32-bit signed integer. The minimum value is -2,147,483,648 and the maximum value is 2,147,483,647 for INTEGER.

● BIGINTThe BIGINT data type stores a 64-bit signed integer. The minimum value is -9,223,372,036,854,775,808 and the maximum value is 9,223,372,036,854,775,807 for BIGINT.

● 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. For example, if a column is defined as DECIMAL(5, 4), the numbers 3.14, 3.1415, 3.141592 are stored in the column as 3.1400, 3.1415, 3.1415, respectively keeping the specified precision(5) and scale(4).The precision p, can range from 1 to 34. The scale can range from 0 to p. If the scale is not specified, it defaults to 0.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 1 to 34 for precision and -6,111 to 6,176 for scale depending on the stored value.Examples: 0.0000001234 (1234 x 10-10) has the precision 4 and the scale 10. 1.0000001234 (10000001234 x 10-10) has the precision 11 and scale 10. 1234000000 (1234x106) has the precision 4 and scale -6.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.

● SMALLDECIMALThe 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 supported only 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 whilst maintaining their precision.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 19

Page 20: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

DECIMAL(p, s) is the SQL standard notation for fixed-point decimal. For instance, 3.14, 3.1415, 3.141592 are stored in a decimal(5, 4) column as 3.1400, 3.1415, 3.1415, respectively keeping the specified precision(5) and scale(4).

● REALThe REAL data type specifies a single-precision 32-bit floating-point number.

● DOUBLEThe DOUBLE data type specifies a single-precision 64-bit floating-point number. The minimum value is -1.79769 x 10308 and the maximum value is 1.79769x10308 . The smallest positive DOUBLE value is 2.2207x10-308 and the largest negative DOUBLE value is -2.2207x10-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.When you use the FLOAT(n) data type, if n is smaller than 25, it becomes a 32-bit REAL data type. If n is greater than or equal to 25, it then becomes a 64-bit DOUBLE data type. If n is not declared, it becomes a 64-bit double data type by default.

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.

● VARCHARThe VARCHAR(n) data type specifies a variable-length ASCII character string, where n indicates the maximum length and is an integer between 1 and 5000.

● NVARCHARThe NVARCHAR(n) data type specifies a variable-length Unicode character set string, where n indicates the maximum length and is an integer between 1 and 5000.

● ALPHANUMThe 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.

● SHORTTEXTThe SHORTTEXT(n) data type specifies veriable-length character string which supports textsearch-features and stringsearch-features. 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> ::= <elem_shorttext> [{, <elem_shorttext>}...]

<elem_shorttext> ::= <fulltext_elem> | SYNC[HRONOUS]

Binary Types

Binary types are used to store bytes of binary data.

● VARBINARY

20P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 21: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

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.

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 of an LOB is 2 GB.

● BLOBThe BLOB data type is used to store large binary data.

● CLOBThe CLOB data type is used to store large ASCII character data.

● NCLOBThe NCLOB data type is used to store a large Unicode character object.

● TEXTThe TEXT data type specifies which supports textsearch-features. This is not a standalone sql-type. Selecting a TEXT-column yields a column of type NCLOB.

<text_type> ::= TEXT <opt_fulltext_elem_list_text>

<opt_fulltext_elem_list_text> ::= <fulltext_elem_text> [{, <fulltext_elem_text>}...]

<fulltext_elem_text> ::= <fulltext_elem> | [SYNC[HRONOUS] | [ASYNC[HRONOUS] FLUSH [QUEUE] | EVERY <n> MINUTES [[OR] AFTER <m> DOCUMENTS] ]

Syntax-rules common to TEXT and SHORTTEXT

<fulltext_elem> ::= LANGUAGE COLUMN <column_name> | LANGUAGE DETECTION '(' <str_const_list> ')' | MIME TYPE COLUMN <column_name> | FUZZY SEARCH INDEX [ON|OFF] | PHRASE INDEX RATIO [ON|OFF] | CONFIGURATION <str_const> | SEARCH ONLY [ON|OFF] | FAST PREPROCESS [ON|OFF]

LOB types are provided for storing and retrieving such large data. LOB types support the following operations.

● The length() function returns the LOB length in bytes.● LIKE can be used to search LOB columns.

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 a join predicate.● LOB columns cannot appear in WHERE clauses as a predicate except LIKE, CONTAINS, =, or <>.● LOB columns cannot appear in SELECT clauses as an aggregate function argument.● 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 a primary key.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 21

Page 22: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

● LOB columns cannot be used in CREATE INDEX statements.● LOB columns cannot be used in statistics update statements.

Mapping between SQL Data Type and Column Store Data Type

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

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

22P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 23: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Data Type Conversion

This section describes the data type conversion allowed in SAP HANA Database.

● Explicit type conversion 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 conversionWhen 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. For instance, a comparison of BIGINT and VARCHAR is performed 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 to each other using TO_TIME(TIMESTAMP) and TO_TIMESTAMP(TIME).

● Examples

Table 7: 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.

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.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 23

Page 24: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Table 8: Table 9a: Data type conversion table

Target/

Source

tinyint smallint

integer bigint decimal

decimal(p,s)

smalldecimal

real double varchar

nvarchar

tinyint - OK OK OK OK OK OK OK OK OK OK

smallint

CHK - OK OK OK OK OK OK OK OK OK

integer CHK CHK - OK OK OK OK OK OK OK OK

bigint CHK CHK CHK - OK CHK CHK CHK OK OK OK

decimal

CHK CHK CHK CHK - CHK CHK CHK OK OK OK

decimal(p,s)

CHK CHK CHK CHK CHK CHK CHK CHK CHK CHK OK

smalldecimal

CHK CHK CHK CHK OK CHK - CHK CHK OK OK

real CHK CHK CHK CHK OK CHK CHK - OK OK OK

double CHK CHK CHK CHK CHK CHK CHK CHK - OK OK

varchar

CHK CHK CHK CHK CHK CHK CHK CHK CHK - OK

nvarchar

CHK CHK CHK CHK CHK CHK CHK CHK CHK CHK -

tinyint - OK OK OK OK OK OK OK OK OK OK

smallint

CHK - OK OK OK OK OK OK OK OK OK

integer CHK CHK - OK OK OK OK OK OK OK OK

bigint CHK CHK CHK - OK CHK CHK CHK OK OK OK

decimal

CHK CHK CHK CHK - CHK CHK CHK OK OK OK

decimal(p,s)

CHK CHK CHK CHK CHK CHK CHK CHK CHK CHK OK

smalldecimal

CHK CHK CHK CHK OK CHK - CHK CHK OK OK

24P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 25: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Target/

Source

tinyint smallint

integer bigint decimal

decimal(p,s)

smalldecimal

real double varchar

nvarchar

tinyint - OK OK OK OK OK OK OK OK OK OK

smallint

CHK - OK OK OK OK OK OK OK OK OK

integer CHK CHK - OK OK OK OK OK OK OK OK

bigint CHK CHK CHK - OK CHK CHK CHK OK OK OK

decimal

CHK CHK CHK CHK - CHK CHK CHK OK OK OK

decimal(p,s)

CHK CHK CHK CHK CHK CHK CHK CHK CHK CHK OK

smalldecimal

CHK CHK CHK CHK OK CHK - CHK CHK OK OK

real CHK CHK CHK CHK OK CHK CHK - OK OK OK

double CHK CHK CHK CHK CHK CHK CHK CHK - OK OK

varchar

CHK CHK CHK CHK CHK CHK CHK CHK CHK - OK

nvarchar

CHK CHK CHK CHK CHK CHK CHK CHK CHK CHK -

real CHK CHK CHK CHK OK CHK CHK - OK OK OK

double CHK CHK CHK CHK CHK CHK CHK CHK - OK OK

varchar CHK CHK CHK CHK CHK CHK CHK CHK CHK - OK

nvarchar

CHK CHK CHK CHK CHK CHK CHK CHK CHK CHK -

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 25

Page 26: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Table 9: Table 9b: 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 CHK -

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 CHK -

Table 10: Table 9c: Data type conversion table

Target/

Source

varbinary alphanum varchar nvarchar

varbinary - - - -

alphanum - - OK OK

varchar OK OK - OK

nvarchar OK OK CHK -

varbinary - - - -

alphanum - - OK OK

varchar OK OK - OK

nvarchar OK OK CHK -

Data Type Precedence

26P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 27: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

This section describes the data type precedence implemented by the SAP HANA Database. Data type precedence specifies that the data type with lower precedence is converted to the data type with higher precedence.

Highest TIMESTAMP

SECONDDATE

DATE

TIME

DOUBLE

REAL

DECIMAL

SMALLDECIMAL

BIGINT

INTEGER

SMALLINT

TINYINT

NCLOB

NVARCHAR

CLOB

VARCHAR

BLOB

Lowest VARBINARY

Highest TIMESTAMP

SECONDDATE

DATE

TIME

DOUBLE

REAL

DECIMAL

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 27

Page 28: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Highest TIMESTAMP

SECONDDATE

DATE

TIME

DOUBLE

REAL

DECIMAL

SMALLDECIMAL

BIGINT

INTEGER

SMALLINT

TINYINT

NCLOB

NVARCHAR

CLOB

VARCHAR

BLOB

Lowest VARBINARY

SMALLDECIMAL

BIGINT

INTEGER

SMALLINT

TINYINT

NCLOB

NVARCHAR

CLOB

VARCHAR

28P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 29: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Highest TIMESTAMP

SECONDDATE

DATE

TIME

DOUBLE

REAL

DECIMAL

SMALLDECIMAL

BIGINT

INTEGER

SMALLINT

TINYINT

NCLOB

NVARCHAR

CLOB

VARCHAR

BLOB

Lowest VARBINARY

BLOB

Lowest VARBINARY

Typed Constant

A constant is a symbol that represents a specific fixed data value.

● Character string contantA character string 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.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 29

Page 30: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

○ 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 constantA 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

● Binary string constantA 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 constantDate, 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

1.4 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.

30P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 31: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

● Comparison Predicates● Range Predicate● In Predicate● Exists Predicate● LIKE Predicate● NULL Predicate● CONTAINS Predicate

1.4.1 Comparison Predicates

Syntax

<comparison_predicate> ::= <expression> { = | != | <> | > | < | >= | <= } [ ANY | SOME | ALL ] { <expression_list> | <subquery> }

Syntax Elements

<expression_list> ::= <expression> [{, <expression>}...]

Expressions are either simple expression such as a character, a date or a number, or expression can also be a scalar subquery (see Expressions and Subquery).

ANY | SOME

Specifies that the comparison returns true if at least one value returned by the <subquery> or <expression_list> are true.

ALL

Specifies that the comparison returns true if the comparison of all values returned by the <subquery> or <expression_list> are true.

Description

Two values are compared using comparison predicates and the comparison returns true, false, or unknown.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 31

Page 32: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

1.4.2 Range Predicate

Syntax

<range_predicate> ::= <expression1> [NOT] BETWEEN <expression2> AND <expression3>

Syntax Elements

<expression1> ::= <expression> <expression2> ::= <expression> <expression3> ::= <expression>

Expressions are either simple expression such as a character, a date or a number, or expression can also be a scalar subquery (see Expressions and Subquery).

NOT

Inverts the operation of the BETWEEN predicate. Specifies that a true will be returned when <expression1> is not in the range of values specified between <expression2> and <expression3>.

Description

Compares a value with a list of values within the provided range.

The range predicate returns true if <expression1> is within the range specified by <expression2> and <expression3>.

NoteA true will only be returned if <expression2> has a value less than or equal to <expression3>.

32P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 33: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

1.4.3 In Predicate

Syntax

<in_predicate> ::= <expression1> [NOT] IN { <expression_list> | <subquery> }

Syntax Elements

<expression1> ::= <expression> <expression_list> ::= <expression> [{, <expression>}...]

Expressions are either simple expression such as a character, a date or a number, or expression can also be a scalar subquery (see Expressions and Subquery).

NOT

Inverts the operation of the IN predicate. Specifies that a true will be returned when <expression1> is not in the set of values specified by <expression_list> or the <subquery>.

Description

A value is compared with a specified set of values. A true will be returned if the value of <expression1> is found in the <expression_list> or <subquery>.

1.4.4 Exists Predicate

Syntax

<exists_predicate> ::= [NOT] EXISTS ( <subquery> )

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 33

Page 34: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Syntax Elements

NOT

Inverts the operation of the EXISTS predicate. Specifies that a true will be returned when the <subquery> returns an empty result set and false when the <subquery> returns a result set.

<subquery>

For information on subqueries, see Subquery

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.

1.4.5 LIKE Predicate

Syntax

<like_predicate> ::= <expression1> [NOT] LIKE <expression2> [ESCAPE <expression3>]

Syntax Elements

<expression1> ::= <expression> <expression2> ::= <expression> <expression3> ::= <expression>

Expressions are either simple expression such as a character, a date or a number, or expression can also be a scalar subquery (see Expressions and Subquery).

NOT

Inverts the operation of the LIKE predicate.

ESCAPE

Specifies an escape character to be used in the comparison string <expression2>. The escape character allows the underscore (_) or percentage sign (%) to be matched.

34P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 35: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Description

The LIKE predicate performs string comparisons. <expression1> is tested for a pattern contained in <expression2>. Wildcard characters ( % ) and ( _ ) can be used in the comparison string <expression2>. LIKE returns true if the pattern specified by expression2 is found.

The percentage sign (%) matches zero or more characters and underscore (_) matches exactly one character. To match a percent sign or underscore with the LIKE predicate, an escape character must be used.

Using ESCAPE <expression3>, you can specify the escape character that will be used allowing the underscore (_) or percentage sign (%) to be matched.

1.4.6 NULL Predicate

Syntax

<null_predicate> ::= <expression> IS [NOT] NULL

Syntax Elements

<expression>

Expressions are either simple expression such as a character, a date or a number, or expression can also be a scalar subquery (see Expressions and 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 ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 35

Page 36: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

1.4.7 CONTAINS Predicate

The CONTAINS predicate is used to search for text-matches to a search string in subqueries.

Syntax:

<contains_function> ::= CONTAINS '(' <contains_columns> ',' <search_string>')' | CONTAINS '(' <contains_columns> ',' <search_string> ',' <search_specifier> ')' <contains_columns> ::= '*' | <column_name> | '(' <columnlist> ')' <search_string> ::= <string_const> <search_specifier> ::= <search_type> <opt_search_specifier2_list> | <search_specifier2_list> <opt_search_specifier2_list> ::= empty | <search_specifier2_list> <search_type> ::= <exact_search> | <fuzzy_search> | <linguistic_search> <search_specifier2_list> ::= <search_specifier2> | <search_specifier2_list> ',' <search_specifier2> <search_specifier2> := <weights> | <language> <exact_search> ::= EXACT <fuzzy_search> ::= FUZZY | FUZZY '(' <float_const> ')' | FUZZY '(' <float_const> ',' <additional_params> ')' <linguistic_search> ::= LINGUISTIC <weights> ::= WEIGHT '(' <float_const_list> ')' <language> :: LANGUAGE '(' <string_const> ')' <additional_params> ::= <string_const>

search_string

The freestyle-search-string format is used (eg. Peter "Palo Alto" OR Berlin -"SAP LABS" )

search_specifier

If the search_specifier clause is not specified EXACT is taken as default

EXACT

EXACT returns true for those records where exact matches of the searchterms are found in the search-attributes

FUZZY

FUZZY returns true for those records where words similar to the searchterms are found in the search-attributes (e.g. spelling errors will be ignored to a certain extent)

float_const

36P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 37: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

If float_const is omitted, then 0.8 is the default. This default can be overridden by defining parameter FUZZINESSTHRESHOLD supported by columnstore join-views

WEIGHT

If a weights list is specified, it must be the same size as the number of (expanded) columns in <contains_columns>

LANGUAGE

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

LINGUISTIC returns true for those records where word-variants of the searchterms are found in the search-attributes (e.g. searching for 'cats' will also return records which contain 'cat')

Limitations: If there are multiple CONTAINS predicates specified in the where clause of a select statement, then only one of the predicates may consist of more than one column in the <contains_columns> list

The CONTAINS-predicate works only on column store tables (simple tables and join-views)

Examples:

Exact search

select * from T where contains(column1, 'dog OR cat') -- EXACT is implicit select * from T where contains(column1, 'dog OR cat', EXACT) select * from T where contains(column1, '"cats and dogs"') -- phrase search

Fuzzy search

select * from T where contains(column1, 'catz', FUZZY(0.8))

Linguistic search:

select * from T where contains(column1, 'catz', LINGUISTIC)

Freestyle search:

The freestyle-search is a search mulitple columns.

select * from T where CONTAINS( (column1,column2,column3), 'cats OR dogz', FUZZY(0.7)) select * from T where CONTAINS( (column1,column2,column3), 'cats OR dogz', FUZZY(0.7))

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 37

Page 38: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

1.5 Operators

● Unary and Binary Operators● Operator Precedence● Arithmetic Operators● String Operators● Comparsion Operators● Logical Operators● Set Operators

You can perform arithmetic operations in expressions by using operators. Operators can be used for calculation, value comparison or to assign values.

Unary and Binary Operators

Table 11: Table 10. 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 applies 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 several operators. If the number of operators is greater than one then the SAP HANA Database will evaluate them in order of operator precedence. You can change the order of evaluation by using parentheses, as expressions contained within parentheses are always evaluated first.

38P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 39: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

If parentheses are not used, the operators have the precedence indicated by the table below. Please note, the SAP HANA Database will evaluate operators with equal precedence from left to right within an expression.

Table 12: Table 11. SQL operator precedence

Precedence Operator Operation

Highest () parentheses

+, - unary positive and negative operation

*, / multiplication, division

+, - addition, subtraction

|| concatenation

=, !=, <, >, <=, >=, IS NULL, LIKE, BETWEEN

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 13: Table 12. 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 result 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 expression is 0, an error is returned.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 39

Page 40: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

String Operators

A concatenation operator combines two items such as strings, expressions or constants into one.

Table 14: Table 13. 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 kept. 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 15: Table 14. 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;

40P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 41: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Logical Operators

Search conditions can be combined using AND or OR operators. You can also negate them using the NOT operator.

Table 16: Table 15. Logical operators

Operator Syntax Description

AND WHERE condition1 AND condition2 When using AND, the combined condition 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 condition 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

The operators described in this section perform set operations on the results of two or more queries.

Table 17: Table 16. Set operators

Operator Returned Value

UNION Combines the results of two or more select statements or query expressions

UNION ALL Combines the results of two or more select statements or query expressions, including all duplicate rows.

INTERSECT Combines the results of two or more select statements or query expressions, and returns all common rows.

EXCEPT Takes output from the first query and then removes rows selected by the second query.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 41

Page 42: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

1.6 Expressions

● Case Expressions● Function Expressions● Aggregate Expressions● Subqueries in Expressions

An expression is a clause that can be evaluated to return values.

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>

For more information on predicates, see Predicates.

42P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 43: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

If the expression following the CASE statement is equal to the expression following the WHEN statement, then 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 an expression.

Syntax

<function_expression> ::= <function_name> ( <expression> [{, <expression>}...] )

Aggregate Expressions

An aggregate expression uses an aggregate function to calculate a single value from the values of multiple rows in a column.

Syntax

<aggregate_expression> ::= COUNT(*) | <agg_name> ( [ ALL | DISTINCT ] <expression> ) <agg_name> ::= COUNT | MIN | MAX | SUM | AVG | STDDEV | VAR

Aggregate name Description

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.

MIN Returns the minimum value of expression.

MAX Returns the maximum value of expression.

SUM Returns the sum of expression.

AVG Returns the arithmetical mean of expression.

STDDEV Returns the standard deviation of given expression as the square root of VARIANCE function.

VAR Returns the variance of expression as the square of standard deviation.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 43

Page 44: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Subqueries in Expressions

A subquery is a SELECT statement enclosed in parentheses. The SELECT statement can contain one and only one select list item. When used as an expression a scalar subquery is allowed to return only zero or one value.

Syntax

<scalar_subquery_expression> ::= (<subquery>)

Within the SELECT list of the top level SELECT, or in the SET clause of an UPDATE statement, you can use a scalar subquery anywhere that you can use a column name. However, scalar_subquery cannot be used inside GROUP BY clause.

Example:

For example, the following statement returns the number of employees in each department, 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;

1.7 SQL Functions

Introduction

This chapter describes SQL Functions that are provided by SAP HANA Database.

● Data Type Conversion Functions● DateTime Functions● Fulltext Functions● Number Functions● String Functions● Window Functions● Miscellaneous Functions

1.7.1 Data Type Conversion Functions

Data type conversion functions are used to convert arguments from one data type to another, or to test whether a conversion is possible.

44P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 45: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

● CAST● TO_ALPHANUM● TO_BIGINT● TO_BINARY● TO_BLOB● TO_CLOB● TO_DATE● TO_DATS● TO_DECIMAL● TO_DOUBLE● TO_FIXEDCHAR● TO_INT● TO_INTEGER● TO_NCLOB● TO_NVARCHAR● TO_REAL● TO_SECONDDATE● TO_SMALLDECIMAL● TO_SMALLINT● TO_TIME● TO_TIMESTAMP● TO_TINYINT● TO_VARCHAR

1.7.1.1 CAST

Syntax

CAST (expression AS data_type)

Syntax Elements

expression - The expression to be converted. data type - The target data type. TINYINT | SMALLINT | INTEGER | BIGINT | DECIMAL | SMALLDECIMAL | REAL | DOUBLE | ALPHANUM | VARCHAR | NVARCHAR | DAYDATE | DATE | TIME | SECONDDATE | TIMESTAMP

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 45

Page 46: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Description

Returns the value of an expression converted to a supplied data type.

Example

SELECT CAST (7 AS VARCHAR) "cast" FROM DUMMY; cast 7

1.7.1.2 TO_ALPHANUM

Syntax

TO_ALPHANUM (value)

Description

Converts a given value to an ALPHANUM data type.

Example

SELECT TO_ALPHANUM ('10') "to alphanum" FROM DUMMY; to alphanum 10

46P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 47: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

1.7.1.3 TO_BIGINT

Syntax

TO_BIGINT (value)

Description

Converts a value to a BIGINT data type.

Example

SELECT TO_BIGINT ('10') "to bigint" FROM DUMMY; to bigint 10

1.7.1.4 TO_BINARY

Syntax

TO_BINARY (value)

Description

Converts a value to a BINARY data type.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 47

Page 48: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Example

SELECT TO_BINARY ('abc') "to binary" FROM DUMMY; to binary 616263

1.7.1.5 TO_BLOB

Syntax

TO_BLOB (value)

Description

Converts a value to a BLOB data type. The argument value must be a binary string.

Example

SELECT TO_BLOB (TO_BINARY('abcde')) "to blob" FROM DUMMY; to blob abcde

1.7.1.6 TO_CLOB

Syntax

TO_CLOB (value)

48P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 49: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Description

Converts a value to a CLOB data type.

Example

SELECT TO_CLOB ('TO_CLOB converts the value to a CLOB data type') "to clob" FROM DUMMY; to clob TO_CLOB converts the value to a CLOB data type

1.7.1.7 TO_DATE

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 as explained in Date Formats.

Example

SELECT TO_DATE('2010-01-12', 'YYYY-MM-DD') "to date" FROM DUMMY; to date 2010-01-12

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 49

Page 50: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

1.7.1.8 TO_DATS

Syntax

TO_DATS (d)

Description

Converts a date string d into an ABAP DATE string with format 'YYYYMMDD'.

Example

SELECT TO_DATS ('2010-01-12') "abap date" FROM DUMMY; abap date 20100112

1.7.1.9 TO_DECIMAL

Syntax

TO_DECIMAL (value [, precision, scale])

Description

Converts the value to a DECIMAL data type.

The precision is the total number of significant digits and can range from 1 to 34.

The scale is the number of digits from the decimal point to the least significant digit and can 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 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.

50P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 51: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

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.

Example

SELECT TO_DECIMAL(7654321.888888, 10, 3) "to decimal" FROM DUMMY

to decimal 7654321.889

1.7.1.10 TO_DOUBLE

Syntax

TO_DOUBLE (value)

Description

Converts a value to a DOUBLE (double precision) data type.

Example

SELECT 3*TO_DOUBLE ('15.12') "to double" FROM DUMMY; to double 45.36

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 51

Page 52: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

1.7.1.11 TO_FIXEDCHAR

Syntax

TO_FIXEDCHAR (str, n)

Description

Returns the first n characters of str

Example

SELECT TO_FIXEDCHAR ('Ant', 2) "to_fixedchar" FROM DUMMY; to_fixedchar An

1.7.1.12 TO_INT

Syntax

TO_INT (value)

Description

Converts the value to an INTEGER data type.

52P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 53: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Example

SELECT TO_INT('10') "to int" FROM DUMMY; to int 10

1.7.1.13 TO_INTEGER

Syntax

TO_INTEGER (value)

Description

Converts the value to an INTEGER data type.

Example

SELECT TO_INTEGER ('10') "to int" FROM DUMMY; to int 10

1.7.1.14 TO_NCLOB

Syntax

TO_NCLOB (value)

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 53

Page 54: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Description

Converts a value to a NCLOB data type.

Example

SELECT TO_NCLOB ('TO_NCLOB converts the value to a NCLOB data type') "to nclob" FROM DUMMY;

to nclob TO_NCLOB converts the value to a NCLOB data type

1.7.1.15 TO_NVARCHAR

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 as explained in Date Formats.

Example

SELECT TO_NVARCHAR(TO_DATE('2009/12/31'), 'YY-MM-DD') "to nchar" FROM DUMMY; to nchar 09-12-31

54P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 55: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

1.7.1.16 TO_REAL

Syntax

TO_REAL (value)

Description

Converts a value to a REAL (single precision) data type.

Example

SELECT 3*TO_REAL ('15.12') "to real" FROM DUMMY; to real 45.36000061035156

1.7.1.17 TO_SECONDDATE

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 as explained in Date Formats.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 55

Page 56: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Example

SELECT TO_SECONDDATE ('2010-01-11 13:30:00', 'YYYY-MM-DD HH24:MI:SS') "to seconddate" FROM DUMMY; to seconddate 2010-01-11 13:30:00.0

1.7.1.18 TO_SMALLDECIMAL

Syntax

TO_SMALLDECIMAL (value)

Description

Converts the value to a SMALLDECIMAL data type.

Example

SELECT TO_SMALLDECIMAL(7654321.89) "to smalldecimal" FROM DUMMY;

to smalldecimal 7654321.89

1.7.1.19 TO_SMALLINT

Syntax

TO_SMALLINT (value)

56P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 57: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Description

Converts the value to a SMALLINT data type.

Example

SELECT TO_SMALLINT ('10') "to smallint" FROM DUMMY; to smallint 10

1.7.1.20 TO_TIME

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 as explained in Time Formats.

Example

SELECT TO_TIME ('08:30 AM', 'HH:MI AM') "to time" FROM DUMMY; to time 08:30:00

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 57

Page 58: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

1.7.1.21 TO_TIMESTAMP

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 as explained in Date Formats.

Example

SELECT TO_TIMESTAMP ('2010-01-11 13:30:00', 'YYYY-MM-DD HH24:MI:SS') "to timestamp" FROM DUMMY; to timestamp 2010-01-11 13:30:00.0

1.7.1.22 TO_TINYINT

Syntax

TO_TINYINT (value)

Description

Converts the value to a TINYINT data type.

58P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 59: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Example

SELECT TO_TINYINT ('10') "to tinyint" FROM DUMMY; to tinyint 10

1.7.1.23 TO_VARCHAR

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 as explained in Date Formats.

Example

SELECT TO_VARCHAR (TO_DATE('2009-12-31'), 'YYYY/MM/DD') "to char" FROM DUMMY; to char 2009/12/31

1.7.2 DateTime Functions

● ADD_DAYS● ADD_MONTHS● ADD_SECONDS● ADD_YEARS● CURRENT_DATE● CURRENT_TIME● CURRENT_TIMESTAMP

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 59

Page 60: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

● CURRENT_UTCDATE● CURRENT_UTCTIME● CURRENT_UTCTIMESTAMP● DAYNAME● DAYOFMONTH● DAYOFYEAR● DAYS_BETWEEN● EXTRACT● HOUR● ISOWEEK● LAST_DAY● LOCALTOUTC● MINUTE● MONTH● MONTHNAME● NANO100_BETWEEN● NEXT_DAY● NOW● QUARTER● SECOND● SECONDS_BETWEEN● UTCTOLOCAL● WEEK● WEEKDAY● YEAR

1.7.2.1 ADD_DAYS

Syntax

ADD_DAYS (d, n)

Description

Computes the date d plus n days.

60P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 61: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Example

SELECT ADD_DAYS (TO_DATE ('2009-12-05', 'YYYY-MM-DD'), 30) "add days" FROM DUMMY; add days 2010-01-04

1.7.2.2 ADD_MONTHS

Syntax

ADD_MONTHS (d, n)

Description

Computes the date d plus n months.

Example

SELECT ADD_MONTHS (TO_DATE ('2009-12-05', 'YYYY-MM-DD'), 1) "add months" FROM DUMMY; add months 2010-01-05

1.7.2.3 ADD_SECONDS

Syntax

ADD_SECONDS (t, n)

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 61

Page 62: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Description

Computes the time t plus n seconds.

Example

SELECT ADD_SECONDS (TO_TIMESTAMP ('2012-01-01 23:30:45'), 60*30) "add seconds" FROM DUMMY; add seconds 2012-01-02 00:00:45.0

1.7.2.4 ADD_YEARS

Syntax

ADD_YEARS (d, n)

Description

Computes the date d plus n years.

Example

SELECT ADD_YEARS (TO_DATE ('2009-12-05', 'YYYY-MM-DD'), 1) "add years" FROM DUMMY; add years 2010-12-05

62P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 63: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

1.7.2.5 CURRENT_DATE

Syntax

CURRENT_DATE

Description

Returns the current local system date.

Example

SELECT CURRENT_DATE "current date" FROM DUMMY; current date 2010-01-11

1.7.2.6 CURRENT_TIME

Syntax

CURRENT_TIME

Description

Returns the current local system time.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 63

Page 64: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Example

SELECT CURRENT_TIME "current time" FROM DUMMY; current time 17:37:37

1.7.2.7 CURRENT_TIMESTAMP

Syntax

CURRENT_TIMESTAMP

Description

Returns the current local system timestamp information.

Example

SELECT CURRENT_TIMESTAMP "current timestamp" FROM DUMMY; current timestamp 2010-01-11 17:38:48.802

1.7.2.8 CURRENT_UTCDATE

Syntax

CURRENT_UTCDATE

64P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 65: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Description

Returns the current UTC date. The UTC stands for Coordinated Universal Time, also known as Greenwich Mean Time (GMT).

Example

SELECT CURRENT_UTCDATE "Coordinated Universal Date" FROM DUMMY; Coordinated Universal Time 2010-01-11

1.7.2.9 CURRENT_UTCTIME

Syntax

CURRENT_UTCTIME

Description

Returns the current UTC time.

Example

SELECT CURRENT_UTCTIME "Coordinated Universal Time" FROM DUMMY; Coordinated Universal Time 08:41:19

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 65

Page 66: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

1.7.2.10 CURRENT_UTCTIMESTAMP

Syntax

CURRENT_UTCTIMESTAMP

Description

Returns the current UTC timestamp.

Example

SELECT CURRENT_UTCTIMESTAMP "Coordinated Universal Timestamp" FROM DUMMY; Coordinated Universal Timestamp 2010-01-11 08:41:42.484

1.7.2.11 DAYNAME

Syntax

DAYNAME (d)

Description

Returns the weekday in English for date d.

66P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 67: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Example

SELECT DAYNAME ('2011-05-30') "dayname" FROM DUMMY; dayname MONDAY

1.7.2.12 DAYOFMONTH

Syntax

DAYOFMONTH (d)

Description

Returns an integer the day of the month for date d.

Example

SELECT DAYOFMONTH ('2011-05-30') "dayofmonth" FROM DUMMY; dayofmonth 30

1.7.2.13 DAYOFYEAR

Syntax

DAYOFYEAR (d)

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 67

Page 68: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Description

Returns an integer representation of the day of the year for date d.

Example

SELECT DAYOFYEAR ('2011-05-30') "dayofyear" FROM DUMMY; dayofyear 150

1.7.2.14 DAYS_BETWEEN

Syntax

DAYS_BETWEEN (d1, d2)

Description

Computes the number of days between d1 and d2.

Example

SELECT DAYS_BETWEEN (TO_DATE ('2009-12-05', 'YYYY-MM-DD'), TO_DATE('2010-01-05', 'YYYY-MM-DD')) "days between" FROM DUMMY; days between 31

68P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 69: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

1.7.2.15 EXTRACT

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

SELECT EXTRACT (YEAR FROM TO_DATE ('2010-01-04', 'YYYY-MM-DD')) "extract" FROM DUMMY; extract 2010

1.7.2.16 HOUR

Syntax

HOUR (t)

Description

Returns an integer representation of the hour for time t.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 69

Page 70: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Example

SELECT HOUR ('12:34:56') "hour" FROM DUMMY; hour 12

1.7.2.17 ISOWEEK

Syntax

ISOWEEK (d)

Description

Returns the ISO year and week numbers of date d. The week number is prefixed by the letter W.

Please also see WEEK

Example

SELECT ISOWEEK (TO_DATE('2011-05-30', 'YYYY-MM-DD')) "isoweek" FROM DUMMY; isoweek 2011-W22

1.7.2.18 LAST_DAY

Syntax

LAST_DAY (d)

70P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 71: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Description

Returns the date of the last day of the month that contains the date d.

Example

SELECT LAST_DAY (TO_DATE('2010-01-04', 'YYYY-MM-DD')) "last day" FROM DUMMY; last day 2010-01-31

1.7.2.19 LOCALTOUTC

Syntax

LOCALTOUTC (t, timezone)

Description

Convert the local time t from a timezone to the UTC(GMT) time

Example

SELECT LOCALTOUTC (TO_TIMESTAMP('2012-01-01 01:00:00', 'YYYY-MM-DD HH24:MI:SS'), 'EST') "localtoutc" FROM DUMMY; localtoutc 2012-01-01 06:00:00.0

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 71

Page 72: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

1.7.2.20 MINUTE

Syntax

MINUTE (t)

Description

Returns an integer representation of the minute for time t.

Example

SELECT MINUTE ('12:34:56') "minute" FROM DUMMY; minute 34

1.7.2.21 MONTH

Syntax

MONTH(d)

Description

Returns the number of the month from date d.

72P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 73: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Example

SELECT MONTH ('2011-05-30') "month" FROM DUMMY; month 5

1.7.2.22 MONTHNAME

Syntax

MONTHNAME(d)

Description

Returns the name of the month in English for date d.

Example

SELECT MONTHNAME ('2011-05-30') "monthname" FROM DUMMY; monthname MAY

1.7.2.23 NANO100_BETWEEN

Syntax

NANO100_BETWEEN (d1, d2)

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 73

Page 74: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Description

Computes the time difference between date arguments d1 and d2, to the precision of 0.1 microseconds.

Example

SELECT NANO100_BETWEEN ('2013-01-30', '2013-01-31') "nano100 between" FROM DUMMY; nano100 between 864000000000

1.7.2.24 NEXT_DAY

Syntax

NEXT_DAY (d)

Description

Returns the date of the next day after date d.

Example

SELECT NEXT_DAY (TO_DATE ('2009-12-31', 'YYYY-MM-DD')) "next day" FROM DUMMY; next day 2010-01-01

74P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 75: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

1.7.2.25 NOW

Syntax

NOW ()

Description

Returns the current timestamp.

Example

SELECT NOW () "now" FROM DUMMY; now 2010-01-01 16:34:19.894

1.7.2.26 QUARTER

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 ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 75

Page 76: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Example

SELECT QUARTER (TO_DATE('2012-01-01', 'YYYY-MM-DD'), 2) "quarter" FROM DUMMY; quarter 2011-Q4

1.7.2.27 SECOND

Syntax

SECOND (t)

Description

Returns an integer representation of the second for time t.

Example

SELECT SECOND ('12:34:56') "second" FROM DUMMY; second 56

1.7.2.28 SECONDS_BETWEEN

Syntax

SECONDS_BETWEEN (d1, d2)

76P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 77: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Description

Computes the number of seconds between date arguments d1 and d2, which is semantically equal to d2 - d1.

Example

SELECT SECONDS_BETWEEN ('2009-12-05', '2010-01-05') "seconds between" FROM DUMMY; Seconds between 2678400

1.7.2.29 UTCTOLOCAL

Syntax

UTCTOLOCAL (t, timezone)

Description

Convert the UTC(GMT) time t to the local time in a timezone

Example

SELECT UTCTOLOCAL (TO_TIMESTAMP('2012-01-01 01:00:00', 'YYYY-MM-DD HH24:MI:SS'), 'EST') "utctolocal" FROM DUMMY; utctolocal 2011-12-31 20:00:00.0

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 77

Page 78: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

1.7.2.30 WEEK

Syntax

WEEK (d)

Description

Returns the week number of date d.

Please also see ISOWEEK

Example

SELECT WEEK (TO_DATE('2011-05-30', 'YYYY-MM-DD')) "week" FROM DUMMY; week 23

1.7.2.31 WEEKDAY

Syntax

WEEKDAY (d)

Description

Returns an integer representation of the day of the week for date d. The return value ranges from 0 to 6, representing Monday(0) through to Sunday(6).

78P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 79: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Example

SELECT WEEKDAY (TO_DATE ('2010-12-31', 'YYYY-MM-DD')) "week day" FROM DUMMY; week day 4

1.7.2.32 YEAR

Syntax

YEAR (d)

Description

Returns the year number of date d.

Example

SELECT YEAR (TO_DATE ('2011-05-30', 'YYYY-MM-DD')) "year" FROM DUMMY; year 2011

1.7.3 Fulltext Functions

● LANGUAGE● MIMETYPE● SCORE

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 79

Page 80: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

1.7.3.1 LANGUAGE

Syntax

LANGUAGE (<column_name>)

Syntax Elements

<column_name> ::= <identifier>

The column where the language detection is to occur.

Description

The function LANGUAGE returns the language of the corresponding column entries. Prerequisite is an existing fulltext index for the specified column.

Example

You 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('Dies ist ein ganz kurzes Beispiel.');

You select the content and detect the language of the entries.

SELECT LANGUAGE(CONTENT),CONTENT FROM T;

Result:

en;This is a very short example. de;Dies ist ein ganz kurzes Beispiel.

80P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 81: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

1.7.3.2 MIMETYPE

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

You 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>');

You select the content and detect the MIME type of the entries.

SELECT MIMETYPE(CONTENT),CONTENT FROM T;

Result:

text/plain;This is an example text/html;<html>This is an example</html>

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 81

Page 82: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

1.7.3.3 SCORE

Syntax

SELECT SCORE(),* FROM <table_name> WHERE CONTAINS (<search_term>)

Syntax Elements

<table_name> ::= <identifier>

The table where the text searching is to occur.

CONTAINS (<search_term>)

For more information on the CONTAINS predicate, see CONTAINS Predicate.

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. 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 that occurs, the higher the score is.● Text ranking (TF-IDF)

Examples

Example 1

You create a table that contains two differing 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.');

You 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);

82P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 83: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Result:

1;This is a test. 0.625;This was a test.

Example 2

You create a table that contains two differing strings.

CREATE COLUMN TABLE T (CONTENT TEXT FAST PREPROCESS OFF); INSERT INTO T VALUES('example'); INSERT INTO T VALUES('exomple');

You 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));

Result:

1;example 0.8799999952316284;exomple

1.7.4 Number Functions

Number functions take numeric values, or strings with numeric characters, as inputs and return numeric values. When strings with numeric characters are provided as inputs implicit conversion from a string to a number is performed automatically before results are computed.

● ABS● ACOS● ASIN● ATAN● ATAN2● BINTOHEX● BITAND● CEIL● COS● COSH● COT● EXP● FLOOR● HEXTOBIN● LN● LOG● MOD● POWER● RAND● ROUND

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 83

Page 84: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

● SIGN● SIN● SINH● SQRT● TAN● TANH● UMINUS

1.7.4.1 ABS

Syntax

ABS (n)

Description

Returns the absolute value of the numeric argument n.

Example

SELECT ABS (-1) "absolute" FROM DUMMY; absolute 1

1.7.4.2 ACOS

Syntax

ACOS (n)

84P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 85: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Description

Returns the arc-cosine, in radians, of the numeric argument n between -1 and 1.

Example

SELECT ACOS (0.5) "acos" FROM DUMMY; acos 1.0471975511965979

1.7.4.3 ASIN

Syntax

ASIN (n)

Description

Returns the arc-sine, in radians, of the numeric argument n between -1 and 1.

Example

SELECT ASIN (0.5) "asin" FROM DUMMY; asin 0.5235987755982989

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 85

Page 86: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

1.7.4.4 ATAN

Syntax

ATAN (n)

Description

Returns the arc-tangent, in radians, of the numeric argument n. The range of n is unlimited.

Example

SELECT ATAN (0.5) "atan" FROM DUMMY; atan 0.4636476090008061

1.7.4.5 ATAN2

Syntax

ATAN2 (n, m)

Description

Returns the arc-tangent, in radians, of the ratio of two numbers n and m. This produces the same result as ATAN(n/m).

86P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 87: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Example

SELECT ATAN2 (1.0, 2.0) "atan2" FROM DUMMY; atan2 0.4636476090008061

1.7.4.6 BINTOHEX

Syntax

BINTOHEX (expression)

Description

Converts a binary value to a hexadecimal value.

Example

SELECT BINTOHEX('AB') "bintohex" FROM DUMMY; bintohex 4142

1.7.4.7 BITAND

Syntax

BITAND (n, m)

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 87

Page 88: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Description

Performs an AND operation on the bits of the arguments n and m. Both n and m must be non-negative integers. The BITAND function returns a result with BIGINT type.

Example

SELECT BITAND (255, 123) "bitand" FROM DUMMY; bitand 123

1.7.4.8 CEIL

Syntax

CEIL (n)

Description

Returns the first integer that is greater or equal to the value n.

Example

SELECT CEIL (14.5) "ceiling" FROM DUMMY; ceiling 15

88P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 89: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

1.7.4.9 COS

Syntax

COS (n)

Description

Returns the cosine of the angle, in radians, of the argument n.

Example

SELECT COS (0.0) "cos" FROM DUMMY; cos 1.0

1.7.4.10 COSH

Syntax

COSH (n)

Description

Computes the hyperbolic cosine of the argument n.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 89

Page 90: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Example

SELECT COSH (0.5) "cosh" FROM DUMMY; cosh 1.1276259652063807

1.7.4.11 COT

Syntax

COT (n)

Description

Computes the cotangent of a number n, where the argument is an angle expressed in radians.

Example

SELECT COT (40) "cot" FROM DUMMY; cot -0.8950829176379128

1.7.4.12 EXP

Syntax

EXP (n)

90P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 91: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Description

Returns the result of the base of natural logarithms e raised to the power of the argument n.

Example

SELECT EXP (1.0) "exp" FROM DUMMY; exp 2.718281828459045

1.7.4.13 FLOOR

Syntax

FLOOR (n)

Description

Returns the largest integer not greater than the numeric argument n.

Example

SELECT FLOOR (14.5) "floor" FROM DUMMY; floor 14

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 91

Page 92: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

1.7.4.14 HEXTOBIN

Syntax

HEXTOBIN (value)

Description

Converts a hexadecimal value to a binary value.

Example

SELECT HEXTOBIN ('1a') "hextobin" FROM DUMMY; hextobin 1A

1.7.4.15 LN

Syntax

LN (n)

Description

Returns the natural logarithm of the argument n.

92P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 93: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Example

SELECT LN (9) "ln" FROM DUMMY; ln 2.1972245773362196

1.7.4.16 LOG

Syntax

LOG (b, n)

Description

Returns the natural logarithm of a number n base b. Base b must be a positive value greater than 1 and n must be any positive value.

Example

SELECT LOG (10, 2) "log" FROM DUMMY; log 0.30102999566398114

1.7.4.17 MOD

Syntax

MOD (n, d)

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 93

Page 94: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

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.

● 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 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

SELECT MOD (15, 4) "modulus" FROM DUMMY; modulus 3

SELECT MOD (-15, 4) "modulus" FROM DUMMY; modulus -3

1.7.4.18 POWER

Syntax

POWER (b, e)

Description

Calculates the base number b raised to the power of an exponent e.

94P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 95: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Example

SELECT POWER (2, 10) "power" FROM DUMMY; power 1024.0

1.7.4.19 RAND

Syntax

DOUBLE RAND()

Description

Returns a pseudo-random value in the range of [0, 1.0). Its return value type is DOUBLE.

Example

SELECT RAND() FROM DUMMY; RAND 3.907985046680551e-14

1.7.4.20 ROUND

Syntax

ROUND (n [, pos]) ROUND (n, pos [, rounding_mode])

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 95

Page 96: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Description

Rounds argument n to the specified pos amount of places after the decimal point.

The rounding_mode defines how the rounding should be carried out. The options for this parameter are as follows:

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).

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 rounded to 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.

NoteWhen 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 will be influenced by the precision of the type used. For example:

select ROUND(TO_REAL(399.71429443359375),2) from DUMMY;

The actual result of this statement will be 399.7099914550781 and not 399.71.

96P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 97: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Examples

SELECT ROUND (16.16, 1) "round" FROM DUMMY; round 16.2

SELECT ROUND (16.16, -1) "round" FROM DUMMY; round 20

SELECT ROUND( 438.75, 1, ROUND_HALF_UP) "round" FROM DUMMY;

round 438.8

SELECT ROUND( 438.75, 1, ROUND_HALF_DOWN) "round" FROM DUMMY;

round 438.7

SELECT ROUND( 438.75, 1, ROUND_HALF_EVEN) "round" FROM DUMMY;

round 438.8

SELECT ROUND( 438.71, 1, ROUND_UP) "round" FROM DUMMY;

round 438.8

SELECT ROUND( 438.79, 1, ROUND_DOWN) "round" FROM DUMMY;

round 438.7

SELECT ROUND( 438.75, 1, ROUND_CEILING) "round" FROM DUMMY;

round 438.8

SELECT ROUND( 438.75, 1, ROUND_FLOOR) "round" FROM DUMMY;

round 438.7

1.7.4.21 SIGN

Syntax

SIGN (n)

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 97

Page 98: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

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, and 0 if n is equal to zero.

Example

SELECT SIGN (-15) "sign" FROM DUMMY; sign -1

1.7.4.22 SIN

Syntax

SIN (n)

Description

Returns the sine of n, where the argument is an angle expressed in radians.

Example

SELECT SIN ( 3.141592653589793/2) "sine" FROM DUMMY; sine 1.0

98P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 99: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

1.7.4.23 SINH

Syntax

SINH (n)

Description

Returns the hyperbolic sine of n, where the argument is an angle expressed in radians.

Example

SELECT SINH (0.0) "sinh" FROM DUMMY; sinh 0.0

1.7.4.24 SQRT

Syntax

SQRT (n)

Description

Returns the square root of the argument n.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 99

Page 100: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Example

SELECT SQRT (2) "sqrt" FROM DUMMY; sqrt 1.4142135623730951

1.7.4.25 TAN

Syntax

TAN (n)

Description

Returns the tangent of n, where the argument is an angle expressed in radians.

Example

SELECT TAN (0.0) "tan" FROM DUMMY; tan 0.0

1.7.4.26 TANH

Syntax

TANH (n)

100P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 101: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Description

Returns the hyperbolic tangent of the numeric argument n.

Example

SELECT TANH (1.0) "tanh" FROM DUMMY; tanh 0.7615941559557649

1.7.4.27 UMINUS

Syntax

UMINUS (n)

Description

Returns the negated value of the numeric argument n.

Example

SELECT UMINUS(-765) "uminus" FROM DUMMY;

uminus 765

1.7.5 String Functions

● ASCII● CHAR

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 101

Page 102: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

● CONCAT● LCASE● LEFT● LENGTH● LOCATE● LOWER● LPAD● LTRIM● NCHAR● REPLACE● RIGHT● RPAD● RTRIM● SUBSTR_AFTER● SUBSTR_BEFORE● SUBSTRING● TRIM● UCASE● UNICODE● UPPER

1.7.5.1 ASCII

Syntax

ASCII(c)

Description

Returns the integer ASCII value of the first byte in a string c.

Example

SELECT ASCII('Ant') "ascii" FROM DUMMY; ascii 65

102P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 103: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

1.7.5.2 CHAR

Syntax

CHAR (n)

Description

Returns the character with the ASCII value of a number n.

Example

SELECT CHAR (65) || CHAR (110) || CHAR (116) "character" FROM DUMMY; character Ant

1.7.5.3 CONCAT

Syntax

CONCAT (str1, str2)

Description

Returns a combined string consisting of str1 followed by str2. The concatenation operator (||) is identical to this function.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 103

Page 104: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Example

SELECT CONCAT ('C', 'at') "concat" FROM DUMMY; concat Cat

1.7.5.4 LCASE

Syntax

LCASE(str)

Description

Converts all characters in string str to lowercase.

NoteThe LCASE function is identical to the LOWER function.

Example

SELECT LCASE ('TesT') "lcase" FROM DUMMY; lcase test

104P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 105: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

1.7.5.5 LEFT

Syntax

LEFT (str, n)

Description

Returns the first n characters/bytes from the beginning of string str.

Example

SELECT LEFT ('Hello', 3) "left" FROM DUMMY; left Hel

1.7.5.6 LENGTH

Syntax

LENGTH(str)

Description

Returns the number of characters in string str.

NoteSupplementary plane Unicode characters, each of which occupies 6 bytes in CESU-8 encoding, are counted as two characters.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 105

Page 106: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Example

SELECT LENGTH ('length in char') "length" FROM DUMMY; length 14

1.7.5.7 LOCATE

Syntax

LOCATE (haystack, needle)

Description

Returns the position of a substring needle within a string haystack. Returns 0 if needle is not found within haystack. Returns NULL if haystack or needle is NULL, or if haystack is an empty string.

Example

SELECT LOCATE ('length in char', 'char') "locate" FROM DUMMY; Locate 11

SELECT LOCATE ('length in char', 'length') "locate" FROM DUMMY; Locate 1

SELECT LOCATE ('length in char', 'zchar') "locate" FROM DUMMY; Locate 0

106P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 107: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

1.7.5.8 LOWER

Syntax

LOWER(str)

Description

Converts all characters in string str to lowercase.

NoteThe LOWER function is identical to the LCASE function.

Example

SELECT LOWER ('AnT') "lower" FROM DUMMY; lower ant

1.7.5.9 LPAD

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.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 107

Page 108: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Example

SELECT LPAD ('end', 15, '12345') "lpad" FROM DUMMY; lpad 123451234512end

1.7.5.10 LTRIM

Syntax

LTRIM (str [, remove_set])

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 not the in remove_set is reached.

Noteremove_set is treated as a set of characters and not as a search string.

Example

SELECT LTRIM ('babababAabend','ab') "ltrim" FROM DUMMY; ltrim Aabend

108P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 109: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

1.7.5.11 NCHAR

Syntax

NCHAR (n)

Description

Returns the Unicode character with the integer code number n.

Example

SELECT NCHAR (65) "nchar" FROM DUMMY; nchar A

1.7.5.12 REPLACE

Syntax

REPLACE (original_string, search_string, replace_string)

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.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 109

Page 110: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

● If original_string, search_string, or replace_string are NULL then NULL is returned.

Example

SELECT REPLACE ('DOWNGRADE DOWNWARD','DOWN', 'UP') "replace" FROM DUMMY; replace UPGRADE UPWARD

1.7.5.13 RIGHT

Syntax

RIGHT(str, n)

Description

Returns the rightmost n characters/bytes of string str.

Example

SELECT RIGHT('HI0123456789', 3) "right" FROM DUMMY; right 789

110P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 111: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

1.7.5.14 RPAD

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 string str will be padded using sequences of these characters until the required length is met.

Example

SELECT RPAD ('end', 15, '12345') "right padded" FROM DUMMY; right padded end123451234512

1.7.5.15 RTRIM

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 is reached.

Note

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 111

Page 112: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

remove_set is treated as a set of characters and not as a search string.

Example

SELECT RTRIM ('endabAabbabab','ab') "rtrim" FROM DUMMY; rtrim endabA

1.7.5.16 SUBSTR_AFTER

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.

Example

SELECT SUBSTR_AFTER ('Hello My Friend','My ') "substr after" FROM DUMMY; substr after Friend

112P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 113: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

1.7.5.17 SUBSTR_BEFORE

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

SELECT SUBSTR_BEFORE ('Hello My Friend','My') "substr before" FROM DUMMY; substr before Hello

1.7.5.18 SUBSTRING

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.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 113

Page 114: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

● If start_position is less than 0, then it is considered as 1.● If string_length is less than 1, then an empty string is returned.

Example

SELECT SUBSTRING ('1234567890',4,2) "substring" FROM DUMMY; substring 45

1.7.5.19 TRIM

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

SELECT TRIM ('a' FROM 'aaa123456789aa') "trim both" FROM DUMMY; trim both 123456789 SELECT TRIM (LEADING 'a' FROM 'aaa123456789aa') "trim leading" FROM DUMMY; trim leading 123456789aa

114P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 115: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

1.7.5.20 UCASE

Syntax

UCASE (str)

Description

Converts all characters in string str to uppercase.

NoteThe UCASE function is identical to the UPPER function.

Example

SELECT UCASE ('Ant') "ucase" FROM DUMMY; ucase ANT

1.7.5.21 UNICODE

Syntax

UNICODE(c)

Description

Returns an integer containing the Unicode code point of the first character in the string, or NULL if the first character is not a valid encoding.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 115

Page 116: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Example

SELECT UNICODE ('#') "unicode" FROM DUMMY; unicode 35

1.7.5.22 UPPER

Syntax

UPPER (str)

Description

Converts all characters in string str to uppercase.

NoteThe UPPER function is identical to the UCASE function.

Example

SELECT UPPER ('Ant') "uppercase" FROM DUMMY; uppercase ANT

116P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 117: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

1.7.6 Window Functions

Syntax

<window_fuction> ::= <window_function_type> OVER ( [ PARTITION BY <expression>[{, <expression>}...] <window_order_by_clause>[{, <window_order_by_clause>}...] ) <window_function_type> ::= RANK() | DENSE_RANK() | ROW_NUMBER() | PERCENT_RANK() | CUME_DIST() | <ntile_function> | <lead_lag_function> | <first_last_value_function> | <nth_value_function> | <window_aggregate_function> <ntile_function> ::= NTILE( <number_of_buckets> ) <lead_lag_function> ::= { LEAD | LAG } ( <expression> [, <offset> [, <default_expression>]] ) <first_last_value_function> ::= { FIRST_VALUE | LAST_VALUE } ( <expression> ) <nth_value_function> ::= NTH_VALUE ( <expression> , <n> ) <window_aggregate_function> ::= COUNT(*) | <agg_name> ( <expression> ) <agg_name> ::= COUNT | MIN | MAX | SUM | AVG | STDDEV | VAR <window_order_by_clause> ::= ORDER BY {<window_order_by_expression>} <window_order_by_expression> ::= <expression> [ASC | DESC] [NULLS FIRST | NULLS LAST ]

Description

The window function let users divide result sets of a query (or a logical partition of a query) into groups of rows called window partition.

A window partition is specified by one or more expressions in the OVER clause.

Window functions other than aggregation functions must have ORDER BY clause in the OVER clause.

Result sets are first partitioned as specified by PARTITION BY clause, and then sorted by ORDER BY clause specification within the window partition.

Finally window functions are applied to each row within window partition boundaries.

Note that ORDER BY clause in OVER clause is only used to evaluate window function so that the order of resulting rows is non-deterministic if not specified by ORDER BY for SELECT.

The default window frame of the window function depends on whether or not a window orderby clause is specified.

If window orderby clause is specified, the default window frame becomes 'between UNBOUNDED PRECEDING and CURRENT ROW', that is, the window function computes on rows preceding or peer with current row.

As a result, the function returns cumulative values.

If window orderby clause is not specified, the default window frame becomes 'between UNBOUNDED PRECEDING and UNBOUNDED FOLLOWING', that is the window function computes on the whole window partition.

As a result, the function returns the same value within a window partition regardless of current row.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 117

Page 118: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

RANK()

Returns rank of a row within a partition, starting from 1. Returns duplicate values in the ranking sequence when there are ties between values.

DENSE_RANK()

Returns ranking values without gaps.

ROW_NUMBER()

Returns unique row number within a partition.

The output of ROW_NUMBER function can be non-deterministic among tie values.

PERCENT_RANK()

Returns relative rank of a row.

The relative rank of a row R is defined as (RANK()-1)/(NR-1), where NR is defined to be the number of rows in the window partition of R.

CUME_DIST()

Returns relative rank of a row.

The relative rank of a row R is defined as NP/NR, where NP is defined to be the number of rows preceding or peer with R inthe window ordering of the window partition of R and NR is defined to be the number of rows in the window ordering of the window.

LEAD ( <expression> [, <offset> [, <default_expression>]] )

Returns value of the 'offset' rows after current row. The 'offset' should be non-negative and default is 1.

If the offset crosses boundaries of the partition 'default' value is returned. If the 'default' is not specified null value is returned.

The 'offset' and 'default' are evaluated at current row.

The output of LEAD function can be non-deterministic among tie values.

LAG ( <expression> [, <offset> [, <default_expression>]] )

Returns value of the 'offset' rows before current row. The 'offset' should be non-negative and default is 1.

If the offset crosses boundaries of the partition 'default' value is returned. If the 'default' is not specified null value is returned.

The 'offset' and 'default' are evaluated at current row.

The output of LAG function can be non-deterministic among tie values.

NTILE( <number_of_buckets> )

Distributes rows into a specified 'number of buckets' and assigns the bucket number starting from 1 to each row in the bucket.

The output of NTILE function can be non-deterministic among tie values.

FIRST_VALUE ( <expression> )

Returns the value of 'expression' evaluated at the first row of the window frame.

118P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 119: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

The output of FIRST_VALUE function can be non-deterministic among tie values.

LAST_VALUE ( <expression> )

Returns the value of 'expression' evaluated at the last row of the window frame.

The output of LAST_VALUE function can be non-deterministic among tie values.

NTH_VALUE ( <expression> , <n> )

Returns the value of 'expression' evaluated at the 'n'-th row from the first row of the window frame.

The output of NTH_VALUE function can be non-deterministic among tie values.

Window Aggregate Function

See Aggregate Expressions for aggregate functions. Window aggregation does not support DISTINCT.

Example

Here is an example table T.

create table T (class char(10), val int, offset int); insert into T values('A', 1, 1); insert into T values('A', 3, 3); insert into T values('A', 5, null); insert into T values('A', 5, 2); insert into T values('A', 10, 0); insert into T values('B', 1, 3); insert into T values('B', 1, 1); insert into T values('B', 7, 1);

Example : Ranking functions

select class, val, ROW_NUMBER() over (partition by class order by val) as row_num, RANK() over (partition by class order by val) as rank, DENSE_RANK() over (partition by class order by val) as dense_rank from T;

The example result of the query is shown below. Note that the result of ROW_NUMBER can be non-deterministic.

class val row_num rank dense_rank

A 1 1 1 1

A 3 2 2 2

A 5 3 3 3

A 5 4 3 3

A 10 5 5 4

B 1 1 1 1

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 119

Page 120: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

B 1 2 1 1

B 7 3 3 2

Example : LEAD/LAG functions

select class, val, offset, LEAD(val) over (partition by class order by val) as lead, LEAD(val,offset,-val) over (partition by class order by val) as lead2, LAG(val) over (partition by class order by val) as lag, LAG(val,offset,-val) over (partition by class order by val) as lag2 from T;

The example result of the query is shown below. Note that the result of LEAD/LAG can be non-deterministic.

class val offset lead lead2 lag lag2

A 1 1 3 3 null -1

A 3 3 5 10 1 -3

A 5 null 5 -5 3 -5

A 5 2 10 -5 5 3

A 10 0 null 10 5 10

B 1 3 1 -1 null -1

B 1 1 7 7 1 1

B 7 1 null -7 1 1

Example : NTILE/FIRST_VALUE/LAST_VALUE/NTH_VALUE functions

select class, val, NTILE(3) over (partition by class order by val) as nt, FIRST_VALUE(val) over (partition by class order by val) as first, LAST_VALUE(val) over (partition by class order by val) as last, NTH_VALUE(val, 4) over (partition by class order by val) as nth from T;

The example result of the query is shown below. Note that the result of NTILE/FIRST_VALUE/LAST_VALUE/NTH_VALUE can be non-deterministic.

class val nt first last nth

A 1 1 1 1 null

A 3 1 1 3 null

A 5 2 1 5 5

A 5 2 1 5 5

120P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 121: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

A 10 3 1 10 5

B 1 1 1 1 null

B 1 2 1 1 null

B 7 3 1 7 null

Example : Aggregate functions

select class, val, offset, COUNT(*) over (partition by class) as c1, COUNT(offset) over (partition by class) as c2, COUNT(*) over (partition by class order by val) as c3, COUNT(offset) over (partition by class order by val) as c4, MAX(val) over (partition by class) as m1, MAX(val) over (partition by class order by val) as m2 from T;

The result of the query is shown below.

class val offset C1 C2 C3 C4 M1 M2

A 1 1 5 4 1 1 10 1

A 3 3 5 4 2 2 10 3

A 5 null 5 4 4 3 10 5

A 5 2 5 4 4 3 10 5

A 10 0 5 4 5 4 10 10

B 1 3 3 3 2 2 7 1

B 1 1 3 3 2 2 7 1

B 7 1 3 3 3 3 7 7

1.7.7 Miscellaneous Functions

● COALESCE● CURRENT_CONNECTION● CURRENT_SCHEMA● CURRENT_USER● GREATEST● GROUPING_ID● IFNULL● LEAST

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 121

Page 122: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

● MAP● NULLIF● SESSION_CONTEXT● SESSION_USER● SYSUUID

1.7.7.1 COALESCE

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 will be NULL if all the arguments are NULL.

Example

CREATE TABLE coalesce_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;

ID A B coalesce

1 100.0 80.0 100.0

2 NULL 63.0 69.30000305175781

3 NULL NULL 50.0

122P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 123: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

1.7.7.2 CURRENT_CONNECTION

Syntax

CURRENT_CONNECTION

Description

Returns the id of the current connection.

Example

SELECT CURRENT_CONNECTION "current connection" FROM DUMMY; current connection 2

1.7.7.3 CURRENT_SCHEMA

Syntax

CURRENT_SCHEMA

Description

Returns a string containing the current schema name.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 123

Page 124: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Example

SELECT CURRENT_SCHEMA "current schema" FROM DUMMY; current schema SYSTEM

1.7.7.4 CURRENT_USER

Syntax

CURRENT_USER

Description

Returns the current user name at the current statement context. This will be user name which 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;

124P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 125: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

-- USER_B is executing USER_A.PROC CALL USER_A.PROC2;

current user USER_B

1.7.7.5 GREATEST

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

1.7.7.6 GROUPING_ID

Syntax

GROUPING_ID(column_name_list)

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 125

Page 126: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Description

GROUPING_ID function can be used with GROUPING SETS to 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 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

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

126P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 127: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

1.7.7.7 IFNULL

Syntax

IFNULL (expression1, expression2)

Description

Returns the first not NULL input expression.

● Returns expression1 if expression1 is not NULL.● Returns expression2 if expression1 is NULL.● Returns NULL if both input expressions are NULL.

Example

SELECT IFNULL ('diff', 'same') "ifnull" FROM DUMMY; ifnull diff

SELECT IFNULL (NULL, 'same') "ifnull" FROM DUMMY; ifnull same

SELECT IFNULL (NULL, NULL) "ifnull" FROM DUMMY; ifnull NULL

1.7.7.8 LEAST

Syntax

LEAST (n1 [, n2]...)

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 127

Page 128: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Description

Returns the least value among the arguments: n1, n2...

Example

SELECT LEAST('aa', 'ab', 'ba', 'bb') "least" FROM DUMMY; least aa

1.7.7.9 MAP

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.

NoteSearch values and corresponding results are always provided in search-result pairs.

Example

SELECT MAP(2, 0, 'Zero', 1, 'One', 2, 'Two', 3, 'Three', 'Default') "map" FROM DUMMY;

map Two

128P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 129: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

SELECT MAP(99, 0, 'Zero', 1, 'One', 2, 'Two', 3, 'Three', 'Default') "map" FROM DUMMY;

map Default

SELECT MAP(99, 0, 'Zero', 1, 'One', 2, 'Two', 3, 'Three') "map" FROM DUMMY;

map NULL

1.7.7.10 NULLIF

Syntax

NULLIF (expression1, expression2)

Description

NULLIF compares the values of two input expressions. If the first expression equals the second expression, NULLIF returns NULL.

● If expression1 does not equal expression2, NULLIF returns expression1.● If expression2 is NULL, NULLIF returns expression1.

Example

SELECT NULLIF ('diff', 'same') "nullif" FROM DUMMY; nullif diff

SELECT NULLIF('same', 'same') "nullif" FROM DUMMY; nullif NULL

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 129

Page 130: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

1.7.7.11 SESSION_CONTEXT

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 SET [SESSION] <variable_name> = <value> command, and unset using UNSET [SESSION] <variable_name>.

SESSION_CONTEXT returns an NVARCHAR with a maximum length of 512 characters.

Example

To read session variables use:

SELECT SESSION_CONTEXT('APPLICATION') "session context" FROM DUMMY;

session context HDBStudio

1.7.7.12 SESSION_USER

Syntax

SESSION_USER

130P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 131: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Description

Returns the user name of the current session.

Example

-- example showing basic function operation using SYSTEM user SELECT SESSION_USER "session user" FROM DUMMY; session user SYSTEM

-- definer-mode procedure declared by USER_A CREATE PROCEDURE USER_A.PROC1 LANGUAGE SQLSCRIPT SQL SECURITY DEFINER AS BEGIN SELECT SESSION_USER "session user" FROM DUMMY; END; -- USER_B is executing USER_A.PROC CALL USER_A.PROC1;

session user USER_B

-- invoker-mode procedure declared by USER_A CREATE PROCEDURE USER_A.PROC2 LANGUAGE SQLSCRIPT SQL SECURITY INVOKER AS BEGIN SELECT SESSION_USER "session user" FROM DUMMY; END; -- USER_B is executing USER_A.PROC CALL USER_A.PROC2;

session user USER_B

1.7.7.13 SYSUUID

SYSUUID

SYSUUID

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 131

Page 132: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

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

SELECT SYSUUID FROM DUMMY; SYSUUID 4DE3CD576C79511BE10000000A3C2220

1.8 SQL Statements

This chapter describes the SQL statements that are supported by the SAP HANA Database.

● Data Definition Statements● Data Manipulation Statements● System Management Statements● Session Management Statements● Transaction Management Statements● Access Control Statements● Data Import Export Statements● Procedural Statements

1.8.1 Data Definition Statements

● ALTER AUDIT POLICY● ALTER FULLTEXT INDEX● ALTER INDEX● ALTER SEQUENCE● ALTER TABLE● COMMENT ON● CREATE AUDIT POLICY● CREATE FULLTEXT INDEX● CREATE INDEX● CREATE SCHEMA

132P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 133: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

● CREATE SEQUENCE● CREATE STATISTICS● CREATE SYNONYM● CREATE TABLE● CREATE TRIGGER● CREATE VIEW● DROP AUDIT POLICY● DROP FULLTEXT INDEX● DROP INDEX● DROP SCHEMA● DROP SEQUENCE● DROP STATISTICS● DROP SYNONYM● DROP TABLE● DROP TRIGGER● DROP VIEW● REFRESH STATISTICS● RENAME COLUMN● RENAME INDEX● RENAME TABLE

1.8.1.1 ALTER AUDIT POLICY

Syntax

ALTER AUDIT POLICY <policy_name> <audit_mode>

Syntax Elements

<policy_name> ::= <identifier>

The name of the audit policy to be altered.

<audit_mode> ::= ENABLE | DISABLE

The audit mode enables or disables the audit policy.

ENABLE

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 133

Page 134: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Enables the audit policy.

DISABLE

Disables the audit policy.

Description

The ALTER AUDIT POLICY statement enables or disables an audit policy. <policy_name> must specify an existing audit policy.

Only database users with the system privilege AUDIT ADMIN are allowed to alter an audit policy. Users with this privilege can alter any audit policy, regardless of if they are the creator of the policy.

When an audit policy is created, it is created in the disabled state. Therefore the audit policy has to be enabled to make its audit actions take effect.

An audit policy can be disabled and enabled as often as required.

Configuration Parameters

The following configuration parameters for auditing are stored in global.ini, in the section auditing configuration:

global_auditing_state ( 'true' / 'false' )

Regardless of the number of enabled audit policies, auditing will only occur if the global_auditing_state configuration parameter is set to true. The default is 'false'.

default_audit_trail_type ( 'SYSLOGPROTOCOL' / 'CSVTEXTFILE' )

Specifies how auditing results will be stored.

● SYSLOGPROTOCOL: uses the system syslog.● CSVTEXTFILE: stores audit information as comma-separated values in a text file.

default_audit_trail_path

Specifies the file path where the CSVTEXTFILE should be stored.

The parameters above can be selected in the M_INIFILE_CONTENTS monitoring view if the user has the required system privileges. The parameters can only be observed in a monitoring view when they have been explicitly defined.

134P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 135: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

System Views

AUDIT_POLICIES : All audit policies and their states.

M_INIFILE_CONTENTS : Database system configuration parameters.

Only users with system privilege CATALOG READ, DATA ADMIN or INIFILE ADMIN can view the content of the M_INIFILE_CONTENTS view. For all other database users this view will be empty.

Example

For this example you need to first create an audit policy called priv_audit using the following statement:

CREATE AUDIT POLICY priv_audit AUDITING SUCCESSFUL GRANT PRIVILEGE, REVOKE PRIVILEGE, GRANT ROLE, REVOKE ROLE LEVEL CRITICAL;

Now you can enable this audit policy with:

ALTER AUDIT POLICY priv_audit ENABLE;

You can also disable the same audit policy with:

ALTER AUDIT POLICY priv_audit DISABLE;

1.8.1.2 ALTER FULLTEXT INDEX

Syntax

ALTER FULLTEXT INDEX <index_name> <alter_fulltext_index_option>

Syntax Elements

<index_name> ::= [<schema_name>.]<identifier> <schema_name> ::= <identifier>

The name of the fulltext index to be rebuilt, with optional schema name.

<alter_fulltext_index_option> ::= <fulltext_parameter_list> | <queue_command> QUEUE

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 135

Page 136: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Specifies whether the parameters of the fulltext index or the state of the fulltext index queue should be changed. The latter is only possible for an asynchronous explicit fulltext index.

<fulltext_parameter_list> ::= <fulltext_parameter> [{, <fulltext_parameter>} ...]

A list of fulltext index parameters that are to be changed.

<fulltext_parameter> ::= FUZZY SEARCH INDEX <on_off> | PHRASE INDEX RATIO <index_ratio>

Fulltext index parameters.

FUZZY SEARCH INDEX <on_off> <on_off> ::= ON | OFF

Defines if a fuzzy search index will be used. ON switches on the fuzzy seach index, and OFF turns the fuzzy search index off.

PHRASE INDEX RATIO <index_ratio>

Specifies the phrase index ratio.

<index_ratio> ::= <exact_numeric_literal>

Specifies the percentage of the phrase index ratio, the value used must be between 0.0 and 1.0

<queue_command> ::= FLUSH | SUSPEND | ACTIVATE

Specifies an action to be performed on the index queue.

FLUSH

Updates the fulltext index with the documents in the queue that have already been processed.

SUSPEND

Suspends the fulltext index processing queue.

ACTIVATE

Activates the fulltext index processing queue.

Description

The ALTER FULLTEXT INDEX command either change the parameters of a fulltext index or the state of an index processing queue. The queue is a mechanism used to enable a fulltext index to operate in asynchronous manner, i.e. inserts will not block until a document is processed.

136P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 137: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Examples

You create table T and then add two indices i1 and i2. Index i1 is a synchronous fulltext index, i2 is an asynchronous fulltext index.

CREATE COLUMN TABLE T (c1 NVARCHAR(1000), c2 NVARCHAR(1000)); CREATE FULLTEXT INDEX i1 ON T (c1) SYNC; CREATE FULLTEXT INDEX i2 ON T (c2) ASYNC;

You alter the phrase index to 30 percent and turn on the fuzzy search index for indexes i1 and i2.

ALTER FULLTEXT INDEX i1 PHRASE INDEX RATIO 0.3 FUZZY SEARCH INDEX ON; ALTER FULLTEXT INDEX i2 PHRASE INDEX RATIO 0.3 FUZZY SEARCH INDEX ON;

You suspend the queue for fulltext index i2.

ALTER FULLTEXT INDEX i2 SUSPEND QUEUE;

You update the fulltext index with the documents in the queue that have already been processed.

ALTER FULLTEXT INDEX i2 FLUSH QUEUE;

1.8.1.3 ALTER INDEX

Syntax

ALTER INDEX <index_name> REBUILD

Syntax Elements

<index_name> ::= [<schema_name>.]<identifier> <schema_name> ::= <identifier>

The name of the index to be rebuilt, with optional schema name.

Description

The ALTER INDEX statement rebuilds an index.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 137

Page 138: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Example

You create table A and an index i on column b of table A.

CREATE TABLE A (a INT, b NVARCHAR(10), c NVARCHAR(20)); CREATE INDEX i ON A(b);

You rebuild index i.

ALTER INDEX i REBUILD;

1.8.1.4 ALTER SEQUENCE

Syntax

ALTER SEQUENCE <sequence_name> [<restart_with>] [<parameter_list>] [RESET BY <reset_by_subquery>]

Syntax Elements

<sequence_name> ::= [<schema_name>.]<identifier> <schema_name> ::= <identifier>

The name of the sequence to be altered with optional schema name.

<sequence_parameter_restart_with> ::= RESTART WITH <restart_value> <restart_value> ::= <signed_integer>

The starting value of the sequence. <restart_value> can be between -4611686018427387904 and 4611686018427387902

NoteIf you do not specify a value for the RESTART WITH clause, the current value of the sequence is used.

<parameter_list> ::= <sequence_parameter>[{, <sequence_parameter>}...]

The sequence paramter list.

<sequence_parameter>::= INCREMENT BY <increment_value> | MAXVALUE <max_value> | NO MAXVALUE | MINVALUE <min_value>

138P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 139: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

| NO MINVALUE | CYCLE | NO CYCLE | CACHE <cache_size> | NO CACHE

A set of parameters that can be used with ALTER SEQUENCE. For parameter details see below.

INCREMENT BY <increment_value> <increment_value> ::= <signed_integer>

The amount the next sequence value is incremented from the last value assigned. The default is 1. You specify a negative value to generate a descending sequence. An error is returned if the INCREMENT BY value is 0.

MAXVALUE <max_value> <max_value> ::= <signed_integer>

The maximum value that can be generated by the sequence. <max_value> must be between -4611686018427387903 and 4611686018427387902.

NO MAXVALUE

When the NO MAXVALUE directive is used the maximum value for an ascending sequence will be 4611686018427387903 and the maximum value for a descending sequence will be -1.

MINVALUE <min_value> <min_value> ::= <signed_integer>

The minimum value that a sequence can generate. <min_value> must be between -4611686018427387904 and 4611686018427387902.

NO MINVALUE

When the NO MINVALUE directive is used, the minimum value for an ascending sequence is 1 and the minimum value for a descending sequence is -4611686018427387903.

CYCLE

When the CYCLE directive is used the sequence number will be restarted after it reaches its maximum or minimum value.

NO CYCLE

When the NO CYCLE directive is used the sequence number will not be restarted after it reaches its maximum or minimum value.

CACHE <cache_size>

The cache size with which a range of sequence numbers will be cached in a node. <cache_size> must be unsigned integer. An error is returned if the CACHE is less than 2 or greater than min(MAXVALUE - MINVALUE, 30000). 2 <= cache_size <= min(MAXVALUE - MINVALUE, 30000)

NO CACHE

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 139

Page 140: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Default option. When the NO CACHE directive is used, the sequence number will not be cached in a node

<reset_by_subquery> ::= <subquery>

During a restart of the database, the system automatically executes the RESET BY statement and the sequence value is restarted with the value determined from the RESET BY subquery.

NoteIf RESET BY is not specified, the sequence value is stored persistently in database. During the restart of the database, the next value of the sequence is generated from the saved sequence value.

For more information on subqueries, see Subquery

Description

The ALTER SEQUENCE statement is used to alter the parameters of a sequence generator.

Examples

Example 1

You create table A and a sequence seq. Sequence seq, when reset, will start from the value of the select statement shown.

CREATE TABLE A (a INT); CREATE SEQUENCE seq RESET BY SELECT IFNULL(MAX(a), 0) + 1 FROM A;

You change the starting sequence value of sequence seq to 2.

ALTER SEQUENCE seq RESTART WITH 2;

You change the maximum value of sequence s to 100, and specify that it does not have a minimum value.

ALTER SEQUENCE seq MAXVALUE 100 NO MINVALUE;

You change the incremental value of sequence seq to 3, and specify that the sequence will not restart upon reaching its maximum or minimum value.

ALTER SEQUENCE seq INCREMENT BY 3 NO CYCLE;

Example 2

You create table B, with column a. You create a sequence s1 with a reset-by subquery based on table B.

CREATE TABLE B (a INT); CREATE SEQUENCE s1 RESET BY SELECT IFNULL(MAX(a), 0) + 1 FROM B;

140P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 141: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

You change the reset-by subquery of sequence s1 to the maximum value contained in column a of table B.

ALTER SEQUENCE s1 RESET BY SELECT MAX(a) FROM B;

1.8.1.5 ALTER TABLE

Syntax

ALTER TABLE <table_name> [<add_column_clause>] [<drop_column_clause>] [<alter_column_clause>] [<add_constraint_clause>] [<drop_primary_key_clause>][<drop_constraint_clause>] [<preload_clause>] [<table_conversion_clause>] [<move_clause>] [<add_range_partition_clause>] [<drop_range_partition_clause>] [<partition_clause>] [<persistent_merge_option>] [<delta_log_option>] [<auto_merge_option>] [<unload_priority>] [<schema_flexibility_option>] [<trigger_option>]

Syntax elements:

<table_name>

<add_column_clause>

<drop_column_clause>

<alter_column_clause>

<add_constraint_clause>

<drop_primary_key_clause>

<drop_constraint_clause>

<preload_clause>

<table_conversion_clause>

<add_range_partition_clause>

<drop_range_partition_clause>

<partition_clause>

<persistent_merge_option>

<delta_log_option>

<auto_merge_option>

<unload_priority>

<schema_flexibility_option>

<trigger_option>

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 141

Page 142: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Syntax Elements

<table_name>

<table_name> ::= [<schema_name>.]<identifier> <schema_name> ::= <identifier>

The identifier of the table to be altered, with optional schema name.

<add_column_clause>

<add_column_clause> ::= ADD ( {<column_definition> [<column_constraint>]} [{, <column_definition> [<column_constraint>]}...] )

Adds one or more columns to the specified table.

<drop_column_clause>

<drop_column_clause> ::= DROP ( <column_name>[{, <column_name>} ...] )

Removes one or more columns from the specified table.

<alter_column_clause>

<alter_column_clause> ::= ALTER ( <column_definition> [<column_constraint>] [{, <column_definition> [<column_constraint>]}...] )

Alters one or more column definitions.

Restrictions:

● For column table, only increasing the size of a column data type is allowed to prevent data loss. For example, changing from nvarchar(20) to nvarchar(10) or from integer to tinyint will raise an error.

● For row table, only increasing the size of VARCHAR and NVARCHAR type column is allowed. Other data type changes are not allowed.

● ALTER does not currently follow data type conversion rules.● Adding NOT NULL constraint to an existing column is allowed if either of the following cases are true:

○ The table is empty.○ The default value is specified when the table contains data.

<column_definition> ::= <column_name> {<data_type> | <lob_data_type>} [<column_store_data_type>] [<ddic_data_type>] [DEFAULT <default_value>] [GENERATED ALWAYS AS <expression>] [<schema_flexibility>] [<fuzzy_search_index>] [<fuzzy_search_mode>] [<load_unit>]

Defines a table column.

<column_name> ::= <identifier>

2

142P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 143: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

The table column name.

<data_type> ::= DATE | TIME | SECONDDATE | TIMESTAMP | TINYINT | SMALLINT | INTEGER | BIGINT | SMALLDECIMAL | DECIMAL | REAL | DOUBLE | VARCHAR | NVARCHAR | ALPHANUM | SHORTTEXT | VARBINARY | TEXT

<lob_data_type> ::= <lob_type_name> [MEMORY THRESHOLD <memory_threshold_value>] <lob_type_name> ::= BLOB | CLOB | NCLOB

<column_store_data_type> ::= CS_ALPHANUM | CS_INT | CS_FIXED | CS_FLOAT | CS_DOUBLE | CS_DECIMAL_FLOAT | CS_FIXED(p-s, s) | CS_SDFLOAT | CS_STRING | CS_UNITEDECFLOAT | CS_DATE | CS_TIME | CS_FIXEDSTRING | CS_RAW | CS_DAYDATE | CS_SECONDTIME | CS_LONGDATE | CS_SECONDDATE

<ddic_data_type> ::= DDIC_ACCP | DDIC_ALNM | DDIC_CHAR | DDIC_CDAY | DDIC_CLNT | DDIC_CUKY | DDIC_CURR | DDIC_D16D | DDIC_D34D | DDIC_D16R | DDIC_D34R | DDIC_D16S | DDIC_D34S | DDIC_DATS | DDIC_DAY | DDIC_DEC | DDIC_FLTP | DDIC_GUID | DDIC_INT1 | DDIC_INT2 | DDIC_INT4 | DDIC_INT8 | DDIC_LANG | DDIC_LCHR | DDIC_MIN | DDIC_MON | DDIC_LRAW | DDIC_NUMC | DDIC_PREC | DDIC_QUAN | DDIC_RAW | DDIC_RSTR | DDIC_SEC | DDIC_SRST | DDIC_SSTR | DDIC_STRG | DDIC_STXT | DDIC_TIMS | DDIC_UNIT | DDIC_UTCM | DDIC_UTCL | DDIC_UTCS | DDIC_TEXT | DDIC_VARC | DDIC_WEEK

The available data types. Please see Data Types.

<memory_threshold_value> ::= <unsigned_integer> | NULL

Controls if LOB data should be stored in memory or not according to the following conditions:

● If <memory_threshold_value> is not provided, lob is stored in memory by default.● If <memory_threshold_value> is provided and its LOB size is bigger than memory threshold value, LOB data is

stored on disk.● If <memory_threshold_value> is provided and its LOB size is equal or less than memory threshold value, LOB

data is stored in memory.● If <memory_threshold_value> is NULL, all LOB data is stored in memory.● If <memory_threshold_value> is 0, all LOB data is stored in disk.

DEFAULT <default_value> ::= NULL | <string_literal> | <signed_numeric_literal> | <unsigned_numeric_literal> | <datetime_value_function> <datetime_value_function> ::= CURRENT_DATE | CURRENT_TIME | CURRENT_TIMESTAMP

Specifies a value to be assigned to the column if an INSERT statement does not provide a value for the column

GENERATED ALWAYS AS <expression>

Specifies the expression to generate the column value in runtime. There are the following limitations of generated columns:

● Generated columns are not supported for row table.● Generated columns can reference only columns which are defined prior to it (left of its own definition in the

DDL).● Generated columns can reference only base columns; They cannot reference generated columns.● Specifying default values on generated columns is not possible.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 143

Page 144: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

● Generated columns cannot be as part of a primary key or a unique constraint.● Dropping base columns of generated columns is not possible.

<schema_flexibility> ::= {ENABLE | DISABLE} SCHEMA FLEXIBILITY

Specifies the column is dynamic:

● ENABLE produces a dynamic column.● DISABLE (default value) produces a static column.

<fuzzy_search_index> ::= FUZZY SEARCH INDEX [ON | OFF]

Turns a fuzzy search index on or off. OFF is the default.

<fuzzy_search_mode> ::= FUZZY SEARCH MODE [<string_literal> | NULL]

Sets the fuzzy search mode with the value of <string_literal>. If NULL is specified, the fuzzy search mode is reset.

<load_unit> ::= {PAGE | COLUMN} LOADABLE

Specifies the unit of column data loading is page. Default unit is column for column table, and table for row table.

<column_constraint> ::= NULL | NOT NULL | <unique_specification> | <references_specification>

The column constraint rules.

For NULL, NOT NULL and <unique_specification>, see below.

For <references_specification>, see References Specification

NULL

If NULL is specified it is not considered a constraint, it represents that a column that may contain a null value. The default is NULL.

NOT NULL

The NOT NULL constraint prohibits a column value from being NULL.

<unique_specification> ::= UNIQUE [<unique_tree_type_index>] | PRIMARY KEY [<unique_tree_type_index> | <unique_inverted_type_index>]

Specifies unique constraints. If the index type is omitted, the SAP HANA database chooses the appropriate index by considering the column data type. If the index type is not specified, the SAP HANA database will automatically select an index type as follows:

3

4

144P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 145: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Index type Criteria

CPBTREE - character string types.

- binary string types.

- decimal types.

- when the constraint is a composite key.

- when the constraint is a non-unique constraint

BTREE All other cases than specified for CPBTREE

UNIQUE

Specifies a column as a unique key.

A composite unique key enables the specification of multiple columns as a unique key. With a unique constraint, multiple rows cannot have the same value in the same column.

PRIMARY KEY

A primary key constraint is a combination of a NOT NULL constraint and a UNIQUE constraint. It prohibits multiple rows from having the same value in the same column.

<unique_tree_type_index> ::= BTREE | CPBTREE;

Specifies the index type.

BTREE

BTREE specifies a B+-tree index. B+-tree is a tree that maintains sorted data which performs efficient insertion, deletion and search of records.

CPBTREE

CPBTREE specifies a CPB+-tree index. CPB+-tree stands for Compressed Prefix B+-Tree, which is based on pkB-tree. CPB+-tree is a very small index because it uses 'partial key' that is only part of full key in index nodes. CPB+-tree shows better performance than B+-Tree for larger keys.

<unique_inverted_type_index> ::= INVERTED [<composite_type>]

<composite_type> ::= HASH | VALUE

Specifies the inverted index type.

INVERTED HASH

HASH encodes the composite key in a condensed manner, and allows for faster equality queries over the composite keys, as well as reduced memory requirements for storage of the composite key.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 145

Page 146: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

HASH should not be used as a composite type in cases where range queries or similarity queries on the composite keys are a signficant part of the workload, VALUE should be used instead.

INVERTED VALUE

VALUE is the default composite key type.

<add_constraint_clause>

<add_constraint_clause> ::= ADD [CONSTRAINT <constraint_name>] <table_constraint> <constraint_name> ::= <identifier>

Adds a table constraint.

<table_constraint> ::= <unique_constraint_definition> | <referential_constraint_definition>

The table constraint can be either a unique constraint or a referential constraint.

<unique_constraint_definition> ::= <unique_specification> (<unique_column_name_list>)

The unique specification see Unique specifcation

<unique_column_name_list> ::= <unique_column_name>[{, <unique_column_name>}...]

Speicfies the unique column name list which can have one or more column names.

<unique_column_name> ::= <identifier>

A column name identifier.

<referential_constraint_definition> ::= FOREIGN KEY (<referencing_column_name_list>) <references_specification>

Specifies a referential constraint.

<referencing_column_name_list> ::= <referencing_column_name>[{, <referencing_column_name>}...]

Specifies the referencing column name list which can have one or more column names.

<referencing_column_name> ::= <identifier>

The identifier of a referencing column.

<references_specification> ::= REFERENCES <referenced_table> [(<referenced_column_name_list>)] [<referential_triggered_action>]

5

6

146P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 147: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Specifies the referenced table, with optional column name list and trigger action. If <referenced_column_name_list> is specified, there will be one-to-one correspondence between <column_name> of <column_definition> (see column definition) and <referenced_column_name>. If it is not specified, there will be one-to-one correspondence between <column_name> of <column_definition> and the column name of the referenced table's primary key.

<referenced_column_name_list> ::= <referenced_column_name>[{, <referenced_column_name>}...]

Specifies the referenced column name list, which can have one or more column names.

<referenced_table> ::= <identifier>

The identifier of a table to be referenced.

<referenced_column_name> ::= <identifier>

The identifier of the column name to be referenced.

<referential_triggered_action> ::= <update_rule> [<delete_rule>] | <delete_rule> [<update_rule>]

Specifies an update rule with optional delete rule or a delete rule with optional update rule. The order in which they are provided provides an order of precedence for execution.

<update_rule> ::= ON UPDATE <referential_action> <referential_action> ::= CASCADE | RESTRICT | SET DEFAULT | SET NULL

The following UPDATE referential actions are possible:

Action Name Update Action

RESTRICT Any updates to a referenced table are prohibited if there are any matched records in the referencing table. This is the default action.

CASCADE If a record is updated in the referenced table, the corresponding records in the referencing table are also updated with the same values.

SET NULL If a record is updated in the referenced table, the corresponding records in the referencing table are also updated with null values.

SET DEFAULT If a record is updated in the referenced table, the corresponding records in the referencing table are also updated with their default values

<delete_rule> ::= ON DELETE <referential_action>

The following DELETE referential actions are possible:

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 147

Page 148: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Action Name Delete Action

RESTRICT Any deletions to a referenced table are prohibited if there are any matched records in the referencing table. This is the default action.

CASCADE If a record in the referenced table is deleted, the corresponding records in the referencing table are also deleted.

SET NULL If a record in the referenced table is deleted, the corresponding records in the referencing table are set to null.

SET DEFAULT If a record in the referenced table is deleted, the corresponding records in the referencing table are set to their default values.

<drop_primary_key_clause>

<drop_primary_key_clause> ::= DROP PRIMARY KEY

Drops the primary key constraint.

<drop_constraint_clause>

<drop_constraint_clause> ::= DROP CONSTRAINT <constraint_name> <constraint_name> ::= <identifier>

Drops a unique or referential constraint.

<preload_clause>

<preload_clause> ::= PRELOAD ALL | PRELOAD ( <column_name> ) | PRELOAD NONE

Sets or removes the preload flag of the given tables or columns.

When the preload flag is set tables are automatically loaded into memory after an index server start. The current status of the preload flag is visible in the system table TABLES in the PRELOAD column. Possible values are 'FULL', 'PARTIALLY' and 'NO'. Also in system table TABLE_COLUMNS in column PRELOAD with possible values being 'TRUE' or 'FALSE'.

PRELOAD ALL

Sets preload flags of all columns in the table.

PRELOAD ( <column_name> )

Sets the flags of the specified column.

PRELOAD NONE

Removes the preload flag from all columns.

148P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 149: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

<table_conversion_clause>

<table_conversion_clause> ::= [ALTER TYPE] {ROW [THREADS <number_of_threads>] | COLUMN [<column_store_mode>] [THREADS <number_of_threads> [BATCH <batch_size>]]}

Converts the table storage from ROW to COLUMN or from COLUMN to ROW.

ROW

Converts the table to ROW storage.

COLUMN

Converts the table to COLUMN storage.

<column_store_mode> ::= DELTA | MAIN

Specifies which column to use for destination column table. The default is to use column DELTA.

THREADS <number_of_threads> <number_of_threads> ::= <unsigned_integer>

Specifies how many parallel execution threads should be used for the table conversion. The optimal value for the number of threads is the number of available CPU cores. If THREADS is not provided the default value of the number of CPU cores specified in the indexserver.ini file will be used.

BATCH <batch_size> <batch_size> ::= <unsigned_integer>

Specifies the number of rows to be inserted in a batch. If BATCH is not specified the default value of 2,000,000 will be used. Inserts into column tables will be immediately committed after every <batch_size> records have been inserted. BATCH option can be used only when a table is converted from ROW to COLUMN storage.

<move_clause>

<move_clause> ::= MOVE [PARTITION <partition_number>] TO <indexserver_host_port> [PHYSICAL] | MOVE [PARTITION <partition_number>] PHYSICAL

Moves a table to another location in a distributed environment.

PARTITION <partition_number> <partition_number> ::= <unsigned_integer>

For partitioned tables, specifies the partition to be moved. If you attempt to move a partitioned table without specifying a <partition_number> an error is returned.

<indexserver_host_port> ::= <unsigned_integer>

The internal indexserver port number where the table is to be moved.

PHYSICAL

Specifies that a column store tables persistence storage is moved immediately to the target host. If the PHYSICAL option is not specified the table move will create a link inside the new host persistence pointing to the old host

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 149

Page 150: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

persistence. The link will be removed on the next merge or upon execution of another move operation not using the TO <indexserver_host_port> clause.

The PHYSICAL keyword is only for column store tables. Row store tables are always moved immediately.

<add_range_partition_clause>

<add_range_partition_clause> ::= ADD <range_partition_clause>

Adds a partition for tables partitioned with RANGE, HASH RANGE, ROUNDROBIN RANGE.

<range_partition_clause> ::= {<from_to_spec> | <single_spec>} [, PARTITION OTHERS]

The range specifier for a new partition.

For syntax details please see partition range specifier below.

<drop_range_partition_clause>

<drop_range_partition_clause> ::= DROP <range_partition_clause>

Drops a partition for tables partitioned with RANGE, HASH RANGE, ROUNDROBIN RANGE.

<partition_clause>

<partition_clause> ::= PARTITION BY <hash_partition> [, <range_partition> | , <hash_partition>] | PARTITION BY <range_partition> | PARTITION BY <roundrobin_partition> [,<range_partition>]

The PARTITION BY option partitions a table using the selected rules.

For more information about partitioning please see the "Table Partitioning in the SAP HANA database" section in the "SAP HANA Administration guide" available from the SAP HANA Appliance page.

<hash_partition> ::= HASH (<partition_expression> [{<partition_expression>,}...]) PARTITIONS {<num_partitions> | GET_NUM_SERVERS()}

Partitions the created table using a hash partitioning scheme.

<range_partition> ::= RANGE (<partition_expression>) (<range_spec>, ...)

Partitions the created table using a range partitioning scheme.

<roundrobin_partition> ::= ROUNDROBIN PARTITIONS {<num_partitions> | GET_NUM_SERVERS()} [, <range_partition>]

Partitions the created table using a round robin partitioning scheme.

GET_NUM_SERVERS()

Returns the number of servers available in the partitioning cluster.

<range_spec> ::= {<from_to_spec> | <single_spec>} [{{<from_to_spec> | <single_spec>},} ...] [, PARTITION OTHERS]

The range specifier for a partition.

150P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 151: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

<from_to_spec> ::= PARTITION <lower_value> <= VALUES < <upper_value>

Specifies a partition using lower and upper values of a <partition_expression>.

<single_spec> ::= PARTITION VALUE = <target_value>

Specifies a partition using a single value of a <partition_expression>.

PARTITION OTHERS

Specifies that all other values that are not covered by the partition specification will be gathered into one partition.

<partition_expression> ::= <column_name> | YEAR(<column_name>) | MONTH(<column_name>)

The specifier used to segregate data into partitions.

<lower_value> ::= <string_literal> | <numeric_literal>

The lower value of a partition specifier.

<upper_value> ::= <string_literal> | <numeric_literal>

The upper value of a partition specifier.

<target_value> ::= <string_literal> | <numeric_literal>

The target value of a single partition specifier.

<num_partitions> ::= <unsigned_integer>

The number of partitions to be created for the table.

<merge_partition_clause> ::= MERGE PARTITIONS

Merges all parts of a partitioned table into a non-partitioned table.

<persistent_merge_option>

<persistent_merge_option> ::= {ENABLE | DISABLE} PERSISTENT MERGE

Enables or disables persistent merging.

● When enabled the merge-manager uses persistent merges for the given table. This is the default behaviour.● When disabled the merge-manager uses main-memory merges instead of persistent merges for the given

table.

<delta_log_option>

<delta_log_option> ::= {ENABLE | DISABLE} DELTA LOG

Enables or disables delta logging for table.

7

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 151

Page 152: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

After enabling, you have to perform a savepoint to be certain that all data is persisted. Also you have to perform a data backup, otherwise it will not be possible to recover this data.

If logging is disabled, log entries will not be persisted for this table. Changes to this table will only be written to the data store when a savepoint is carried out. This can cause loss of committed transaction should the indexserver terminate. In the case of a termination, you have to truncate this table and insert all data again.

NoteYou should only use this option during initial load.

<auto_merge_option>

<auto_merge_option> ::= {ENABLE | DISABLE} AUTOMERGE

Enables or disables automatic delta merge on the specified table.

<unload_priority>

<unload_priority_option> ::= UNLOAD PRIORITY <unload_priority>

UNLOAD PRIORITY specifies that priority of table to be unloaded from memory.

<unload_priority> ::= <digit>

Sets the priority of table to be unloaded from memory. It can be 0 ~ 9, where 0 means not-unloadable and 9 means earliest unload.

<schema_flexibility_option>

<schema_flexibility_option> ::= {ENABLE | DISABLE} SCHEMA FLEXIBILITY

Enables or disables schema flexibility for the specified table.

<trigger_option>

<trigger_option> ::= {ENABLE | DISABLE} TRIGGER [TRIGGER_NAME]

Enables or disables the specified trigger on the specified table. If trigger_name is not specified enables or disables all triggers on the specified table.

Description

The ALTER TABLE statement changes the definition of a table.

System Views

TABLES : Table information.

TABLE_COLUMNS : Table column information.<b

152P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 153: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Examples

You create Table t, and then alter default value of column b to 10.

CREATE TABLE t (a INT, b INT); ALTER TABLE t ALTER (b INT DEFAULT 10);

You alter table t adding a new column c.

ALTER TABLE t ADD (c NVARCHAR(10) DEFAULT 'NCHAR');

You create a primary key constraint, prim_key, on columns a and b of table t.

ALTER TABLE t ADD CONSTRAINT prim_key PRIMARY KEY (a, b);

You change the table type of table t to COLUMN storage.

ALTER TABLE t COLUMN;

You set the preload flags of column b and c on table t.

ALTER TABLE t PRELOAD (b, c);

You partition table t with a RANGE partition, and then add an additional partition.

ALTER TABLE t PARTITION BY RANGE (a) (PARTITION VALUE = 1, PARTITION OTHERS); ALTER TABLE t ADD PARTITION 2 <= VALUES < 10;

You disable delta logging of table t.

ALTER TABLE t DISABLE DELTA LOG;

You change the unload priority of table t to 2:

ALTER TABLE t UNLOAD PRIORITY 2;

You create table R. Then you alter table R adding a unique constraint UK.

CREATE TABLE R (A INT PRIMARY KEY, B NVARCHAR(10)); ALTER TABLE R ADD CONSTRAINT UK UNIQUE (B);

You drop the unique constraint UK from table R.

ALTER TABLE R DROP CONSTRAINT UK;

You create table S. You add a referential constraint FK to table S that references column A of table R with delete cascade option.

CREATE TABLE S (FA INT, B NVARCHAR(10)); ALTER TABLE S ADD CONSTRAINT FK FOREIGN KEY(FA) REFERENCES R(A) ON DELETE CASCADE;

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 153

Page 154: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

You create table T1 and then turn on the schema flexibility of the table. You test the schema flexibility of table T1 by inserting a new record. A new column F is automatically created and a record is inserted:

CREATE COLUMN TABLE T1 (C INT); ALTER TABLE T1 ENABLE SCHEMA FLEXIBILITY; INSERT INTO T1 (C, F) VALUES (1, 'NVAR1');

You create table T2 with a fuzzy search index and fuzzy search mode. You then switch off the fuzzy search index of COL1 and finally reset fuzzy search mode of COL2.

CREATE COLUMN TABLE T2 (KEY INT, COL1 VARCHAR(10) FUZZY SEARCH INDEX ON, COL2 NVARCHAR(10) FUZZY SEARCH MODE 'postcode'); ALTER TABLE T2 ALTER (COL1 VARCHAR(10) FUZZY SEARCH INDEX OFF); ALTER TABLE T2 ALTER (COL2 NVARCHAR(10) FUZZY SEARCH MODE NULL);

You create table T3 with page loadable columns C3, C4 and C5. Then, C3 becomes column loadable and C6 page loadable.

CREATE COLUMN TABLE T3 (C1 INT PRIMARY KEY, C2 DATE, C3 VARCHAR(80) PAGE LOADABLE NOT NULL, C4 VARCHAR(5000) PAGE LOADABLE, C5 VARCHAR(5000) PAGE LOADABLE NOT NULL, C6 VARCHAR(5000)); ALTER TABLE T3 ALTER (C3 VARCHAR(80) COLUMN LOADABLE, C6 VARCHAR(5000) PAGE LOADABLE);

1.8.1.6 COMMENT ON

Syntax

COMMENT ON {TABLE | VIEW } <object_name> IS <comment> COMMENT ON COLUMN <column_ref> IS <comment>

Syntax Elements

<object_name> ::= [<schema_name>.] {<table_name> | <view_name>} <table_name> ::= <identifier> <view_name> ::= <identifier> <schema_name> ::= <identifier>

The identifier of table or view to be commented on, with optional schema name.

<column_ref> ::= {<table_name> | <view_name>}.<identifier>

The identifier of a column to be commented on.

<comment> ::= <string_literal>

154P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 155: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

The comment for the database object or column.

Description

You use COMMENT ON command to add comments to tables, views or their columns. Comments are a useful way to record a human readable description of schema tables/views, and their columns, for future reference.

System Views

TABLES : Table comments.

TABLE_COLUMNS : Table column comments.

VIEWS : View comments.

VIEW_COLUMNS : View column comments.

Examples

Example 1 - Comment on a table.

You create a table and add a comment on it.

CREATE TABLE COMMENT_ON_EX(A INT); COMMENT ON TABLE COMMENT_ON_EX IS 'Used for comment on examples';

You select the table from the TABLES system table to view the comment.

SELECT * FROM TABLES where TABLE_NAME='COMMENT_ON_EX';

Example 2 - Comment on a table column.

You comment on column A of the COMMENT_ON_EX table from example 1.

COMMENT ON COLUMN COMMENT_ON_EX.A IS 'This is an example column comment';

You select the column description from the TABLE_COLUMNS system table.

SELECT * FROM TABLE_COLUMNS where TABLE_NAME='COMMENT_ON_EX';

Example 3 - Comment on a view and view column.

You create a view, a view comment, and view column comment.

CREATE VIEW COMMENT_ON_EX_VIEW AS SELECT * FROM COMMENT_ON_EX; COMMENT ON VIEW COMMENT_ON_EX_VIEW IS 'This is a view comment'; COMMENT ON COLUMN COMMENT_ON_EX_VIEW.A IS 'This is a view column comment';

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 155

Page 156: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

You select the view comment and view column comments from the relevant system tables.

SELECT * FROM VIEWS where VIEW_NAME='COMMENT_ON_EX_VIEW'; SELECT * FROM VIEW_COLUMNS where VIEW_NAME='COMMENT_ON_EX_VIEW';

1.8.1.7 CREATE AUDIT POLICY

Syntax

CREATE AUDIT POLICY <policy_name> AUDITING <audit_status_clause> <audit_actions> LEVEL <audit_level>

Syntax Elements

<policy_name> ::= <identifier>

The name of the audit policy to be created.

<audit_status_clause> ::= SUCCESSFUL | UNSUCCESSFUL | ALL

Defines whether successful, unsuccessful or all executions of the specified audit actions will be audited.

<audit_actions> ::= <actions_for_user_clause> | <audit_action_list_clause> | <target_audit_action_list_clause>

The audit actions for the audit policy.

<actions_for_user_clause> ::= ACTIONS FOR <user_name>[{, <user_name>}...]

Audits actions for a user or a set of users.

<user_name> ::= <identifier>

The username of the user to be audited by the audit policy.

<audit_action_list_clause> ::= <audit_action_list> [FOR <user_name>[{, <user_name>}...] <audit_action_list> ::= <audit_action_name>[{, <audit_action_name>}...] <audit_action_name> ::= GRANT PRIVILEGE | REVOKE PRIVILEGE | GRANT STRUCTURED PRIVILEGE | REVOKE STRUCTURED PRIVILEGE | GRANT APPLICATION PRIVILEGE | REVOKE APPLICATION PRIVILEGE | GRANT ROLE | REVOKE ROLE | GRANT ANY | REVOKE ANY

156P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 157: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

| CREATE USER | DROP USER | ALTER USER | DROP TABLE | CREATE ROLE | DROP ROLE | ENABLE AUDIT POLICY | DISABLE AUDIT POLICY | CREATE STRUCTURED PRIVILEGE | DROP STRUCTURED PRIVILEGE | ALTER STRUCTURED PRIVILEGE | CONNECT | SYSTEM CONFIGURATION CHANGE | SET SYSTEM LICENSE | UNSET SYSTEM LICENSE | ACTIVATE REPOSITORY CONTENT | EXPORT REPOSITORY CONTENT | IMPORT REPOSITORY CONTENT | DISCONNECT SESSION | CANCEL SESSION | BACKUP CATALOG DELETE

Audits specific system actions, optionally limited to a user or a set of users. For more information on audit actions see Audit Actions.

<target_audit_action_list> ::= <target_audit_action_entry> [FOR <user_name>[{, <user_name>}...] <target_audit_action_entry> ::= <target_audit_action_name>[{, <target_audit_action_name>}...] ON <object_name>[{, <object_name>}...] <target_audit_action_name> ::= INSERT | UPDATE | DELETE | SELECT | EXECUTE

Audits actions on a database object or set of objects. Optionally this auditing can be limited to a user or a set of users. Only objects of type table, view, and procedure can be specified in the <target_audit_action_entry>. Synonyms and sequences cannot be selected as objects for audit policies. Furthermore only these <target_audit_action_name>s can be combined with an object. The following table shows an overview of auditable actions on objects.

Action Table View Procedure

DELETE YES YES ---

INSERT YES YES ---

SELECT YES YES ---

UPDATE YES YES ---

EXECUTE --- --- YES

<object_name> ::= <table_name> | <view_name> | <procedure_name>

<table_name> ::= [<schema_name>.]<identifier> <view_name> ::= [<schema_name>.]<identifier> <procedure_name> ::= [<schema_name>.]<identifier> <schema_name> ::= <identifier>

Specifies a database object for the target audit action.

<audit_level> ::= EMERGENCY | ALERT | CRITICAL | WARNING | INFO

Assigns an audit policy to an audit level. Possible levels, in decreasing order of importance, are:

● EMERGENCY.● ALERT.● CRITICAL.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 157

Page 158: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

● WARNING.● INFO.

Description

The CREATE AUDIT POLICY statement creates a new audit policy. This audit policy can then be enabled and will cause the auditing of the specified audit actions to occur.

Only database users having the system privilege AUDIT ADMIN are allowed to create an audit policy.

The specified audit policy name must be unique not match the name of an existing audit policy.

An audit policy defines which audit actions will be audited. Audit policies need to be enabled for auditing to occur.

One audit policy can contain one of the following:

● non-restricted auditing for n (>=1) users● auditing for actions not restricted to objects● auditing for actions which are restricted to objects.

For the last two alternatives listed, an optional restriction for user(s) is available.

For auditing to occur, audit policies have to be created and enabled. Also the configuration parameter global_auditing_state (see Configuration Parameters) has to be set to true.

Audit Actions

The table below contains the available audit actions. Each of the audit actions are in a specific group, audit actions in the same group can be combined into one audit policy.

Audit Action Name Group Number Audit Operation Comment

CONNECT 1 creation of a user connection to the database

SYSTEM CONFIGURATION CHANGE

1 changes to the system configuration (e.g. INIFILE)

DISCONNECT SESSION 1 audits disconnects of sessions

CANCEL SESSION 1 audits cancelation of sessions

8

158P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 159: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Audit Action Name Group Number Audit Operation Comment

GRANT PRIVILEGE 2 granting of privileges to users or roles

REVOKE PRIVILEGE 2 revoking of privileges from users or roles

GRANT STRUCTURED PRIVILEGE

2 granting of structured/analytical privileges to users or roles

REVOKE STRUCTURED PRIVILEGE

2 revoking of structured/analytical privileges from users or roles

GRANT APPLICATION PRIVILEGE

2 granting of application privileges to users or roles

REVOKE APPLICATION PRIVILEGE

2 revoking of application privileges from users or roles

GRANT ROLE 2 granting of roles to users or roles

REVOKE ROLE 2 revoking of roles from users or roles

GRANT ANY 2 granting of privileges, structured privileges or roles to users or roles

REVOKE ANY 2 revoking of privileges, structured privileges or roles from users or roles

INSERT 3 use of insert/replace/upsert statements on tables and views

allows specification of target objects

UPDATE 3 use of update/replace/upsert statements on tables and views

allows specification of target objects

DELETE 3 deletion of rows from tables/views and truncation of tables

allows specification of target objects

SELECT 3 use of select statements on tables and views

allows specification of target objects

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 159

Page 160: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Audit Action Name Group Number Audit Operation Comment

EXECUTE 3 procedure calls allows specification of target objects

CREATE USER 4 creation of users

DROP USER 4 dropping of users

ALTER USER 4 altering of users

CREATE ROLE 4 creation of roles

DROP ROLE 4 dropping of roles

ENABLE AUDIT POLICY 5 activation of audit policies

DISABLE AUDIT POLICY 5 deactivation of audit policies

CREATE STRUCTURED PRIVILEGE

7 creation of structured/analytical privileges

DROP STRUCTURED PRIVILEGE

7 destruction of structured/analytical privilege

ALTER STRUCTURED PRIVILEGE

7 change of structured/analytical privilege

SET SYSTEM LICENSE 8 installation of a system license

UNSET SYSTEM LICENSE 9 deletion of licenses

ACTIVATE REPOSITORY CONTENT

10 activation of repository design time objects

EXPORT REPOSITORY CONTENT

10 export of repository design time objects

IMPORT REPOSITORY CONTENT

10 import of repository design time objects

DROP TABLE 11 deletion of database tables

BACKUP CATALOG DELETE

13 audits deletion of entries in the backup catalog

ALL 12 all actions above used for specific users

160P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 161: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Configuration Parameters

Currently the configuration parameter for auditing are stored in global.ini configuration file, in the auditing configuration section.

global_auditing_state ( 'true' / 'false' )

Activates / deactivates auditing globally, regardless of the enabled state of the audit policies. The default is false, meaning: no auditing will occur.

default_audit_trail_type ( 'SYSLOGPROTOCOL' / 'CSVTEXTFILE' )

Specifies how to store the auditing results. SYSLOGPROTOCOL is the default.

CSVTEXTFILE should be used only for testing purposes.

default_audit_trail_path

Specifies the audit file storage location for the CSVTEXTFILE audit trail type.

As for all configuration parameters, these parameters can be selected in view M_INIFILE_CONTENTS, assuming that the current user has the required privileges.

NoteThese parameters can only be seen if they have been explicitly set.

System Views

AUDIT_POLICIES : All audit policies and their states.

M_INIFILE_CONTENTS : Configuration parameter concerning auditing.

Only database users with system privilege CATALOG READ, DATA ADMIN or INIFILE ADMIN can view information in the M_INIFILE_CONTENTS view. For other database users this view will be empty.

Example

Your create a new audit policy named priv_audit that will audit successful granting and revoking of privileges and roles. The audit policy has the medium audit level CRITICAL.

This policy has to be explicitly enabled (see ALTER AUDIT POLICY) to cause the auditing of the audit policy.

CREATE AUDIT POLICY priv_audit AUDITING SUCCESSFUL GRANT PRIVILEGE, REVOKE PRIVILEGE, GRANT ROLE, REVOKE ROLE LEVEL CRITICAL;

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 161

Page 162: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

You create a new audit policy named object_audit that will audit the inserts into the existing table MY_SCHEMA.MY_TABLE. This policy has to be explicitly enabled (see ALTER AUDIT POLICY) to cause the auditing of the audit policy. This policy is restricted to user FRED and uses the audit level INFO.

CREATE USER FRED PASSWORD Initial_1; CREATE SCHEMA MY_SCHEMA OWNED BY system; CREATE TABLE MY_SCHEMA.MY_TABLE (first_col int); GRANT INSERT ON MY_SCHEMA.MY_TABLE to FRED; CREATE AUDIT POLICY OBJECT_AUDIT AUDITING SUCCESSFUL INSERT ON MY_SCHEMA.MY_TABLE FOR FRED LEVEL INFO

1.8.1.8 CREATE FULLTEXT INDEX

Syntax

CREATE FULLTEXT INDEX <index_name> ON <table_name> ( <column_name> ) [<fulltext_parameter_list>]

Syntax Elements

<index_name> ::= [<schema_name>.]<identifier> <schema_name> ::= <identifier>

The name of the fulltext index to be created, with optional schema name.

<fulltext_parameter_list> ::= <fulltext_parameter> [{, <fulltext_parameter>}...]

<fulltext_parameter> ::= 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> | MIME TYPE <string_literal>

<column_name> ::= <identifier>

Fulltext parameters.

LANGUAGE COLUMN <column_name>

Defines the column where the language of a document is specified.

LANGUAGE DETECTION ( <string_literal_list> )

162P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 163: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

The set of languages to be considered during language detection.

MIME TYPE COLUMN <column_name>

Defines the column where the mime-type of a document is specified.

FUZZY SEARCH INDEX <on_off>

Specifies whether a fuzzy search index should be used.

PHRASE INDEX RATIO <index_ratio> <index_ratio> ::= <exact_numeric_literal>

Specifies the percentage of the phrase index. Value must be between 0.0 and 1.0

CONFIGURATION <string_literal>

The path to a custom configuration file for text analysis.

SEARCH ONLY <on_off>

Defines if the original document should be stored or only the search results. When set to ON the original document content is not stored.

FAST PREPROCESS <on_off>

If set to ON, fast preprocessing is used, i.e. linguistic searches are not possible.

MIME TYPE <string_literal>

The default mime type used for preprocessing. The value must be a valid mime type, for example 'cf M_TEXT_ANALYSIS_MIME_TYPES'.

<on_off> ::= ON | OFF

Enables and disables the defined option.

<change_tracking_elem> ::= SYNC[HRONOUS] | ASYNC[HRONOUS] [FLUSH [QUEUE] <flush_queue_elem>]

The type of index to be created.

SYNC[HRONOUS]

Creates a synchronous fulltext index.

ASYNC[HRONOUS]

Creates an asynchronous fulltext index.

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

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 163

Page 164: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Specifies when to update the fulltext index if an asynchronous index is used.

Description

The CREATE FULLTEXT INDEX statement creates an explicit fulltext index on the given table column.

Fulltext index is supported for the following data types:

● VARCHAR, NVARCHAR types with CS_STRING type● VARBINARY type● BLOB, CLOB, NCLOB types

Example

You create table A.

CREATE COLUMN TABLE A (A VARCHAR(10) PRIMARY KEY, B VARCHAR(10));

You create synchronous fulltext index named 'i'. Index i is on column 'A' of table 'A', where the fuzzy search index is not used and the set of languages for language detection consists of 'EN','DE' and 'KR'.

CREATE FULLTEXT INDEX i ON A(A) FUZZY SEARCH INDEX OFF SYNC LANGUAGE DETECTION ('EN','DE','KR')

1.8.1.9 CREATE INDEX

Syntax

CREATE [UNIQUE] [BTREE | CPBTREE] INDEX <index_name> ON <table_name> (<column_name_order_entry>[{, <column_name_order_entry>}...]) [<global_index_order>]

Syntax Elements

UNIQUE

164P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 165: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Defines that a unique index should be created. A duplicates check will occur when the index is created and when a record is added to the table.

BTREE

Specifies a B+-tree index type. B+-tree uses an index tree that maintains sorted data in a way that performs efficient insertion, deletion and search of records.

CPBTREE

Specifies a CPB+-tree index type. CPB+-tree stands for Compressed Prefix B+-Tree, this index tree type is based on pkB-tree. CPB+-tree is a very small index because it uses 'partial key' that is only part of full key in index nodes. CPB+-tree shows better performance than B+-Tree for larger keys.

<index_name> ::= [<schema_name>.]<identifier> <schema_name> ::= <identifier>

The name of the index to be created, with optional schema name.

<column_name_order_entry> ::= <column_name> [<column_order>]

Specifies the columns to be used in the index, with an optional ordering.

<column_order> ::= ASC | DESC

Specifies whether the column index should be created in ascending or descending order. The default ordering is ASC.

<global_index_order> ::= ASC | DESC

Specifies the index ordering for all columns in the index.

Note<column_order> or <global_index_order> cannot be used at the same time.

Description

The CREATE INDEX statement creates an index on a table with the selected column(s).

When column data types are character string types, binary string types, decimal types, or when the constraint is a composite key, or a non-unique constraint, the default index type is CPBTREE. In other cases BTREE will be used. If neither BTREE nor CPBTREE keyword is specified, then the SAP HANA database chooses the appropriate index type.

System Views

INDEXES : Indexes currently defined on tables.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 165

Page 166: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

INDEX_COLUMNS : Index column information.

Example

You create Table t, and then add an index idx is created on column b of table t with ascending order.

CREATE TABLE t (a INT, b NVARCHAR(10), c NVARCHAR(20)); CREATE INDEX idx ON t(b);

You create a CPBTREE index idx1 on column a of table t with ascending order and column b with descending order.

CREATE CPBTREE INDEX idx1 ON t(a, b DESC);

You create a CPBTREE index idx2 on column a and c of table t with descending order.

CREATE INDEX idx2 ON t(a, c) DESC;

You create a UNIQUE CPBTREE index idx3 on column b and c of table t with ascending order.

CREATE UNIQUE INDEX idx3 ON t(b, c);

You create a UNIQUE BTREE index idx4 on column a of table t with ascending order.

CREATE UNIQUE INDEX idx4 ON t(a);

1.8.1.10 CREATE SCHEMA

Syntax

CREATE SCHEMA <schema_name> [OWNED BY <user_name>]

Syntax Elements

<schema_name> ::= <identifier> <user_name> ::= <simple_identifier>

OWNED BY

Specifies the name of the schema owner. If omitted, the current user will be the owner of the schema.

166P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 167: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Description

The CREATE SCHEMA statement creates a schema in the current database.

Example

CREATE SCHEMA my_schema OWNED BY system;

1.8.1.11 CREATE SEQUENCE

Syntax

CREATE SEQUENCE <sequence_name> [<sequence_parameter_list>] [RESET BY <subquery>]

Syntax Elements

<sequence_name> ::= [<schema_name>.]<identifier> <schema_name> ::= <identifier>

The name of the sequence to be created along, with optional schema name.

<sequence_parameter_list> ::= <sequence_parameter>[{,<sequence_parameter>}...]

Defines one or more sequence parameters.

<sequence_parameter> ::= START WITH <start_value> | INCREMENT BY <increment_value> | MAXVALUE <max_value> | NO MAXVALUE | MINVALUE <min_value> | NO MINVALUE | CYCLE | NO CYCLE | CACHE <cache_size> | NO CACHE

Sequence parameters.

START WITH <start_value> <start_value> ::= <signed_integer>

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 167

Page 168: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

The starting sequence value. If you do not specify a value for the START WITH clause, MINVALUE is used for ascending sequences and MAXVALUE is used for descending sequences.

INCREMENT BY <increment_value> <increment_value> ::= <signed_integer>

The amount the next sequence value is incremented from the last value assigned. The default is 1. You specify a negative value to generate a descending sequence. An error is returned if the INCREMENT BY value is 0.

MAXVALUE <max_value> <max_value> ::= <signed_integer>

The maximum value that can be generated by the sequence. <max_value> must be between -4611686018427387903 and 4611686018427387902.

NO MAXVALUE

When the NO MAXVALUE directive is used the maximum value for an ascending sequence will be 4611686018427387903 and the maximum value for a descending sequence will be -1.

MINVALUE <min_value> <min_value> ::= <signed_integer>

The minimum value that a sequence can generate. <min_value> must be between -4611686018427387904 and 4611686018427387902.

NO MINVALUE

When the NO MINVALUE directive is used, the minimum value for an ascending sequence is 1 and the minimum value for a descending sequence is -4611686018427387903.

CYCLE

When the CYCLE directive is used the sequence number will be restarted after it reaches its maximum or minimum value.

NO CYCLE

Default option. When the NO CYCLE directive is used the sequence number will not be restarted after it reaches its maximum or minimum value.

CACHE <cache_size> <cache_size> ::= <unsigned_integer>

The cache size with which a range of sequence numbers will be cached in a node. <cache_size> must be unsigned integer. An error is returned if the CACHE is less than 2 or greater than min(MAXVALUE - MINVALUE, 30000). 2 <= cache_size <= min(MAXVALUE - MINVALUE, 30000)

NO CACHE

Default option. When the NO CACHE directive is used, the sequence number will not be cached in a node.

RESET BY <subquery>

168P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 169: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

During the restart of the database, database automatically executes the <subquery> and the sequence value is restarted with the returned value.

NoteIf RESET BY is not specified, the sequence value is stored persistently in database. During the restart of the database, the next value of the sequence is generated from the saved sequence value.

For more information on subqueries, see Subquery

Description

The CREATE SEQUENCE statement is used to create a sequence.

A sequence is used to generate unique integers by multiple users. CURRVAL is used to get the current value of the sequence and NEXTVAL is used to get the next value of the sequence. CURRVAL is only valid after calling NEXTVAL in a session.

Example

Example 1

You create sequence seq and then use CURRVAL and NEXTVAL to get the values from the sequence.

CREATE SEQUENCE seq START WITH 11;

NEXTVAL returns 11.

SELECT seq.NEXTVAL FROM DUMMY;

CURRVAL returns 11.

SELECT seq.CURRVAL FROM DUMMY;

Example 2

You create table r and use the maximum value of column a to reset sequence s when the database is restarted.

CREATE TABLE r (a INT); CREATE SEQUENCE s RESET BY SELECT IFNULL(MAX(a), 0) + 1 FROM r; SELECT s.NEXTVAL FROM DUMMY;

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 169

Page 170: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

1.8.1.12 CREATE STATISTICS

Syntax

CREATE STATISTICS [<data_statistics_name>} ON <data_sources> <data_statistics_properties>

Syntax Element

<data_statistics_name> ::= <identifier>

A unique name for the new data statistics object.

NoteIf a name is specified, only one data source can be specified and TYPE cannot be ALL. That is to say that the data source must identify a single data statistics object.

<data_sources> ::= <table_name> [(<column_name>{, <column_name>}...)]

Data sources you wish to use for the creation of data statistics objects. If multiple columns are specified, a data statistics object is created for each data source <table_name> <column_name>.

<table_name> ::= [<schema_name>.]<identifier> <schema_name> ::= <identifier>

The table name, with optional schema name, for which statistics are to be created. For more information on schema names and identifiers, see Identifiers.

<column_name> ::= <identifier>

A table column to use as the data source.

<data_statistics_property>::= TYPE <data_statistics_type> | CONSTRAINT <constraint_param> | BUCKETS <unsigned_integer> | QERROR <numeric_literal> | QTHETA <unsigned_integer> | MEMORY <memory_bytes> | MEMORY PERCENT <memory_percentage> | PERSISTENT {ON|OFF}

Data statistics properties specifies the properties of the data statistics objects to be built from the specified data sources.

TYPE <data_statistics_type> <data_statistics_type> ::= HISTOGRAM | SIMPLE | ALL

170P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 171: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

In general, any data statistics type can be built for any data source, however some data statistics types may not be appropriate for a given data source. For example, highly volatile data sources, like a delta store, should have data statistics which can be efficiently updated when data updates occur. A data source can have only one data statistics object of a certain type: one of type HISTOGRAM, and one data statistics object of the type SIMPLE. If TYPE is not specified, both simple and histogram statistics will be created.

Default: ALL.

HISTOGRAM

The HISTOGRAM type specifies a one-dimensional data statistics object.

SIMPLE

SIMPLE specifies basic statistics, such as min, max, null count, count, distinct count.

CONSTRAINT <constraint_param> <constraint_param> ::= QOPTIMAL | MAXDIFF

The mathematical constraint used to build a histogram. This parameter can only be specified when TYPE is HISTOGRAM. Only two types of histograms are supported:

● q-optimal● maxdiff (for virtual tables)

Default: MAXDIFF for virtual tables and QOPTIMAL for other data sources.

BUCKETS <unsigned_integer>

The maximum number of data buckets to be used in the histogram. This parameter can only be specified when TYPE is HISTOGRAM.

Default: automatically determined by the histogram algorithm in use.

QERROR <numeric_literal>

The Q error used to build the q-optimal histogram. This parameter can only be specified when TYPE is HISTOGRAM, and CONSTRAINT is QOPTIMAL.

Default: automatically determined by the histogram build algorithm in use.

QTHETA <unsigned_integer>

A lower-bound on the frequencies for which a q error constraint is applied when building a q-optimal histogram. This parameter can only be specified when TYPE is HISTOGRAM, and CONSTRAINT is QOPTIMAL.

Default: automatically determined by the histogram build algorithm in use.

MEMORY PERCENT <memory_percentage> <memory_percentage> ::= <unsigned_integer>

A data statistics object can use large amount of memory for some data sources. The MEMORY parameter can used to limit the amount of memory used for data statistics objects.

<memory_percentage> is specified as percentage of the space used by the data source itself. It represents the maximum amount of memory which can be used for the data statistics object. For example, if a data source is a

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 171

Page 172: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

table column which uses 100 MB of memory, and <memory_percentage> is 5. The data statistics object for this column can use, at most, 5 MB for its memory representation.

Default: automatically determined by the histogram build algorithm in use.

MEMORY <memory_bytes> <memory_bytes> ::= <unsigned_integer>

Similar to the MEMORY PERCENT parameter above, the MEMORY parameter is used to limit the memory for data statistics objects. <memory_bytes> specifies the maximum amount of memory, in bytes, which can be used for the data statistics object.

PERSISTENT {ON|OFF}

PERSISTENT can be specified only for CREATE and ALTER STATISTICS statements when TYPE is HISTOGRAM. It specifies if the histogram data will be persistent in a system table. The simple statistics are always persistent.

Default: ON

Description

CREATE STATISTICS statement creates data statistics objects which approximate the specified <data_sources>. Data statistics objects are used to estimate the properties of the data without directly accessing the data itself. This can be useful during query optimization, query execution, etc.

Examples

You create a maxdiff histogram with a maximum 100 buckets, on the column T.X, where T is a virtual table.

CREATE STATISTICS ON T (X) TYPE HISTOGRAM BUCKETS 100

You create a q-optimal histogram for each partition of MAIN store with a maximum 1000 buckets on the column T.X, where T is a column-store table. The QERROR that is not specified will be determined by the histogram build algorithm.

CREATE STATISTICS ON T (X) TYPE HISTOGRAM BUCKETS 1000

You create a q-optimal histogram for each partition of MAIN store on the column T.X, where T is a column-store table. The QERROR and BUCKETS that are not specified will be determined by the histogram build algorithm. You specify the name of this data as "HISTOGRAM_T_X".

CREATE STATISTICS "HISTOGRAM_T_X" ON T (X) TYPE HISTOGRAM

172P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 173: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

1.8.1.13 CREATE SYNONYM

Syntax

CREATE [PUBLIC] SYNONYM <synonym_name> FOR <object_name>

Syntax Elements

<synonym_name> ::= [<schema_name>.]<identifier> <schema_name> ::= <identifier>

The name of the synonym to be created, with optional schema name.

<object_name> ::= <table_name> | <view_name> | <procedure_name> | <sequence_name>

<table_name> ::= [<schema_name>.]<identifier> <view_name> ::= [<schema_name>.]<identifier> <sequence_name> ::= [<schema_name>.]<identifier> <procedure_name> ::= [<schema_name>.]<identifier> <schema_name> ::= <identifier>

Description

The CREATE SYNONYM statement creates an alternate name for a table, view, procedure or sequence.

You can use a synonym to re-point functions and stored procedures to differing tables, views or sequences without needing to re-write the function or stored procedure.

The optional PUBLIC element allows for the creation of a public synonym. A public synonym can be accessed by any users, but the users that have proper privilege on its base object can access the base object.

Example

You create table A.

CREATE TABLE A (A INT PRIMARY KEY, B INT);

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 173

Page 174: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

You create a synonym for table A, a_synonym.

CREATE SYNONYM a_synonym FOR A;

1.8.1.14 CREATE TABLE

Syntax

CREATE [<table_type>] TABLE <table_name> <table_contents_source> [<logging_option>] [<auto_merge_option>] [<unload_priority_clause>] [<schema_flexibility_option>] [<partition_clause>] [<location_clause>] | CREATE VIRTUAL TABLE <table_name> <remote_location_clause>

Syntax elements:

<table_type>

<table_contents_source>

<logging_option>

<auto_merge_option>

<unload_priority_clause>

<schema_flexibility_option>

<partition_clause>

<location_clause>

<remote_location_clause>

Syntax Elements

<table_type>

<table_type> ::= COLUMN | ROW | HISTORY COLUMN | GLOBAL TEMPORARY | LOCAL TEMPORARY

Defines the type of table storage organization. The default value is ROW.

ROW, COLUMN

174P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 175: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

If the majority of table access will be through a large number of tuples, with only a few selected attributes, COLUMN-based storage should be used. If the majority of table access involves selecting a few records, with all attributes selected, ROW-based storage is preferable. The SAP HANA database uses a combination of table types to enable storage and interpretation in both ROW and COLUMN forms.

HISTORY COLUMN

Creates a table with a particular transaction session type called 'HISTORY'. Tables with session type HISTORY support time travel queries. Time travel queries are queries against historical states of the database.

For more information on utilizing history time travel please see: HISTORY time travel

GLOBAL TEMPORARY

Table definition is globally available while data is visible only to the current session. The table is truncated at the end of the session.

Metadata in a global temporary table is persistent meaning the metadata exists until the table is dropped and the metadata is shared across sessions. Data in a global temporary table is session-specific meaning only the owner session of the global temporary table is allowed to insert/read/truncate the data, exists for the duration of the session and data from the global temporary table is automatically dropped when the session is terminated. Global temporary table can be dropped only when the table does not have any record in it.

Supported operations on Global Temporary Table:

1. Create with or without a primary key2. Rename table3. Rename column4. Truncate5. Drop6. Create or Drop view on top of global temporary table7. Create synonym8. Select9. Select into or Insert10. Delete11. Update12. Upsert or Replace

LOCAL TEMPORARY

The table definition and data is visible only to the current session. The table is truncated at the end of the session.

Metadata exists for the duration of the session and is session-specific meaning only the owner session of the local temporary table is allowed to see. Data in a local temporary table is session-specific meaning only the owner session of the local temporary table is allowed to insert/read/truncate the data, exists for the duration of the session and data from the local temporary table is automatically dropped when the session is terminated.

Supported operations on Local Temporary Table:

1. Create without a primary key2. Truncate

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 175

Page 176: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

3. Drop4. Select5. Select into or Insert6. Delete7. Update8. Upsert or Replace

VIRTUAL

Creates a virtual table based on an existing table/view inside a remote source. For more information on remote source, see CREATE REMOTE SOURCE

<table_name> ::= [<schema_name>.]<identifier> <schema_name> ::= <identifier>

For more information on schema names and identifiers, see Identifiers.

<table_contents_source>

<table_contents_source> ::= (<table_element>, ...) | <like_table_clause> | [(<column_name>, ...)] <as_table_subquery>

You can create a table in the following ways:

● Describing the table elements, see below.● Basing the new table like an existing table, see CREATE TABLE LIKE.● From the result of a subquery, see CREATE TABLE AS <subquery>.

<table_element> ::= <column_definition> [<column_constraint>] | <table_constraint>

Defines a table column with associated column or table constraint.

For column constraint please see column constraint.

For table constraint please see table constraint.

<column_definition> ::= <column_name> {<data_type> | <lob_data_type>} [<column_store_data_type>] [<ddic_data_type>] [DEFAULT <default_value>] [GENERATED ALWAYS AS <expression>] [<schema_flexibility>] [<fuzzy_search_index>] [<fuzzy_search_mode>] [<load_unit>]

Defines a table column.

<column_name> ::= <identifier>

The table column name.

<data_type> ::= DATE | TIME | SECONDDATE | TIMESTAMP | TINYINT | SMALLINT | INTEGER | BIGINT | SMALLDECIMAL | DECIMAL

9

10

176P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 177: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

| REAL | DOUBLE | VARCHAR | NVARCHAR | ALPHANUM | SHORTTEXT | VARBINARY | TEXT

<lob_data_type> ::= <lob_type_name> [MEMORY THRESHOLD <memory_threshold_value>] <lob_type_name> ::= BLOB | CLOB | NCLOB

<column_store_data_type> ::= CS_ALPHANUM | CS_INT | CS_FIXED | CS_FLOAT | CS_DOUBLE | CS_DECIMAL_FLOAT | CS_FIXED(p-s, s) | CS_SDFLOAT | CS_STRING | CS_UNITEDECFLOAT | CS_DATE | CS_TIME | CS_FIXEDSTRING | CS_RAW | CS_DAYDATE | CS_SECONDTIME | CS_LONGDATE | CS_SECONDDATE

<ddic_data_type> ::= DDIC_ACCP | DDIC_ALNM | DDIC_CHAR | DDIC_CDAY | DDIC_CLNT | DDIC_CUKY | DDIC_CURR | DDIC_D16D | DDIC_D34D | DDIC_D16R | DDIC_D34R | DDIC_D16S | DDIC_D34S | DDIC_DATS | DDIC_DAY | DDIC_DEC | DDIC_FLTP | DDIC_GUID | DDIC_INT1 | DDIC_INT2 | DDIC_INT4 | DDIC_INT8 | DDIC_LANG | DDIC_LCHR | DDIC_MIN | DDIC_MON | DDIC_LRAW | DDIC_NUMC | DDIC_PREC | DDIC_QUAN | DDIC_RAW | DDIC_RSTR | DDIC_SEC | DDIC_SRST | DDIC_SSTR | DDIC_STRG | DDIC_STXT | DDIC_TIMS | DDIC_UNIT | DDIC_UTCM | DDIC_UTCL | DDIC_UTCS | DDIC_TEXT | DDIC_VARC | DDIC_WEEK

The available data types. Please see Data Types.

<memory_threshold_value> ::= <unsigned_integer> | NULL

Controls if LOB data should be stored in memory or not according to the following conditions:

● If <memory_threshold_value> is not provided, lob is stored in memory by default.● If <memory_threshold_value> is provided and its LOB size is bigger than memory threshold value, LOB data is

stored on disk.● If <memory_threshold_value> is provided and its LOB size is equal or less than memory threshold value, LOB

data is stored in memory.● If <memory_threshold_value> is NULL, all LOB data is stored in memory.● If <memory_threshold_value> is 0, all LOB data is stored in disk.

DEFAULT <default_value> ::= NULL | <string_literal> | <signed_numeric_literal> | <unsigned_numeric_literal> | <datetime_value_function> <datetime_value_function> ::= CURRENT_DATE | CURRENT_TIME | CURRENT_TIMESTAMP

Specifies a value to be assigned to the column if an INSERT statement does not provide a value for the column.

GENERATED ALWAYS AS <expression>

Specifies the expression to generate the column value in runtime. There are the following limitations of generated columns:

● Generated columns are not supported for row table.● Generated columns can reference only columns which are defined prior to it (left of its own definition in the

DDL).● Generated columns can reference only base columns; They cannot reference generated columns.● Specifying default values on generated columns is not possible.● Generated columns cannot be as part of a primary key or a unique constraint.● Dropping base columns of generated columns is not possible.

LOB DATA TYPE in column definition

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 177

Page 178: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Avaliable lob data types are BLOB, CLOB and NCLOB.

If MEMORY THRESHOLD option is not given, lob is stored in memory as default.

If MEMORY THRESHOLD is given and its LOB size is bigger than memory threshold value, LOB data is stored in disk. If MEMORY THRESHOLD is given and its LOB size is equal or less than memory threshold value, LOB data is stored in memory. If memory threshold is NULL, all LOB data is stored in memory. If memory threshold is 0, all LOB data is stored in disk.

<schema_flexibility> ::= {ENABLE | DISABLE} SCHEMA FLEXIBILITY

Specifies the column is dynamic:

● ENABLE produces a dynamic column.● DISABLE (default value) produces a static column.

<fuzzy_search_index> ::= FUZZY SEARCH INDEX {ON | OFF}

Turns a fuzzy search index on or off. OFF is the default.

<fuzzy_search_mode> ::= FUZZY SEARCH MODE [<string_literal> | NULL]

Sets the fuzzy search mode with the value of <string_literal>. If NULL is specified, the fuzzy search mode is reset.

<load_unit> ::= {PAGE | COLUMN} LOADABLE

Specifies the unit of column data loading is page. Default unit is column for column table, and table for row table.

<column_constraint> ::= NULL | NOT NULL | <unique_specification> | <references_specification>

The column constraint rules.

For NULL, NOT NULL and <unique_specification>, see below.

For <references_specification>, see References Specification

NULL

If NULL is specified it is not considered a constraint, it represents that a column that may contain a null value. The default is NULL.

NOT NULL

The NOT NULL constraint prohibits a column value from being NULL.

11

178P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 179: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

<unique_specification> ::= UNIQUE [<unique_tree_type_index>] | PRIMARY KEY [<unique_tree_type_index> | <unique_inverted_type_index>]

Specifies unique constraints. If the index type is omitted, the SAP HANA database chooses the appropriate index by considering the column data type. If the index type is not specified, the SAP HANA database will automatically select an index type as follows:

Index type Criteria

CPBTREE - character string types.

- binary string types.

- decimal types.

- when the constraint is a composite key.

- when the constraint is a non-unique constraint

BTREE All other cases than specified for CPBTREE

UNIQUE

Specifies a column as a unique key.

A composite unique key enables the specification of multiple columns as a unique key. With a unique constraint, multiple rows cannot have the same value in the same column.

PRIMARY KEY

A primary key constraint is a combination of a NOT NULL constraint and a UNIQUE constraint. It prohibits multiple rows from having the same value in the same column.

<unique_tree_type_index> ::= BTREE | CPBTREE;

Specifies the index type.

BTREE

BTREE specifies a B+-tree index. B+-tree is a tree that maintains sorted data which performs efficient insertion, deletion and search of records.

CPBTREE

CPBTREE specifies a CPB+-tree index. CPB+-tree stands for Compressed Prefix B+-Tree, which is based on pkB-tree. CPB+-tree is a very small index because it uses 'partial key' that is only part of full key in index nodes. CPB+-tree shows better performance than B+-Tree for larger keys.

12

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 179

Page 180: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

<unique_inverted_type_index> ::= INVERTED [<composite_type>]

<composite_type> ::= HASH | VALUE

Specifies the inverted index type.

INVERTED HASH

Specifies that a hash should be used to encode the composite key in a condensed manner. This allows for faster equality queries over the composite keys as well as reduced memory requirements for storage of the composite key.

HASH should not be used as a composite type in cases where range queries or similarity queries on the composite keys are a signficant part of the workload. In these cases VALUE or VALUE COMPRESSED should be used instead.

INVERTED VALUE

VALUE is the default composite key type.

<table_constraint> ::= <unique_constraint_definition> | <referential_constraint_definition>

The table constraint can be either a unique constraint or a referential constraint.

<unique_constraint_definition> ::= <unique_specification> (<unique_column_name_list>)

The unique specification see Unique specifcation

<unique_column_name_list> ::= <unique_column_name>[{, <unique_column_name>}...]

Speicfies the unique column name list which can have one or more column names.

<unique_column_name> ::= <identifier>

A column name identifier.

<referential_constraint_definition> ::= FOREIGN KEY (<referencing_column_name_list>) <references_specification>

Specifies a referential constraint.

<referencing_column_name_list> ::= <referencing_column_name>[{, <referencing_column_name>}...]

Specifies the referencing column name list which can have one or more column names.

<referencing_column_name> ::= <identifier>

The identifier of a referencing column.

13

180P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 181: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

<references_specification> ::= REFERENCES <referenced_table> [(<referenced_column_name_list>)] [<referential_triggered_action>]

Specifies the referenced table, with optional column name list and trigger action. If <referenced_column_name_list> is specified, there will be one-to-one correspondence between <column_name> of <column_definition> (see column defintion) and <referenced_column_name>. If it is not specified, there will be one-to-one correspondence between <column_name> of <column_definition> and the column name of the referenced table's primary key.

<referenced_column_name_list> ::= <referenced_column_name>[{, <referenced_column_name>}...]

Specifies the referenced column name list, which can have one or more column names.

<referenced_table> ::= <identifier>

The identifier of a table to be referenced.

<referenced_column_name> ::= <identifier>

The identifier of the column name to be referenced.

<referential_triggered_action> ::= <update_rule> [<delete_rule>] | <delete_rule> [<update_rule>]

Specifies an update rule with optional delete rule or a delete rule with optional update rule. The order in which they are provided provides an order of precedence for execution.

<update_rule> ::= ON UPDATE <referential_action> <referential_action> ::= CASCADE | RESTRICT | SET DEFAULT | SET NULL

The following UPDATE referential actions are possible:

Action Name Update Action

RESTRICT Any updates to a referenced table are prohibited if there are any matched records in the referencing table. This is the default action.

CASCADE If a record is updated in the referenced table, the corresponding records in the referencing table are also updated with the same values.

SET NULL If a record is updated in the referenced table, the corresponding records in the referencing table are also updated with null values.

14

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 181

Page 182: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Action Name Update Action

SET DEFAULT If a record is updated in the referenced table, the corresponding records in the referencing table are also updated with their default values

<delete_rule> ::= ON DELETE <referential_action>

The following DELETE referential actions are possible:

Action Name Delete Action

RESTRICT Any deletions to a referenced table are prohibited if there are any matched records in the referencing table. This is the default action.

CASCADE If a record in the referenced table is deleted, the corresponding records in the referencing table are also deleted.

SET NULL If a record in the referenced table is deleted, the corresponding records in the referencing table are set to null.

SET DEFAULT If a record in the referenced table is deleted, the corresponding records in the referencing table are set to their default values.

<like_table_clause> ::= LIKE <like_table_name> [WITH [NO] DATA] [<like_without_option>]

Creates a table that has the same definition as like_table_name, unless corresponding property or WITHOUT option is specified. All the column definitions with constraints, default values and other properties such as generated column, schema flexibility, etc are copied from the table <like_table_name>. All table constraints, indexes, fulltext indexes and table location are also copied.

<like_table_name> ::= <table_name> <table_name> ::= <identifier>

The identifier of the table that will be duplicated.

WITH [NO] DATA

15

182P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 183: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

The WITH DATA option specifies that data is copied from the <like_table_name> table. The default value of WITH NO DATA does not copy the table data.

<like_without_option> ::= WITHOUT AUTO MERGE | WITHOUT HISTORY | WITHOUT NO LOGGING | WITHOUT PARTITION | WITHOUT SCHEMA FLEXIBILITY | WITHOUT UNLOAD | WITHOUT PRELOAD | WITHOUT UNLOAD PRIORITY | WITHOUT INDEX | WITHOUT FUZZY SEARCH INDEX | WITHOUT FUZZY SEARCH MODE | WITHOUT GLOBAL TEMPORARY | WITHOUT LOCAL TEMPORARY

Specifies which properties will not be copied from the <like_table_name> table. For example when WITHOUT PARTITION is specified, the table will not be partitioned.

<as_table_subquery> ::= AS (<subquery>) [WITH [NO] DATA]

Creates a table and fills it with the data computed by the <subquery> (See sql_subquery). Only NOT NULL constraints are copied by this clause. If column_names are specified, specified column_names override the column names from <subquery>.

WITH [NO] DATA

The WITH DATA option specifies that data is copied from <subquery>. The default is WITH DATA. WITH NO DATA option does not copy the data from <subquery>.

<logging_option>

<logging_option> ::= LOGGING | NO LOGGING [RETENTION <retention_period>]

Specifies logging options for the created table.

LOGGING

Specifies that table logging is activated. This is the default logging option.

NO LOGGING

Specifies that logging is deactivated. A NO LOGGING table means that the definition of the table is persistent and globally available, data is temporary and global.

RETENTION <retention_period> <retention_period> ::= <unsigned_integer>

Specifies the retention time in seconds of the column table created by NO LOGGING. After the specified retention period has elapsed, the table will be dropped if used physical memory of the host is above 80%.

<auto_merge_option>

<auto_merge_option> ::= [NO] AUTO MERGE

AUTO MERGE (default value) specifies that automatic delta merge is triggered. NO AUTO MERGE disables automatic delta merging.

16

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 183

Page 184: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

<unload_priority_clause>

<unload_priority_clause> ::= UNLOAD PRIORITY <unload_priority>

UNLOAD PRIORITY specifies that priority of table to be unloaded from memory.

<unload_priority> ::= <digit>

<unload_priority> can be 0 ~ 9, where 0 means not-unloadable and 9 means earliest unload.

<schema_flexibility_option>

<schema_flexibility_option> ::= WITH SCHEMA FLEXIBILITY

Specifies that the table schema is flexible.

<partition_clause>

<partition_clause> ::= PARTITION BY <hash_partition> [, <range_partition> | , <hash_partition>] | PARTITION BY <range_partition> | PARTITION BY <roundrobin_partition> [,<range_partition>]

The PARTITION BY option partitions a table using the selected rules.

For more information about partitioning please see the "Table Partitioning in the SAP HANA database" section in the "SAP HANA Administration guide" available from the SAP HANA Appliance page.

<hash_partition> ::= HASH (<partition_expression> [{<partition_expression>,}...]) PARTITIONS {<num_partitions> | GET_NUM_SERVERS()}

Partitions the created table using a hash partitioning scheme.

<range_partition> ::= RANGE (<partition_expression>) (<range_spec>, ...)

Partitions the created table using a range partitioning scheme.

<roundrobin_partition> ::= ROUNDROBIN PARTITIONS {<num_partitions> | GET_NUM_SERVERS()} [, <range_partition>]

Partitions the created table using a round robin partitioning scheme.

GET_NUM_SERVERS()

Returns the number of servers available in the partitioning cluster.

<range_spec> ::= {<from_to_spec> | <single_spec>} [{{<from_to_spec> | <single_spec>},} ...] [, PARTITION OTHERS]

The range specifier for a partition.

<from_to_spec> ::= PARTITION <lower_value> <= VALUES < <upper_value>

Specifies a partition using lower and upper values of a <partition_expression>.

<single_spec> ::= PARTITION VALUE = <target_value>

184P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 185: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Specifies a partition using a single value of a <partition_expression>.

PARTITION OTHERS

Specifies that all other values that are not covered by the partition specification will be gathered into one partition.

<partition_expression> ::= <column_name> | YEAR(<column_name>) | MONTH(<column_name>)

The specifier used to segregate data into partitions.

<lower_value> ::= <string_literal> | <numeric_literal>

The lower value of a partition specifier.

<upper_value> ::= <string_literal> | <numeric_literal>

The upper value of a partition specifier.

<target_value> ::= <string_literal> | <numeric_literal>

The target value of a single partition specifier.

<num_partitions> ::= <unsigned_integer>

The number of partitions to be created for the table.

<location_clause>

<location_clause> ::= AT [LOCATION] {'<host>:<port>' | ('<host>:<port>', ...)} <host> ::= <string_literal> <port> ::= <unsigned_integer>

It is possible to determine the index servers on which the partitions are created. If you specify the LOCATION, the partitions will be created on these instances using round robin scheme. Duplicates in the list will be removed. If you specify exactly the same number of instances as partitions in the partition specification, then each partition will be assigned to the respective instance in the list. All index servers in the list have to belong to the same instance.

If no locations are specified, the partitions will be created randomly. If the number of partitions matches the number of servers - for example by using GET_NUM_SERVERS() - it is ensured that multiple CREATE TABLE calls will be distributed across all servers evenly. In case of a multi-level partitioning, this applies for the number of partitions of the first level.

This mechanism is useful if several tables are to be created which have a semantic relationship to each other. A table can be created in the specified location with <host>:<port>. <location_clause> can be specified when creating partitioned tables that are distributed on multiple instances. When <location_clause> is provided without <partition_clause>, the table is created on the first location specified. If location information is not provided, the table will be automatically assigned to one node. This option can be used for both row store and column store tables in a distributed environment. Even if location is specified for a global temporary table, the table is always created in the master instance.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 185

Page 186: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

<remote_location_clause>

<remote_location_clause> ::= AT <source_name>.[<db_name>].[<owner>].<identifier> <source_name> ::= <identifier> <db_name> ::= <identifier> <owner> ::= <identifier>

Identifies a remote object (table or view) from an existing remote source. For more information on names and identifiers, see Identifiers.

Description

The CREATE TABLE statement creates a table. Tables are created without data except when <as_table_subquery> or <like_table_clause> is used along with the WITH DATA option.

The CREATE VIRTUAL TABLE is an extension of the CREATE TABLE statement. It provides a way to access an existing table/view on a remote source from an SAP HANA instance. The list of remote columns is automatically imported into the virtual table.

System Views

TABLES : Table information.

TABLE_COLUMNS : Table column information.

Examples

You create Table A that has INTEGER-type column A and B. Column A has a primary key constraint.

CREATE TABLE A (A INT PRIMARY KEY, B INT);

You create a partitioned table P1 that has DATE-type column U. Column U has a primary key constraint and is used as RANGE-partitioning column.

CREATE COLUMN TABLE P1 (U DATE PRIMARY KEY) PARTITION BY RANGE (U) (PARTITION '2010-02-03' <= VALUES < '2011-01-01', PARTITION VALUE = '2011-05-01');

You create a partitioned table P2 that has INTEGER-type column I, J and K. Column I and J make the primary key constraint and are used as HASH-partitioning column. Column K is used as a sub HASH-partitioning column.

CREATE COLUMN TABLE P2 (I INT, J INT, K INT, PRIMARY KEY(I, J)) PARTITION BY HASH (I, J) PARTITIONS 2, HASH (K) PARTITIONS 2;

You create table C1 that has the same definition as table A. Table C1 also has the same records as table A.

CREATE COLUMN TABLE C1 LIKE A WITH DATA;

186P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 187: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

You create table H1 that has the same definition as table H. Table H1 also has the same records as table H. You create a column table H2 from the definition of table H without history property and without any records.

CREATE HISTORY COLUMN TABLE H (A INT); CREATE TABLE H1 LIKE H WITH DATA; CREATE TABLE H2 LIKE H WITH NO DATA WITHOUT HISTORY;

You create table C2 that has the same column data type and NOT NULL constraint as table A without any data.

CREATE TABLE C2 AS (SELECT * FROM A) WITH NO DATA;

You create table F that has a foreign key that references column A of table R with update cascade option.

CREATE TABLE R (A INT PRIMARY KEY, B NVARCHAR(10)); CREATE TABLE F (FK INT, B NVARCHAR(10), FOREIGN KEY(FK) REFERENCES R ON UPDATE CASCADE);

You create a flexible table T.

CREATE COLUMN TABLE T(A INT) WITH SCHEMA FLEXIBILITY;

You create table T2 with fuzzy search index and a fuzzy search mode.

CREATE COLUMN TABLE T2 (KEY INT, COL1 VARCHAR(10) FUZZY SEARCH INDEX ON, COL2 NVARCHAR(10) FUZZY SEARCH MODE 'POSTCODE');

You create table T3 with page loadable columns C3, C4 and C5.

CREATE COLUMN TABLE T3 (C1 INT PRIMARY KEY, C2 DATE, C3 VARCHAR(80) PAGE LOADABLE NOT NULL, C4 VARCHAR(5000) PAGE LOADABLE, C5 VARCHAR(5000) PAGE LOADABLE NOT NULL, C6 VARCHAR(5000));

You can create a virtual table on an existing remote source.

CREATE REMOTE SOURCE S ADAPTER ASE_ODBC CONFIGURATION 'DSN=ProductionASE' WITH CREDENTIAL TYPE 'PASSWORD' USING 'user="aseuser";password="asepassword"' CREATE VIRTUAL TABLE VT AT S.db_name.owner.table_name

1.8.1.14.1 HISTORY time travel

You can utlitize the HISTORY COLUMN table type time travel feature in the following ways:

Session level time travel

A database session can be set back to a certain point-in-time. The input parameter of the statement is either a utc-timestamp or a commitid.

SET HISTORY SESSION TO UTCTIMESTAMP = <timestamp> <timestamp> ::= <string_literal>

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 187

Page 188: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

or

SET HISTORY SESSION TO COMMIT ID = <commit_id> <commit_id> ::= <unsigned_integer>

The timestamp has to be in format 'YYYY-MM-DD HH:MM:SS[.FF7]'. For more information on timestamps, see Timestamp Formats

The COMMIT ID variant of the statement takes a commitid as a parameter. The value of the commitid parameter must occur in COMMIT_ID column of the system table SYS.TRANSACTION_HISTORY, otherwise an exception will be thrown. The COMMIT ID is useful when using user defined snapshots. A user defined snapshot can be taken by simply storing the commitid which is assigned to a transaction during the commit phase. The commitid can be retrieved by executing the following query directly after a transaction commit:

SELECT LAST_COMMIT_ID FROM M_TRANSACTIONS WHERE CONNECTION_ID = CURRENT_CONNECTION;

To terminate a restored session to switch back to the current session, an explicit COMMIT or ROLLBACK has to be executed on the DB connection.

Statement level time travel

<subquery> AS OF UTCTIMESTAMP <timestamp> <subquery> AS OF COMMIT ID <commit_id>

In order to be able to relate the commitid with the commit time, a system table SYS.TRANSACTION_HISTORY is maintained which stores additional information for each transaction which commits data for history table. For detailed information on setting session-level timetravel, please refer to SET HISTORY SESSION, and for details on <subquery>, please refer to Subquery.

Note● Autocommit has to be turned off when a session should be restored (otherwise an exception will be thrown

with an appropriate error message)● Non-history tables in restored sessions always show their current snapshot● Only data query statement (select) is allowed inside restored sessions.● A history table must have a primary key● The session type can be checked from the column, SESSION_TYPE of the system table SYS.TABLES.● Update on key column is not supported.● A history table cannot be imported or exported.

188P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 189: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

1.8.1.15 CREATE TRIGGER

Syntax

CREATE TRIGGER <trigger_name> <trigger_action_time> <trigger_event_list> ON <subject_table_name> [REFERENCING <transition_list>] [<for_each_row>] BEGIN [<trigger_decl_list>] [<proc_handler_list>] <trigger_stmt_list> END

Syntax Elements

<trigger_name> ::= [<schema_name>.]<identifier> <schema_name> ::= <identifier>

The name of the trigger to be created, with optional schema name.

<subject_table_name> ::= <identifier>

The table the trigger is defined on.

For more information on identifiers, see Identifiers.

<trigger_action_time> ::= BEFORE | AFTER

When trigger action should occur.

BEFORE

Specifies that the trigger will be executed before an operation on the table.

AFTER

Specifies that the trigger will executed after an operation on the table.

<trigger_event_list> ::= <trigger_event> | <trigger_event_list> OR <trigger_event> <trigger_event> ::= INSERT | DELETE | UPDATE

The data modification command that will activate trigger action.

REFERENCING <transition_list>

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 189

Page 190: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

When a trigger transition variable is declared, the trigger can access records that are being changed by the DML executed by the trigger. For more information see Transition variable and Transition table.

<transition_list> ::= <transition> [{, <transition>}...]

One or more transition list entries.

<transition> ::= <transition_variable> | <transition_table>

A transition variable or table variable.

<transition_variable> ::= {OLD | NEW} ROW [AS] <trans_var_name> <trans_var_name> ::= <identifier>

During row level trigger execution, <trans_var_name>.<column_name> represents a single record from the corresponding column that is being changed by the DML. <column_name> is the target tables column name. Only a ROW trigger can use a transition variable.

<transition_table> ::= {OLD | NEW} TABLE [AS] <trans_tab_name> <trans_tab_name> ::= <identifier>

During statement level trigger execution, <trans_tab_name> represent records being changed by the trigger DML as a table variable. Only statement trigger can use a transition table.

OLD

You can access the old row of the DML in the trigger. This is the row that will be replaced by an update, or a deleted old row. UPDATE triggers and DELETE triggers can have OLD ROW transition variables or OLD TABLE transition table variables.

NEW

You can access the new record of the DML in the trigger. This is the row that will be inserted, or the new updated row.

UPDATE triggers and INSERT triggers can have NEW ROW transition variables or NEW TABLE transition table variables.

<for_each_row> ::= FOR EACH { ROW | STATEMENT }

Default: ROW

Defines that the trigger will be called in a row-wise or statement-wise fashion.

ROW

Specifies that a row level trigger will be used. This will be fired once for each row affected by the triggering event.

STATEMENT

Specifies that a statement level trigger will be used. This will be fired once for each triggering event.

<trigger_decl_list> ::= {DECLARE <trigger_decl>}...

190P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 191: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Trigger declaration.

<trigger_decl> ::= <trigger_var_decl> | <trigger_condition_decl>

You can declare trigger variables or trigger conditions.

Declared variable can be used scalar value assignment or referenced in a trigger SQL statement.

<trigger_var_decl> ::= <var_name> [CONSTANT] <data_type> [<not_null>] [<trigger_default_assign>] ;

Trigger variable declaration.

<var_name> ::= <identifier>

The identifier of the trigger variable.

CONSTANT

When you specify the CONSTANT keyword, you cannot change the variable during trigger execution.

<data_type> ::= DATE | TIME | SECONDDATE | TIMESTAMP | TINYINT | SMALLINT | INTEGER | BIGINT | SMALLDECIMAL | DECIMAL | REAL | DOUBLE | VARCHAR | NVARCHAR | ALPHANUM | SHORTTEXT | VARBINARY | BLOB | CLOB | NCLOB | TEXT

The datatype of the trigger variable. For more information on data types, see Data Types.

<not_null> ::= NOT NULL

Not null condition.

<trigger_default_assign> ::= DEFAULT <expression> | := <expression>

The default value of the trigger variable. For more information on expression, see Expressions.

<trigger_condition_decl> ::= <condition_name> CONDITION ; | <condition_name> CONDITION FOR <sql_error_code> ;

Condition handler declaration.

<condition_name> ::= <identifier>

A declared condition name that you can reference in an exception handler.

<sql_error_code> ::= SQL_ERROR_CODE <int_const>

Error code specification for exception handling.

<proc_handler_list> ::= {<proc_handler>}... <proc_handler> ::= DECLARE EXIT HANDLER FOR <proc_condition_value_list> <trigger_stmt>

Declares exception handlers to catch SQL exceptions.

<proc_condition_value_list> ::= <proc_condition_value> [{, <proc_condition_value>}]

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 191

Page 192: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

One or more condition values.

<proc_condition_value> ::= SQLEXCEPTION | SQLWARNING | <sql_error_code> | <condition_name>

You can use a specific error code number or condition name declared on a condition variable.

<trigger_stmt_list> ::= {<trigger_stmt>}... <trigger_stmt> ::= <proc_block> | <proc_assign> | <proc_if> | <proc_loop> | <proc_while> | <proc_for> | <proc_foreach> | <proc_signal> | <proc_resignal> | <trigger_sql>

The trigger body syntax is a subset of the procedure body syntax. For more information, see CREATE PROCEDURE.

<proc_block> ::= BEGIN [<trigger_decl_list>] [<proc_handler_list>] <trigger_stmt_list> END ;

Sections of your trigger procedures can be nested using BEGIN and END terminals.

<proc_assign> ::= <var_name> := <expression> ; <var_name> ::= <identifier>

Assign values to variables.

<proc_if> ::= IF <condition> THEN <trigger_stmt_list> [<proc_elsif_list>] [<proc_else>] END IF ;

<proc_elsif_list> ::= ELSEIF <condition> THEN <trigger_stmt_list>

<proc_else> ::= ELSE <trigger_stmt_list>

You use IF - THEN - ELSE IF to control execution flow with conditionals.

<condition> ::= <condition> OR <condition> | <condition> AND <condition> | NOT <condition> | ( <condition> ) | <predicate>

Specifies the conditions where the command should be performed. For more information on predicates, see Predicates.

<proc_loop> ::= LOOP <trigger_stmt_list> END LOOP ;

192P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 193: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

You use LOOP to repeatedly execute a set of trigger statements.

<proc_while> ::= WHILE <condition> DO <trigger_stmt_list> END WHILE ;

You use WHILE to repeatedly call a set of trigger statements while a condition is true.

<proc_for> ::= FOR <column_name> IN [<reverse>] <expression> .. <expression> DO <trigger_stmt_list> END FOR ;

You use FOR - IN loops to iterate over a set of data.

<column_name> ::= <identifier>

The name of the column where the data iteration is to occur.

<reverse> ::= REVERSE

Specifies the results should be iterated over in reverse order.

<proc_foreach> ::= FOR <column_name> AS <column_name> [<open_param_list>] DO <trigger_stmt_list> END FOR ;

You use FOR - EACH loops to iterate over all elements in a set of data.

<open_param_list> ::= ( <expr_list> ) <expr_list> ::= <expression>[{, <expression>}]

One or more input expressions to be iterated over.

<proc_signal> ::= SIGNAL <signal_value> [<set_signal_info>] ;

You use the SIGNAL statement to explicitly raise an exception from within your trigger procedures.

<proc_resignal> ::= RESIGNAL [<signal_value>] [<set_signal_info>] ;

You use the RESIGNAL statement to raise an exception on the action statement in an exception handler. If an error code is not specified, RESIGNAL will throw the caught exception.

<signal_value> ::= <signal_name> | <sql_error_code> <signal_name> ::= <identifier> <sql_error_code> ::= <unsigned_integer>

You can SIGNAL or RESIGNAL a signal name or an SQL error code.

<set_signal_info> ::= SET MESSAGE_TEXT = '<message_string>' <message_string> ::= <any_character>

You use SET MESSAGE_TEXT to deliver an error message to users when specified error is thrown during trigger execution.

<trigger_sql> ::= <select_into_stmt> | <insert_stmt> | <delete_stmt> | <update_stmt>

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 193

Page 194: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

| <replace_stmt> | <upsert_stmt>

For information on <insert_stmt>, see INSERT.

For information on <delete_stmt>, see DELETE.

For information on <update_stmt>, see UPDATE.

For information on <replace_stmt> and <upsert_stmt>, see REPLACE | UPSERT.

<select_into_stmt> ::= SELECT <select_list> INTO <var_name_list> <from_clause > [<where_clause>] [<group_by_clause>] [<having_clause>] [{<set_operator> <subquery>, ... }] [<order_by_clause>] [<limit>]

For information on <select_list>, <from_clause>, <where_clause>, <group_by_clause>, <having_clause>, <set_operator>, <subquery, <order_by_clause> and <limit> see SELECT.

<var_name_list> ::= <var_name>[{, <var_name>}] <var_name> ::= <identifier>

<var_name> is scalar variable. You can assign a selected item value to this scalar variable.

Description

The CREATE TRIGGER command defines a set of statements that are executed when a given operation (INSERT/UPDATE/DELETE) takes place on a given subject table.

A trigger is special kind of stored procedure that automatically executes when an event occurs on a given table.

Only database users having the TRIGGER privilege for the given <subject_table_name> are allowed to create a trigger for that table.

Current trigger limitations are described below:

● INSTEAD_OF trigger is not supported.● Access to the subject table that a trigger is defined on is not allowed in trigger body.● The maximum number of triggers per table and per DML is 1024. This means that a table can have maximum

1024 insert triggers, 1024 update triggers and 1024 delete triggers.● Procedure features that are not supported by trigger procedures:

○ Result set assignment to a table type.○ Exit/continue command (execution flow control).○ Cursors.○ Procedure call.○ Dynamic SQL execution.○ Return (end SQL statement execution).

194P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 195: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

System Views

TRIGGERS : Defined triggers.

Examples

Basic trigger usage

You create a table that the trigger will be created upon.

CREATE TABLE TARGET ( A INT);

You create a table that the trigger will access and modify.

CREATE TABLE SAMPLE ( A INT);

You create the following trigger.

CREATE TRIGGER TEST_TRIGGER AFTER INSERT ON TARGET FOR EACH ROW BEGIN DECLARE SAMPLE_COUNT INT; SELECT COUNT(*) INTO SAMPLE_COUNT FROM SAMPLE; IF :SAMPLE_COUNT = 0 THEN INSERT INTO SAMPLE VALUES(5); ELSEIF :SAMPLE_COUNT = 1 THEN INSERT INTO SAMPLE VALUES(6); END IF; END;

Trigger TEST_TRIGGER will be executed after any record insert execution for TARGET table.

Since SAMPLE table record count is zero at the first insert attempt, the trigger TEST_TRIGGER will insert 5 into the SAMPLE table.

On the second insertion to the TARGET table, the trigger will insert 6 into the SAMPLE table because its count is now two.

INSERT INTO TARGET VALUES (1); SELECT * FROM SAMPLE; 5 INSERT INTO TARGET VALUES (2); SELECT * FROM SAMPLE; 5 6

Trigger with AFTER UPDATE and a WHILE loop.

CREATE TABLE TARGET ( A INT); CREATE TABLE SAMPLE ( A INT); CREATE TRIGGER TEST_TRIGGER_WHILE_UPDATE AFTER UPDATE ON TARGET BEGIN DECLARE found INT := 1;

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 195

Page 196: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

DECLARE val INT := 1; WHILE :found <> 0 DO SELECT count(*) INTO found FROM sample WHERE a = :val; IF :found = 0 THEN INSERT INTO sample VALUES(:val); END IF; val := :val + 1; END WHILE; END;

Trigger with AFTER INSERT and FOR loop.

CREATE TABLE TARGET ( A INT); CREATE TABLE control_tab(id INT PRIMARY KEY, name VARCHAR(30), payment INT); CREATE TABLE message_box(message VARCHAR(200), log_time TIMESTAMP);

CREATE TRIGGER TEST_TRIGGER_FOR_INSERT AFTER INSERT ON TARGET BEGIN DECLARE v_id INT := 0; DECLARE v_name VARCHAR(20) := ''; DECLARE v_pay INT := 0; DECLARE v_msg VARCHAR(200) := ''; DELETE FROM message_box; FOR v_id IN 100 .. 103 DO SELECT name, payment INTO v_name, v_pay FROM control_tab WHERE id = :v_id; v_msg := :v_name || ' has ' || TO_CHAR(:v_pay); INSERT INTO message_box VALUES (:v_msg, CURRENT_TIMESTAMP); END FOR; END;

Trigger with EXIT HANDLER examples.

CREATE TABLE TARGET ( A INT); CREATE TABLE MYTAB (I INTEGER PRIMARY KEY); CREATE TRIGGER MYTRIG_SQLEXCEPTION AFTER INSERT ON TARGET BEGIN DECLARE EXIT HANDLER FOR SQLEXCEPTION SELECT ::SQL_ERROR_CODE, ::SQL_ERROR_MESSAGE FROM DUMMY; INSERT INTO MYTAB VALUES (1); INSERT INTO MYTAB VALUES (1); -- expected unique violation error: 301 -- not reached END; CREATE TRIGGER MYTRIG_SQL_ERROR_CODE AFTER UPDATE ON TARGET BEGIN DECLARE EXIT HANDLER FOR SQL_ERROR_CODE 301 SELECT ::SQL_ERROR_CODE, ::SQL_ERROR_MESSAGE FROM DUMMY; INSERT INTO MYTAB VALUES (1); INSERT INTO MYTAB VALUES (1); -- expected unique violation error: 301 -- not reached END; CREATE TRIGGER MYTRIG_CONDITION AFTER DELETE ON TARGET BEGIN DECLARE MYCOND CONDITION FOR SQL_ERROR_CODE 301; DECLARE EXIT HANDLER FOR MYCOND SELECT ::SQL_ERROR_CODE, ::SQL_ERROR_MESSAGE FROM DUMMY; INSERT INTO MYTAB VALUES (1);

196P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 197: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

INSERT INTO MYTAB VALUES (1); -- expected unique violation error: 301 -- not reached END;

Trigger with SIGNAL/RESIGNAL examples

CREATE TABLE TARGET ( A INT); CREATE TABLE MYTAB (I INTEGER PRIMARY KEY); CREATE TABLE MYTAB_TRIGGER_ERR (err_code INTEGER, err_msg VARCHAR(30));

CREATE TRIGGER MYTRIG_SIGNAL AFTER INSERT ON TARGET BEGIN DECLARE MYCOND CONDITION FOR SQL_ERROR_CODE 10001; DECLARE EXIT HANDLER FOR MYCOND INSERT INTO MYTAB_TRIGGER_ERR VALUES (::SQL_ERROR_CODE, ::SQL_ERROR_MESSAGE); INSERT INTO MYTAB VALUES (1); SIGNAL MYCOND SET MESSAGE_TEXT = 'my error'; -- not reached END; CREATE TRIGGER MYTRIG_RESIGNAL AFTER UPDATE ON TARGET BEGIN DECLARE MYCOND CONDITION FOR SQL_ERROR_CODE 10001; DECLARE EXIT HANDLER FOR MYCOND RESIGNAL; INSERT INTO MYTAB VALUES (1); SIGNAL MYCOND SET MESSAGE_TEXT = 'my error'; -- not reached END;

Transition variable

CREATE TABLE TARGET ( A INT, B VARCHAR(10)); CREATE TABLE SAMPLE_OLD ( A INT, B VARCHAR(10)); CREATE TABLE SAMPLE_NEW ( A INT, B VARCHAR(10)); CREATE TABLE SAMPLE ( A INT, B VARCHAR(10)); INSERT INTO TARGET VALUES ( 1, 'oldvalue'); INSERT INTO TARGET VALUES ( 2, 'oldvalue'); INSERT INTO TARGET VALUES ( 5, 'oldvalue');

CREATE TRIGGER TEST_TRIGGER_VAR_UPDATE AFTER UPDATE ON TARGET REFERENCING NEW ROW mynewrow, OLD ROW myoldrow FOR EACH ROW BEGIN INSERT INTO SAMPLE_new VALUES(:mynewrow.a, :mynewrow.b); INSERT INTO SAMPLE_old VALUES(:myoldrow.a, :myoldrow.b); INSERT INTO SAMPLE VALUES(0, 'trigger'); END;

UPDATE TARGET SET b = 'newvalue' WHERE A < 3; SELECT * FROM TARGET; 1, 'newvalue' 2, 'newvalue' 5, 'oldvalue' SELECT * FROM SAMPLE_NEW; 1, 'newvalue' 2, 'newvalue' SELECT * FROM SAMPLE_OLD; 1, 'oldvalue' 2, 'oldvalue' SELECT * FROM SAMPLE; 0, 'trigger' 0, 'trigger'

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 197

Page 198: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Transition table

CREATE TABLE TARGET ( A INT, B VARCHAR(10)); CREATE TABLE SAMPLE_OLD ( A INT, B VARCHAR(10)); CREATE TABLE SAMPLE_NEW ( A INT, B VARCHAR(10)); CREATE TABLE SAMPLE ( A INT, B VARCHAR(10)); INSERT INTO TARGET VALUES ( 1, 'oldvalue'); INSERT INTO TARGET VALUES ( 2, 'oldvalue'); INSERT INTO TARGET VALUES ( 5, 'oldvalue');

CREATE TRIGGER TEST_TRIGGER_TAB_UPDATE AFTER UPDATE ON TARGET REFERENCING NEW TABLE mynewtab, OLD TABLE myoldtab FOR EACH STATEMENT BEGIN INSERT INTO SAMPLE_new SELECT * FROM :mynewtab; INSERT INTO SAMPLE_old SELECT * FROM :myoldtab; INSERT INTO SAMPLE VALUES(0, 'trigger'); END;

UPDATE TARGET SET b = 'newvalue' WHERE A < 3; SELECT * FROM TARGET; 1, 'newvalue' 2, 'newvalue' 5, 'oldvalue' SELECT * FROM SAMPLE_NEW; 1, 'newvalue' 2, 'newvalue' SELECT * FROM SAMPLE_OLD; 1, 'oldvalue' 2, 'oldvalue' SELECT * FROM SAMPLE; 0, 'trigger'

1.8.1.16 CREATE VIEW

Syntax

CREATE VIEW <view_name> [(<column_name_list>)] AS <subquery>

Syntax Elements

<view_name> ::= [<schema_name>.]<identifier> <schema_name> ::= <identifier>

The name of the view to be created, with optional schema name.

<column_name_list> ::= <column_name>[{, <column_name>}...] <column_name> ::= <identifier>

198P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 199: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

The column names of the view. When a column name is specified along with the view name, a query result is displayed with that column name. If a column name is omitted, a query result gives an appropriate name to the column automatically.

NoteThe number of column names has to be the same as the number of columns returned from <subquery>.

Description

The CREATE VIEW statement effectively creates virtual table based on the results of an SQL statement. It is not a table in a real sense as it does not contain any data.

Update operations on views are supported if the following conditions are met:

● Each column in the view must map to the column of a single table.● If a column in a view base table has a NOT NULL constraint without default value the column must be included

in view columns so that inserts can be performed.

○ An update operation on a view is allowed without this condition.● Must not contain an aggregate or analytic function in a SELECT list. For example, the following functions are

not allowed:

○ TOP, SET, DISTINCT operator in a SELECT list.○ GROUP BY, ORDER BY clause.

● Must not contain a subquery in a SELECT list.● Must not contain a sequence value(CURRVAL, NEXTVAL).● Must not contain a column view as the base view.

NoteIf base views or tables are updatable, a view on the base views or tables can also be updatable if the above conditions are met.

Example

You create table A.

CREATE TABLE A (A INT PRIMARY KEY, B INT);

You create a view v that selects all records from table A.

CREATE VIEW v AS SELECT * FROM A;

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 199

Page 200: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

1.8.1.17 DROP AUDIT POLICY

Syntax

DROP AUDIT POLICY <policy_name>

Syntax Elements

<policy_name> ::= <identifier>

The name of the audit policy to be dropped.

Description

The DROP AUDIT POLICY statement drops an audit policy. <policy_name> must specify an existing audit policy.

Only database users having the system privilege AUDIT ADMIN are allowed to drop an audit policy. Each database user having this privilege is allowed to drop any audit policy, regardless of whether they were the audit policy creator.

Even if an audit policy is dropped, it is possible that the audit action specified in the dropped audit policy will be audited further. This happens if another audit policy is enabled that specifies the dropped audit action.

To temporarily stop auditing an audit policy, it can be disabled and does not necessarily need to be dropped.

System Views

AUDIT_POLICIES : All audit policies and their states.

M_INIFILE_CONTENTS : Configuration parameter concerning auditing.

Only database users with system privilege CATALOG READ, DATA ADMIN or INIFILE ADMIN can see any information in the M_INIFILE_CONTENTS view. For other database users this view will be empty.

200P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 201: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Example

You create the priv_audit audit policy.

CREATE AUDIT POLICY priv_audit AUDITING SUCCESSFUL GRANT PRIVILEGE, REVOKE PRIVILEGE, GRANT ROLE, REVOKE ROLE LEVEL CRITICAL;

You now drop the priv_audit audit policy created in the previous step.

DROP AUDIT POLICY priv_audit;

1.8.1.18 DROP FULLTEXT INDEX

Syntax

DROP FULLTEXT INDEX <index_name>

Syntax Elements

<index_name> ::= [<schema_name>.]<identifier> <schema_name> ::= <identifier>

The name of the fulltext index to be dropped, with optional schema name.

Description

The DROP FULLTEXT INDEX statement removes a fulltext index.

Example

You create table A and then add an index i on column b of table A.

CREATE TABLE A (a INT, b NVARCHAR(10), c NVARCHAR(20)); CREATE INDEX i ON A(b);

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 201

Page 202: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

You drop index i.

DROP FULLTEXT INDEX i;

1.8.1.19 DROP INDEX

Syntax

DROP INDEX <index_name>

Syntax Elements

<index_name> ::= [<schema_name>.]<identifier> <schema_name> ::= <identifier>

The index to be dropped, with optional schema name.

Description

The DROP INDEX statement removes an index.

System Views

INDEXES : Indexes currently defined on tables.

INDEX_COLUMNS : Index column information.

Example

You create table A and then add an index i on column b of table A.

CREATE TABLE A (a INT, b NVARCHAR(10), c NVARCHAR(20)); CREATE INDEX i ON A(b);

202P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 203: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

You drop index i.

DROP INDEX i;

1.8.1.20 DROP SCHEMA

Syntax

DROP SCHEMA <schema_name> [<drop_option>]

Syntax Elements

<schema_name> ::= <identifier>

The name of the schema to be dropped.

<drop_option> ::= CASCADE | RESTRICT

Specifies the drop option to use. When <drop_option> is not specified a non-cascaded drop will be performed. This will only drop the specified schema, dependent objects of the schema will be invalidated but not dropped.

The invalidated object can be revalidated when an object that has same schema name is created.

CASCADE

Drops the schema and dependent objects.

RESTRICT

Drops the schema only when dependent objects do not exist. If this drop option is used and a dependent object exists an error will be thrown.

Description

The DROP SCHEMA statement removes a schema.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 203

Page 204: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Example

You create schema my_schema and a table my_schema.t.

CREATE SCHEMA my_schema; CREATE TABLE my_schema.t (a INT);

You drop my_schema with a CASCADE option.

DROP SCHEMA my_schema CASCADE;

1.8.1.21 DROP SEQUENCE

Syntax

DROP SEQUENCE <sequence_name> [<drop_option>]

Syntax Elements

<sequence_name> ::= [<schema_name>.]<identifier> <schema_name> ::= <identifier>

The name of the sequence to be dropped, with optional schema name.

<drop_option> ::= CASCADE | RESTRICT

When <drop_option> is not specified a non-cascaded drop will be performed. This will only drop the specified sequence, dependent objects of the sequence will be invalidated but not dropped.

The invalidated objects can be revalidated when an object that has same schema and object name is created.

CASCADE

Drops the sequence and dependent objects.

RESTRICT

Drops the sequence only when dependent objects do not exist. If this drop option is used and a dependent object exists an error will be thrown.

204P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 205: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Description

The DROP SEQUENCE statement removes a sequence.

Example

You create a sequence seq.

CREATE SEQUENCE seq START WITH 11;

You drop the sequence seq.

DROP SEQUENCE seq;

1.8.1.22 DROP STATISTICS

Syntax

DROP STATISTICS {<data_statistics_name> | ON <data_sources> [TYPE {HISTOGRAM | SIMPLE | ALL}]}

Syntax Element

<data_statistics_name> ::= <identifier>

A unique name for the existing data statistics object to be dropped.

NoteIf a <data_statistics_name> is specified then the <data_sources> name cannot be specified at the same time.

<data_sources> ::= <table_name> [(<column_name>{, <column_name>}...)]

The data statistics objects to be dropped. If multiple columns are specified, each data statistics objects built on the data source <table_name> <column_name> will be dropped.

<table_name> ::= [<schema_name>.]<identifier> <schema_name> ::= <identifier>

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 205

Page 206: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

The table name, with optional schema name, where the statistics will be dropped. For more information on schema names and identifiers, see Identifiers.

<column_name> ::= <identifier>

The table column where the statistics will be dropped.

TYPE <data_statistics_type> <data_statistics_type> ::= HISTOGRAM | SIMPLE | ALL

The data statistics type identifies which data statistics objects are to be dropped. If TYPE is not specified, all data statistics objects on specified data sources are dropped.

Default: ALL

Description

DROP STATISTICS statement drops data statistics objects.

Example

You drop the histogram for the statistics on column T.X, where T is a virtual table.

DROP STATISTICS ON T (X) TYPE HISTOGRAM

You drop a data statistics object with the name "HISTOGRAM_T_X".

DROP STATISTICS "HISTOGRAM_T_X"

1.8.1.23 DROP SYNONYM

Syntax

DROP [PUBLIC] SYNONYM <synonym_name> [<drop_option>]

Syntax Elements

PUBLIC

206P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 207: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

When specified allows the removal of a public synonym.

<synonym_name> ::= [<schema_name>.]<identifier> <schema_name> ::= <identifier>

The name of the synonym to be dropped, with optional schema name.

<drop_option> ::= CASCADE | RESTRICT

When <drop_option> is not specified a non-cascaded drop will be performed. This will only drop the specified synonym, dependent objects of the synonym will be invalidated but not dropped.

The invalidated object can be revalidated when an object that has same schema and object name is created.

CASCADE

Drops the synonym and dependent objects.

RESTRICT

Drops the synonym only when dependent objects do not exist. If this drop option is used and a dependent object exists an error will be thrown.

Description

The DROP SYNONYM statement removes a synonym.

Example

You create a table 'a', then a synonym a_synonym and a public synonym pa_synonym for the table.

CREATE TABLE a (c INT); CREATE SYNONYM a_synonym FOR a; CREATE PUBLIC SYNONYM pa_synonym FOR a;

You drop both synonym a_synonym and public synonym pa_synonym using a non-cascaded drop in both cases.

DROP SYNONYM a_synonym; DROP PUBLIC SYNONYM pa_synonym;

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 207

Page 208: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

1.8.1.24 DROP TABLE

Syntax

DROP TABLE <table_name> [<drop_option>]

Syntax Elements

<table_name> ::= [<schema_name>.]<identifier> <schema_name> ::= <identifier>

The name of the table to be dropped, with optional schema name.

<drop_option> ::= CASCADE | RESTRICT

When <drop_option> is not specified a non-cascaded drop will be performed. This will only drop the specified table, dependent objects of the table will be invalidated but not dropped.

The invalidated objects can be revalidated when an object that has same schema and object name is created.

CASCADE

Drops the table and dependent objects.

RESTRICT

Drops the table only when dependent objects do not exist. If this drop option is used and a dependent object exists an error will be thrown.

Description

The DROP TABLE statement removes a table from the database.

System Views

TABLES : Table information.

TABLE_COLUMNS : Table column information.

208P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 209: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Example

You create table A and then drop it directly afterwards.

CREATE TABLE A(C INT); DROP TABLE A;

1.8.1.25 DROP TRIGGER

Syntax

DROP TRIGGER <trigger_name>

Syntax Elements

<trigger_name> ::= [<schema_name>.]<identifier> <schema_name> ::= <identifier>

The name of the trigger to be dropped, with optional schema name.

<drop_option> ::= CASCADE | RESTRICT

When <drop_option> is not specified a non-cascaded drop will be performed. This will only drop the specified trigger, dependent objects of the trigger will be invalidated but not dropped.

The invalidated object can be revalidated when an object that has same schema and object name is created.

CASCADE

Drops the trigger and dependent objects.

RESTRICT

Drops the trigger only when dependent objects do not exist. If this drop option is used and a dependent object exists an error will be thrown.<b

Description

The DROP TRIGGER statement deletes a trigger.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 209

Page 210: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Only database users having the TRIGGER privilege for the table on which the trigger was defined are allowed to drop a trigger for that table.

Example

You create two tables, target and sample, and a trigger called test.

CREATE TABLE target ( A INT); CREATE TABLE sample ( A INT); CREATE TRIGGER test AFTER UPDATE ON target BEGIN INSERT INTO sample VALUES(3); END;

You drop the trigger called test.

DROP TRIGGER test;

1.8.1.26 DROP VIEW

Syntax

DROP VIEW <view_name> [<drop_option>]

Syntax Elements

<view_name> ::= [<schema_name>.]<identifier> <schema_name> ::= <identifier>

The name of the view to be dropped, with optional schema name.

<drop_option> ::= CASCADE | RESTRICT

When <drop_option> is not specified a non-cascaded drop will be performed. This will only drop the specified view, dependent objects of the view will be invalidated but not dropped.

The invalidated objects can be revalidated when an object that has same schema and object name is created.

CASCADE

210P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 211: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Drops the view and dependent objects.

RESTRICT

Drops the view only when dependent objects do not exist. If this drop option is used and a dependent object exists an error will be thrown.

Description

The DROP VIEW statement removes a view from the database.

Example

You create table t, then a view v that selects all records from table t.

CREATE TABLE t (a INT); CREATE VIEW v AS SELECT * FROM t;

You drop view v from the database.

DROP VIEW v;

1.8.1.27 REFRESH STATISTICS

Syntax

REFRESH STATISTICS {<data_statistics_name> | ON <data_sources> [TYPE {HISTOGRAM | SIMPLE | ALL}]}

Syntax Element

<data_statistics_name> ::= <identifier>

A unique name for the existing data statistics object that will be refreshed.

Note

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 211

Page 212: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

If a <data_statistics_name> is specified then the <data_sources> name cannot be specified at the same time.

<data_sources> ::= <table_name> [(<column_name>{, <column_name>}...)]

The data statistics objects to be refreshed. If multiple columns are specified, each data statistics objects for the data source <table_name> <column_name> will be refreshed.

<table_name> ::= [<schema_name>.]<identifier> <schema_name> ::= <identifier>

The table name, with optional schema name, where the statistics will be refreshed. For more information on schema names and identifiers, see Identifiers.

<column_name> ::= <identifier>

The table column where the statistics will be refreshed.

TYPE <data_statistics_type> <data_statistics_type> ::= HISTOGRAM | SIMPLE | ALL

The data statistics type identifies which data statistics objects are to be refreshed. If TYPE is not specified, all data statistics objects on specified data sources will be refreshed.

Description

The REFRESH STATISTICS statement rebuilds data statistics objects which approximate the specified <data_sources>.

To use this statement, the data statistics objects must already have been created using the CREATE STATISTICS statement.

Example

You refresh histogram statistics for the column T.X, where T is a virtual table.

REFRESH STATISTICS ON T (X) TYPE HISTOGRAM

You refresh the histogram statistics for the column T.X, where T is a column-store table.

REFRESH STATISTICS ON T (X)

You refresh the histogram statistics for the column T.X, where T is a column-store table with the name "HISTOGRAM_T_X".

REFRESH STATISTICS "HISTOGRAM_T_X"

212P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 213: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

1.8.1.28 RENAME COLUMN

Syntax

RENAME COLUMN <table_name>.<old_column_name> TO <new_column_name>

Syntax Elements

<table_name> ::= <identifier>

The name of the table where the column is to be renamed.

<old_column_name> ::= <identifier> <new_column_name> ::= <identifier>

The old and new column names respectively.

Description

The RENAME COLUMN statement changes the name of a column.

For more information on identifiers, see Identifiers.

Example

You create table tab with two columns named A and B.

CREATE TABLE tab (A INT PRIMARY KEY, B INT);

You display the column names for table tab stored in the SAP HANA database.

SELECT COLUMN_NAME, POSITION FROM TABLE_COLUMNS WHERE SCHEMA_NAME = CURRENT_SCHEMA AND TABLE_NAME = 'tab' ORDER BY POSITION;

You rename column A to C.

RENAME COLUMN tab.A TO C;

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 213

Page 214: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

You display the column names for table tab after the renaming.

SELECT COLUMN_NAME, POSITION FROM TABLE_COLUMNS WHERE SCHEMA_NAME = CURRENT_SCHEMA AND TABLE_NAME = 'tab' ORDER BY POSITION;

1.8.1.29 RENAME INDEX

Syntax

RENAME INDEX <current_index_name> TO <new_index_name>

Syntax Elements

<current_index_name> ::= [<schema_name>.]<identifier> <schema_name> ::= <identifier>

The current index name, with optional schema name.

<new_index_name> ::= <identifier>

The new index name.

Description

The RENAME INDEX statement changes the name of an index.

System Views

INDEXES : Indexes currently defined on tables.

INDEX_COLUMNS : Index column information.

214P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 215: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Example

You create Table B and then index idx on column B of table B.

CREATE TABLE B (A INT PRIMARY KEY, B INT); CREATE INDEX idx on B(B);

You show the list of index names on table B using the INDEXES system table.

SELECT INDEX_NAME FROM INDEXES WHERE SCHEMA_NAME = CURRENT_SCHEMA AND TABLE_NAME = 'B';

You rename index idx to new_idx.

RENAME INDEX idx TO new_idx;

You show a list of index names on table B after the renaming has occurred.

SELECT INDEX_NAME FROM INDEXES WHERE SCHEMA_NAME = CURRENT_SCHEMA AND TABLE_NAME = 'B';

1.8.1.30 RENAME TABLE

Syntax

RENAME TABLE <current_table_name> TO <new_table_name>

Syntax Elements

<current_table_name> ::= [<schema_name>.]<identifier> <schema_name> ::= <identifier>

The current name of the table, with optional schema name.

<new_table_name> ::= <identifier>

The new name for the table.

Description

The RENAME TABLE statement changes the name of a table.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 215

Page 216: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Example

Example 1 - Renaming a table in the current schema

You create table A in the current schema.

CREATE TABLE A (A INT PRIMARY KEY, B INT);

You show a list of table names in the current schema.

SELECT TABLE_NAME FROM TABLES WHERE SCHEMA_NAME = CURRENT_SCHEMA;

You rename table A to a new name B.

RENAME TABLE A TO B;

You show a list of table names in current schema after the renaming process.

SELECT TABLE_NAME FROM TABLES WHERE SCHEMA_NAME = CURRENT_SCHEMA;

Example 2 - Renaming a table in another schema

You create schema mySchema and then create a table A in the new schema.

CREATE SCHEMA mySchema; CREATE TABLE mySchema.A (A INT PRIMARY KEY, B INT);

You show the list of table names in schema mySchema.

SELECT TABLE_NAME FROM TABLES WHERE SCHEMA_NAME = 'MYSCHEMA';

You rename table A in mySchema to B.

RENAME TABLE mySchema.A TO B;

You show a list of table names in schema mySchema after the renaming process.

SELECT TABLE_NAME FROM TABLES WHERE SCHEMA_NAME = 'MYSCHEMA';

1.8.2 Data Manipulation Statements

● DELETE● EXPLAIN PLAN● INSERT● LOAD● MERGE DELTA● REPLACE | UPSERT● SELECT● TRUNCATE TABLE

216P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 217: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

● UNLOAD● UPDATE

1.8.2.1 DELETE

Syntax

DELETE [HISTORY] FROM <table_name> [WHERE <condition>]

Syntax Elements

HISTORY

Marks the selected records of a history-table history storage for deletion.

<table_name> ::= [<schema_name>.]<identifier> <schema_name> ::= <identifier>

The table name where the deletion is to occur, with optional schema name. For more information on identifiers, see Identifiers.

WHERE <condition> <condition> ::= <condition> OR <condition> | <condition> AND <condition> | NOT <condition> | ( <condition> ) | <predicate>

Specifies the conditions where the command should be performed. For more information on predicates, see Predicates.

Description

The DELETE statement deletes records from a table where the <condition> is met. If the WHERE clause is omitted, then DELETE removes all records from a table.

When using the DELETE HISTORY command, time travel queries referencing the deleted rows may still access these rows. In order to physically delete these rows the following statements have to be executed:

ALTER SYSTEM RECLAIM VERSION SPACE; MERGE HISTORY DELTA of <table_name>;

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 217

Page 218: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

In some cases even the execution of the two statements above may not lead to physical deletion.

To check whether the rows are physically deleted, the following statement can be used:

SELECT * FROM <table_name> WHERE <condition> WITH PARAMETERS ('REQUEST_FLAGS'= ('ALLCOMMITTED','HISTORYONLY'));

NoteThe "WITH PARAMETERS ('REQUEST_FLAGS'= ('ALLCOMMITTED','HISTORYONLY'))" clause may only be used for the purpose of validating the result of using the DELETE HISTORY statement.

Examples

Example 1 - Standard delete operation.

You create a table T and insert some data.

CREATE TABLE T (KEY INT PRIMARY KEY, VAL INT); INSERT INTO T VALUES (1, 1); INSERT INTO T VALUES (2, 2); INSERT INTO T VALUES (3, 3);

You delete from table T where the key column is equal to 1;

DELETE FROM T WHERE KEY = 1;

After executing the above query the contents of table T is as follows:

KEY VAL

2 2

3 3

From this result we can see that one row was deleted.

Example 2 - History deletion.

You first create a history table and insert a value.

CREATE HISTORY COLUMN TABLE HIST(KEY INT PRIMARY KEY, VAL INT); INSERT INTO HIST VALUES (1, 1); COMMIT;

You update the row you inserted in the previous step.

UPDATE HIST SET VAL=42 WHERE KEY=1; COMMIT;

You merge in the table delta-storage with the table main-storage.

MERGE DELTA OF HIST;

218P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 219: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Assuming the merge statement has moved the updated record into the history storage of the history table, you can now delete the updated record history.

DELETE HISTORY FROM HIST WHERE KEY=1;

1.8.2.2 EXPLAIN PLAN

EXPLAIN PLAN

EXPLAIN PLAN [SET STATEMENT_NAME = <statement_name>] FOR <subquery>

Syntax Elements

<statement_name> ::= <string_literal>

The name of a specific execution plan in the output table for a given SQL statement.

<subquery>

For information on subqueries, see Subquery

Description

The EXPLAIN PLAN statement is used to evaluate the execution plan that the SAP HANA database follows to execute an SQL statement. The result of the evaluation is stored into the EXPLAIN_PLAN_TABLE view for examination.

The SQL <subquery> must be data manipulation language (DML) statement. A schema definition language statement cannot be used with EXPLAIN PLAN.

System Views

EXPLAIN_PLAN_TABLE : SQL query plan explanation results.

NoteThe EXPLAIN_PLAN_TABLE view is shared by all users.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 219

Page 220: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Example

In the EXPLAIN_PLAN_TABLE OPERATOR_NAME column:

● COLUMN SEARCH denotes the starting position of column engine operators.● ROW SEARCH denotes the starting position of row engine operators.

In the example below, the intermediate result produced by a COLUMN SEARCH (ID 10) is consumed by a ROW SEARCH (ID 7). The intermediate result produced by the ROW SEARCH (ID 7) is consumed by another COLUMN SEARCH (ID 1).

The operators below the lowest COLUMN SEARCH (ID 10) explain how the COLUMN SEARCH (ID 10) is executed.

The operators between the ROW SEARCH (ID 7) and the COLUMN SEARCH (ID 10) explain how the ROW SEARCH (ID 7) processes the intermediate result produced by the COLUMN SEARCH (ID 10).

The operators between the top COLUMN SEARCH (ID 1) and the ROW SEARCH (ID 7) explain how the top COLUMN SEARCH (ID 1) processes the intermediate result produced by the ROW SEARCH (ID 7).

OPERATOR_NAME OPERATOR_ID PARENT_OPERATOR_ID

LEVEL POSITION

COLUMN SEARCH 1 NULL 1 1

LIMIT 2 1 2 1

ORDER BY 3 2 3 1

GROUP BY 4 3 4 1

JOIN 5 4 5 1

COLUMN TABLE 6 5 6 1

ROW SEARCH 7 5 6 2

BTREE INDEX JOIN 8 7 7 1

BTREE INDEX JOIN 9 8 8 1

COLUMN SEARCH 10 9< >9 1

FILTER 11 10 10 1

COLUMN TABLE 12 11 11 1

SQL plan explanation

Here is an example query plan explanation. In the example, all tables are located on row store.

DELETE FROM explain_plan_table WHERE statement_name = 'TPC-H Q10';

EXPLAIN PLAN SET STATEMENT_NAME = 'TPC-H Q10' FOR SELECT TOP 20 c_custkey, c_name,

220P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 221: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

SUM(l_extendedprice * (1 - l_discount)) AS revenue, c_acctbal, n_name, c_address, c_phone, c_comment FROM customer, orders, lineitem, nation WHERE c_custkey = o_custkey AND l_orderkey = o_orderkey AND o_orderdate >= '1993-10-01' AND o_orderdate < ADD_MONTHS('1993-10-01',3) AND l_returnflag = 'R' AND c_nationkey = n_nationkey GROUP BY c_custkey, c_name, c_acctbal, c_phone, n_name, c_address, c_comment ORDER BY revenue DESC;

SELECT operator_name, operator_details, table_name FROM explain_plan_table WHERE statement_name = 'TPC-H Q10';

The following table contains the plan explanation of the query.

OPERATOR_NAME OPERATOR_DETAILS TABLE_NAME

ROW SEARCH CUSTOMER.C_CUSTKEY, CUSTOMER.C_NAME, SUM(LINEITEM.L_EXTENDEDPRICE * (1 - LINEITEM.L_DISCOUNT)), CUSTOMER.C_ACCTBAL, NATION.N_NAME, CUSTOMER.C_ADDRESS, CUSTOMER.C_PHONE, CUSTOMER.C_ COMMENT

None

LIMIT NUM RECORDS: 20

ORDER BY SUM(LINEITEM.L_EXTENDEDPRICE * (1 - LINEITEM.L_DISCOUNT)) DESC

None

MERGE AGGREGATION NUM PARTITIONS: 4 None

GROUP BY GROUPING: NATION.N_NAME, R_CUSTOMER.C_CUSTKEY, AGGREGATION:

None

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 221

Page 222: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

OPERATOR_NAME OPERATOR_DETAILS TABLE_NAME

SUM(LINEITEM.L_EXTENDEDPRICE * (1 - LINEITEM.L_DISCOUNT))

CPBTREE INDEX JOIN INDEX NAME: _SYS_TREE_RS_279_#0_#P0,

INDEX CONDITION: ORDERS.O_ORDERKEY = LINEITEM.L_ORDERKEY,

INDEX FILTER: 'R' = LINEITEM.L_RETURNFLAG

LINEITEM

BTREE INDEX JOIN INDEX NAME: _SYS_TREE_RS_285_#0_#P0,

INDEX CONDITION: CUSTOMER.C_NATIONKEY = NATION.N_NATIONKEY

NATION

BTREE INDEX JOIN INDEX NAME: _SYS_TREE_RS_283_#0_#P0,

INDEX CONDITION: ORDERS.O_CUSTKEY = CUSTOMER.C_CUSTKEY

CUSTOMER

TABLE SCAN FILTER CONDITION: ORDERS.O_ORDERDATE < '1994-01-01' AND ORDERS.O_ORDERDATE >= '1993-10-01'

ORDERS

From this plan result we can obtain the following facts about this query:

● TABLE SCAN will be executed on ORDERS with the FILTER CONDITION.● BTREE INDEX JOIN will be executed with the B-tree index of CUSTOMER and the result of the TABLE SCAN

below.● BTREE INDEX JOIN will be executed with the B-tree index of NATION and the result of the BTREE INDEX JOIN

below.● CPBTREE INDEX JOIN will be executed with the CPB-tree index of LINEITEM and the result of the BTREE

INDEX JOIN below.● GROUP BY will be executed with the result of the CPBTREE INDEX JOIN below, with 4 threads.● MERGE AGGREGATION will be executed with the result of the GROUP BY below.

222P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 223: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

1.8.2.3 INSERT

Syntax

INSERT INTO <table_name> [ <column_list_clause> ] { <value_list_clause> | <subquery> }

Syntax Elements

<table_name> ::= [ <schema_name>. ]<identifier> <schema_name> ::= <identifier>

The table where the insert is to be performed, with optional schema name.

<column_list_clause> ::= ( <column_name>, ... ) <column_name> ::= <identifier>

A list of column identifiers, ordered in the order of values in the <value_list_clause> or <subquery>. If the column list is omitted, the database performs the insert using all the columns in the table. A column which is not included in the column list will be filled using the columns default value. For more information on identifiers, see Identifiers.

<value_list_clause> ::= VALUES ( <expression>, ... )

A list of values, or expressions evaluating to values, that will be inserted into the table. For descriptions on expressions, please refer to Expressions.

<subquery>

For information on subqueries, see Subquery

Description

The INSERT statement adds a record to a table. The values to be inserted can either be values, expressions or the result of a subquery. If the subquery used does not return any records, then the database will not insert any records into the table.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 223

Page 224: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Example

You create table T:

CREATE TABLE T (KEY INT PRIMARY KEY, VAL1 INT, VAL2 NVARCHAR(20));

You insert a row into table T.

INSERT INTO T VALUES (1, 1, 'The first');

KEY VAL1 VAL2

1 1 The first

You insert a new row into table T using column list to specify which columns should receive the input values.

INSERT INTO T (KEY, VAL2) VALUES (2,3);

KEY VAL1 VAL2

1 1 The first

2 0 NULL

You insert a row into table T using a subquery.

INSERT INTO T SELECT 3, 3, 'The third' FROM DUMMY;

KEY VAL1 VAL2

1 1 The first

2 0 3

3 3 The third

1.8.2.4 LOAD

Syntax

LOAD <table_name> [HISTORY] {DELTA | ALL | (<column_name>, ...)}

224P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 225: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Syntax Elements

<table_name> ::= [<schema_name>.]<identifier> <schema_name>::= <identifier>

The name of the table to be loaded into memory, with optional schema name.

HISTORY

You can use the HISTORY option when <table_name> is the name of a history table. The default operation of the LOAD command loads the current state of the given table into memory. If you explicitly require the table history to be loaded into memory, a separate LOAD statement with the HISTORY option enabled has to be executed. So to load a history completely into memory, two LOAD statements have to be executed, with and without HISTORY option enabled.

NoteIf you do not explicitly load table history into memory the SAP HANA database will automatically load this data upon first access.

DELTA

DELTA specifies that the delta part of a column store table is loaded into memory. As the column store is read optimized and compressed, deltas are used to optimize insert or update operations.

ALL

ALL current data of the column store table, including its delta, is loaded into memory.

NoteThis option will not load the table history.

<column_name> ::= <identifier>

The name of the column to be loaded into memory.

Description

The LOAD statement explicitly loads column store table data into memory instead of upon first access.

A LOAD statement without HISTORY option only loads the current table data and the table delta into memory, but not the history-delta and history-main.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 225

Page 226: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

System Views

M_CS_TABLES : Current table load status.

Examples

You create column table A.

CREATE COLUMN TABLE A (A INT, B INT);

You load table A into memory.

LOAD A all;

You load the columns A and B of table A into memory.

LOAD A (A,B);

You query the load status of table A using the m_cs_tables monitoring view.

select loaded from m_cs_tables where table_name = 'A'

1.8.2.5 MERGE DELTA

Syntax

MERGE [HISTORY] DELTA OF <table_name> [PART n] [WITH PARAMETERS (<parameter_list>, ...)]

Syntax Elements

HISTORY

Merges the history-delta storage of a table into the history-main storage for column store temporal tables.

PART

Merge the delta of a specific table partition to the tables main storage.

<table_name> ::= [<schema_name>.]<identifier> <schema_name> ::= <identifier>

226P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 227: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

The table name where the delta merge will occur, with optional schema name.

<parameter_list> ::= <parameter> [{, <parameter>}...] <parameter> ::= <parameter_name> = <parameter_setting> <parameter_name> ::= 'SMART_MERGE' | 'MEMORY_MERGE' <parameter_setting> ::= 'ON' | 'OFF'

Column store-specific options are passed using the "WITH PARAMETERS" clause.

SMART_MERGE

When SMART_MERGE is ON, the database does a smart merge based on merge criteria specified in automerge section of indexserver configuration. When SMART_MERGE is OFF, smart merging is disabled.

MEMORY_MERGE

When MEMORY_MERGE is ON the SAP HANA database merges the table delta storage in memory only, it will not be persisted. When MEMORY_MERGE is OFF, memory merging is disabled.

Description

The MERGE DELTA statement merges the column store table delta storage to the tables main storage. As a column store table is read optimized and compressed deltas are introduced to optimize insert or update operations. All insertions are passed to the delta storage. At a certain point in time the delta changes to a table can be merged into the table main storage.

The UPDATE privilege on the column store table is required for performing a delta merge.

Examples

You create history column table A.

CREATE HISTORY COLUMN TABLE A(c NVARCHAR(1000)) PARTITION BY ROUNDROBIN PARTITIONS 2;

You merge the column store table delta storage to the tables main storage.

MERGE DELTA OF A;

You merge the column store table A using a smart merge.

MERGE DELTA OF A WITH PARAMETERS('SMART_MERGE' = 'ON');

You smart merge the column store table A delta storage to main storage in memory only. This merge will not be persisted to disk.

MERGE DELTA OF A WITH PARAMETERS('SMART_MERGE' = 'ON', 'MEMORY_MERGE' = 'ON');

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 227

Page 228: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

You merge table A delta storage of partition 1 to the main storage of partion 1.

MERGE DELTA OF A PART 1;

You merge table A history-delta storage into its history-main storage.

MERGE HISTORY DELTA OF A;

You merge table A partition 1 history-delta storage to its history-main storage.

MERGE HISTORY DELTA OF A PART 1;

1.8.2.6 REPLACE | UPSERT

Syntax

UPSERT <table_name> [ <column_list_clause> ] { <value_list_clause> [ WHERE <condition> | WITH PRIMARY KEY ] | <subquery> } REPLACE <table_name> [ <column_list_clause> ] { <value_list_clause> [ WHERE <condition> | WITH PRIMARY KEY ] | <subquery> }

Syntax Elements

<table_name> ::= [ <schema_name>. ]<identifier> <schema_name> ::= <identifier>

The table name where the UPSERT or REPLACE is to be performed, with optional schema name.

<column_list_clause> ::= ( <column_name>, ... ) <column_name> ::= <identifier>

A list of column identifiers, ordered in the order of values in the <value_list_clause> or <subquery>. For more information on identifiers, see Identifiers.

<value_list_clause> ::= VALUES ( <expression>, ... )

A list of values, or expressions evaluating to values, that will be inserted or updated into the table. For more information on expressions, please refer to Expressions.

WHERE <condition> <condition> ::= <condition> OR <condition> | <condition> AND <condition> | NOT <condition> | ( <condition> ) | <predicate>

228P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 229: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Specifies the conditions where the command should be performed. For more information on predicates, see Predicates.

WITH PRIMARY KEY

When specified, the primary key value in either the <value_list_clause> or the <subquery> will be used to define the row to be acted upon.

<subquery>

For information on subqueries, see Subquery

Description

The UPSERT (or REPLACE statement) either updates rows in a table or inserts new rows.

When this command is used without a subquery it functions in a similar way to the UPDATE statement. The difference with this command is that when the WHERE clause condition is false it will insert a new record into the table.

When this command is used with a table that has a PRIMARY KEY, the primary key column must be included in the column list. Columns defined with NOT NULL and without a default specification also have to be included in the column list. Columns that are not specified will be filled with a default value or NULL.

The UPSERT (or REPLACE) statement with a subquery functions like the INSERT statement. The exception with this command is that, if an existing row in the table has the same primary key value as a new row, the row will be updated with the returned record from the subquery. If the table does not have a primary key the command functions in an equivalent way to an INSERT statement, as an index cannot be used to check for row duplication.

Example

You create table T.

CREATE TABLE T (KEY INT PRIMARY KEY, VAL INT);

You insert a new value.

UPSERT T VALUES (1, 1);

KEY VAL

1 1

You insert a new value if the condition in the WHERE clause is false or update the current row values if WHERE evaluates to true.

UPSERT T VALUES (2, 2) WHERE KEY = 2;

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 229

Page 230: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

KEY VAL

1 1

2 2

You update the table row where KEY is equal to 1.

UPSERT T VALUES (1, 9) WHERE KEY = 1;

KEY VAL

1 9

2 2

You use the "WITH PRIMARY KEY" keyword to update the table using the primary key value in the VALUES clause.

UPSERT T VALUES (1, 8) WITH PRIMARY KEY;

KEY VAL

1 8

2 2

You insert values using a subquery.

UPSERT T SELECT KEY + 2, VAL FROM T;

KEY VAL

1 8

2 2

3 8

4 2

230P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 231: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

1.8.2.7 SELECT

Syntax

<select_statement> ::= <subquery> [ <for_update> | <time_travel> ] | ( <subquery> ) [ <for_update> | <time_travel> ] <subquery> ::= <select_clause> <from_clause> [<where_clause>] [<group_by_clause>] [<having_clause>] [<set_operator> <subquery> [{, <set_operator> <subquery>}...]] [<order_by_clause>] [<limit>]

Syntax Elements

SELECT clause

The select clause specifies an output to be returned either to the caller or to an outer select clause if one exists.

<select_clause> ::= SELECT [TOP <unsigned_integer>] [ ALL | DISTINCT ] <select_list>

The select clause.

TOP <unsigned_integer>

Specifies that that the first <unsigned_integer> records from the SQL statement should be returned.

DISTINCT

Specifies that only one copy of each set of duplicate records selected should be returned.

ALL

Specifies that all rows selected, including all copies of duplicates should be returned. This is the default option.

<select_list> ::= <select_item>[{, <select_item>}... ]

The list of columns to be retrieved.

<select_item> ::= [<table_name>.] <asterisk> | <expression> [ AS <column_alias> ]

17

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 231

Page 232: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

The details of the column to be retrieved.

<table_name> ::= [<schema_name>.]<identifier> <schema_name> ::= <identifier>

The table name which will be the source for the selected columns, with optional schema name.

<column_alias> ::= <identifier>

The column alias used to refer to an expression.

<asterisk> ::= *

You use an asterisk (*) to select all columns from all tables or views listed in the FROM clause. If you provide a schema name or a table name with an asterisk(*), it is used to limit the scope of the result set to the specified table.

FROM clause

The from clause specifies inputs such as tables, views, and subqueries to be used in the select statement.

<from_clause> ::= FROM <table> [{, <table>}...]

The list of tables where the SELECT data is sourced from.

<table> ::= <table_name> [ [AS] <table_alias> ] | <subquery> [ [AS] <table_alias> ] | <joined_table>

The table, subquery or join which will be the data source for the query.

<table_alias> ::= <identifier>

The alias identifier for a table, subquery or joined table.

<joined_table> ::= <table> [<join_type>] JOIN <table> ON <predicate> | <table> CROSS JOIN <table> | <joined_table>

Specifies how tables should be joined.

ON <predicate>

Specifies a join predicate.

CROSS JOIN

Specifies that a cross join shoul be performed.

NoteA cross join produces the cross-product of two tables.

<join_type> ::= INNER | { LEFT | RIGHT | FULL } [OUTER]

Specifies the type of join to be performed:

● LEFT defines a left outer join.

232P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 233: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

● RIGHT defines a right outer join.● FULL indicates a full outer join.

OUTER

Specifies that an outer join should be performed.

WHERE clause

<where_clause> ::= WHERE <condition>

The WHERE clause is used to specify predicates on inputs in the FROM clause,

<condition> ::= <condition> OR <condition> | <condition> AND <condition> | NOT <condition> | ( <condition> ) | <predicate>

<predicate> ::= <comparison_predicate>| <range_preciate> | <in_predicate> | <exist_predicate> | <like_predicate> | <null_predicate> <comparison_predicate> ::= <expression> { = | != | <> | > | < | >= | <= } [ ANY | SOME | ALL ] ({<expression_list> | <subquery>}) <range_predicate> ::= <expression> [NOT] BETWEEN <expression> AND <expression> <in_predicate> ::= <expression> [NOT] IN ( { <expression_list> | <subquery> } ) <exist_predicate> ::= [NOT] EXISTS ( <subquery> ) <like_predicate> ::= <expression> [NOT] LIKE <expression> [ESCAPE <expression>] <null_predicate> ::= <expression> IS [NOT] NULL

<expression_list> ::= <expression> [{, <expression>}...]

GROUP BY clause

<group_by_clause> ::= GROUP BY { <group_by_expression_list> | <grouping_set> }

The GROUP BY clause is used to group the selected rows based on the values in the specified columns.

<group_by_expression_list> ::= <expression> [{, <expression>}...]

<grouping_set> ::= { GROUPING SETS | ROLLUP | CUBE } [BEST <signed_integer>] [LIMIT <unsigned_integer>[OFFSET <unsigned_integer>] ] [WITH SUBTOTAL] [WITH BALANCE] [WITH TOTAL] [TEXT_FILTER <filterspec> [FILL UP [SORT MATCHES TO TOP]]] [STRUCTURED RESULT [WITH OVERVIEW] [PREFIX <prefix_table_name>] | MULTIPLE RESULTSETS] ( <grouping_expression_list> )

<grouping_expression_list> ::= <grouping_expression> [{, <grouping_expression>}...]

<grouping_expression> ::= <expression> | ( <expression> [{, <expression>}...] ) | ( ( <expression> [{, <expression>}...] ) <order_by_clause> )

GROUPING SETS

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 233

Page 234: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Generates results with specified multiple groupings of data in a single statement. If no additional options, such as BEST and LIMIT, are set the result produced will be the same as a UNION ALL of the aggregation of each specified group.

For example

select col1, col2, col3, * count(*) from t group by grouping sets ( (col1, col2), (col1, col3) )

is equivalent to

select * col1, col2, NULL, count(*) from t group by col1, col2 union all select col1, NULL, * col3, count(*) from t group by col1, col3

In the grouping-sets query each of (col1, col2) and (col1, col3) specifies the grouping.

ROLLUP

Generates results with multiple levels of aggregation in a single statement.

For example

rollup (col1, col2, col3)

is equivalent to

grouping sets ( (col1, col2, col3), (col1, col2), (col1) )

with an additional aggregation without grouping. Thus, the number of grouping sets that result set contains is the number of columns in ROLLUP list plus one for a last aggregation if there is no additional option.

CUBE

Generates results with multiple levels of aggregations in a single statement.

For example

cube (col1, col2, col3)

is equivalent to

grouping sets ( (col1, col2, col3), (col1, col2), (col1, col3), (col2, col3), (col1), (col2), (col3) )

with an additional aggregation without grouping. Thus, the number of grouping sets that result set contains is the same as all possible permutations of columns in the CUBE list plus one for the last aggregation if there is no additional option.

BEST <signed_integer>

Returns only the top-n grouping sets sorted in descending order of the number of rows aggregated in each grouping set. <signed_integer> can be zero, positive, and negative. When n is zero, it is the same as the BEST option not being set. When n is negative, it means sorting in ascending order.

LIMIT <unsigned_integer> [OFFSET <unsigned_integer>]

234P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 235: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Returns the first <unsigned_integer> grouped records after skipping OFFSET<unsigned_integer> for each grouping set.

WITH SUBTOTAL

Returns an additional subtotal for each grouping set in the returned results controlled by OFFSET or LIMIT. Unless OFFSET and LIMIT are specified, the value is the same as WITH TOTAL.

WITH BALANCE

Returns for each grouping set an additional aggregated value of the remaining values not returned by OFFSET or LIMIT.

WITH TOTAL

Returns for each grouping set an additional row that is the aggregated total value. OFFSET and LIMIT options do not change this value.

TEXT_FILTER <filterspec>

Performs text filtering or highlighting on the grouping columns using a <filterspec>, which is a single-quoted string that follows the below syntax.

<filterspec> ::= '[<prefix>]<element><subsequent> [{, <subsequent>}...]' <prefix> ::= + | - | NOT <element> ::= <token> | <phrase> <token> ::= !! Unicode letters or digits <phrase> ::= !! double-quoted string that does not contain double quotations inside <subsequent> ::= [<prefix_subsequent>]<element> <prefix_subsequent> ::= + | - | NOT | AND | AND NOT | OR

A filter defined by <filterspec> is a token/phrase or tokens/phrases connected with logical operators such as AND, OR and NOT. A token matches a string that contains its corresponding word in a case-insensitive manner. For example, 'ab' matches 'ab cd' and 'cd Ab' but does not match 'abcd'. A token can contain the wildcard character '*' that matches any string and '?' that matches any character. Inside a phrase '*' and '?' do not function as wildcard characters. With tokens and phrases logical operators AND, OR and NOT can be used together. As OR is the default operator, 'ab cd' is the same as 'ab OR cd'

NoteLogical operators should be written in uppercase characters.

Prefixes '+' and '-' mean inclusion (AND) and exclusion (AND NOT), respectively. For example, 'ab -cd' is the same as 'ab AND NOT cd'. If FILL UP is not specified, only grouped records that have matching values are returned.

NoteA filter is applied only to the first grouping column in each grouping set.

FILL UP

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 235

Page 236: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Returns not only matched grouped records, but also non-matched records. TEXT_FILTER is useful to identify which records have been matched. See 'Related Functions' below.

SORT MATCHES TO TOP

Returns matching values before non-matching values for each grouping set. This option cannot be used with SUBTOTAL, BALANCE and TOTAL.

STRUCTURED RESULT

Returns results as temporary tables. For each grouping set a single temporary table is created. If the WITH OVERVIEW option is set, an additional temporary table is created for the overview of the grouping sets. The names of the temporary tables are specified by the PREFIX option.

WITH OVERVIEW

Returns an overview in a separate additional table.

PREFIX <prefix_table_name> <prefix_table_name> ::= #<identifier>

Specifies a prefix for naming the temporary tables. <prefix_table_name> must start with "#", which means a temporary table. If PREFIX is not specified, the default prefix is "#GN" followed by a nonnegative integer number. See 'Return Format' below.

MULTIPLE RESULTSETS

Specifies that results should be returned in multiple result sets.

Related Functions

● GROUPING_ID(column_name_list) function returns an integer number to identify which grouping set each grouped record belongs to. See GROUPING_ID.

● TEXT_FILTER ( <grouping_column> ) function, which is used with TEXT_FILTER, FILL UP, and SORT MATCHES TO TOP, displays matching values or NULL. NULL is displayed for non-matching values when FILL UP option is specified.

Return Format

● If neither STRUCTURED RESULT nor MULTIPLE RESULTSETS is set, the unioned result ofall grouping sets is returned, with NULL values filling up attributes that are not included in a specific grouping set.

● With STRUCTURED RESULT, temporary tables are created additionally which can be queried using "SELECT * FROM <table name>" in the same session. The name of the tables follows the form:

○ <PREFIX>0: this table will contain the overview if WITH OVERVIEW is specified○ <PREFIX>n: n-th grouping set subject to re-ordering by the BEST parameter

● With MULTIPLE RESULTSETS, multiple result sets are returned. Grouped records for each grouping set are in a single result set.

HAVING clause

<having_clause> ::= HAVING <condition>

Selects the specified groups that satisfy the predicates. If this clause is omitted, all groups are selected.

SET OPERATORS

236P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 237: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

The set operators enable multiple select statements to be combined but return only one result set.

<set_operator> ::= UNION [ ALL | DISTINCT ] | INTERSECT [DISTINCT] | EXCEPT [DISTINCT]

UNION ALL

Selects all records from all select statements. Duplicates are not removed.

UNION [DISTINCT]

Selects all unique records from all select statements by removing duplicates found from different select statements. UNION has the same function as UNION DISTINCT.

INTERSECT [DISTINCT]

Returns records that exist in all select statement results.

EXCEPT [DISTINCT]

Returns all unique records from the first select statements after removing the duplicates in the following select statements.

ORDER BY clause

<order_by_clause> ::= ORDER BY { <order_by_expression>, ... }

The ORDER BY clause is used to sort records by expressions or positions.

<order_by_expression> ::= <expression> [ ASC | DESC ] [ NULLS FIRST | NULLS LAST ] | <position> [ ASC | DESC ] [ NULLS FIRST | NULLS LAST ] <position> ::= <unsigned_integer>

<position> uses the entries in the select list to define the ordering required. For example:

SELECT col1, col2 FROM t ORDER BY 2

"ORDER BY 2" indicates that ordering should be undertaken using the second expression in the select list, which in this case is "col2".

[ ASC | DESC ]

Default: ASC ASC sorts records in ascending order. DESC sorts records in descending order.

[ NULLS FIRST | NULLS LAST ]

Specifies where in the results set NULL values should appear. 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.

LIMIT

<limit> ::= LIMIT <unsigned_integer> [ OFFSET <unsigned_integer> ]

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 237

Page 238: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Limits the number of output records. For example:

LIMIT 3 [OFFSET 5]

Returns the first 3 records after skipping 5 records.

FOR UPDATE

<for_update> ::= FOR UPDATE [OF <update_column_name_list>]

Locks the selected records so that other users cannot lock or change the records until end of this transaction.

<update_column_name_list>> ::= ( <column_name>[{, <column_name>}...] )

A list of columns is used to specify which table or view in the FROM clause should be locked. If there is only a single table or view, FOR UPDATE will suffice. However, if there are two objects (e.g., tables, views, and, subqueries), OF should be used.

NoteA table used in a subquery cannot be locked. Also that only one table/view can be currently locked.

The lock is released when the corresponding transaction is finished by commit or rollback.

create column table x ( a int, b int ); insert into x values (1,1); insert into x values (2,2); create column table y ( a int, b int ); insert into y values (1,1); insert into y values (2,2); select * from x where a=1 for update; --> OK commit; select * from x where a=1 for update of x.c; --> error because c column does not exist in table x. select * from x where a=1 for update of x.a; --> OK commit; select * from x, y where a=1 for update; --> error because "OF" is not used to specify which one of x and y is locked. select * from x, y where a=1 for update of y.b; --> OK commit; select * from x, (select * from y) where a=1 for update of y.b; --> error because y is inside subquery commit;

TIME TRAVEL

Keywords related with time travel can be used for statement-level time travel to go back to the snapshot specified by commit_id or utctimestamp.

<time_travel> ::= AS OF { { COMMIT ID <commit_id> } | { UTCTIMESTAMP <timestamp> } }

Time travel is possible only with a history column table. <commit_id> can be obtained from m_history_index_last_commit_id after each commit and its related <timestamp> can be obtained from sys.m_transaction_history.

238P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 239: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

For example:

create history column table x ( a int, b int ); // after turnning off auto commit insert into x values (1,1); commit; select last_commit_id from m_history_index_last_commit_id where session_id = current_connection; // e.g., 10 insert into x values (2,2); commit; select last_commit_id from m_history_index_last_commit_id where session_id = current_connection; // e.g., 20 delete from x; commit; select last_commit_id from m_history_index_last_commit_id where session_id = current_connection; // e.g., 30 select * from x as of commit id 30; // return nothing select * from x as of commit id 20; // return two records (1,1) and (2,2) select * from x as of commit id 10; // return one record (1,1)

select commit_time from sys.transaction_history where commit_id = 10; // e.g., '2012-01-01 01:11:11' select commit_time from sys.transaction_history where commit_id = 20; // e.g., '2012-01-01 02:22:22' select commit_time from sys.transaction_history where commit_id = 30; // e.g., '2012-01-01 03:33:33'

select * from x as of utctimestamp '2012-01-02 02:00:00'; // return one record (1,1) select * from x as of utctimestamp '2012-01-03 03:00:00'; // return two records (1,1) and (2,2) select * from x as of utctimestamp '2012-01-04 04:00:00'; // return nothing

Examples

You create column table t1 and populate it with some example data.

create column table t1 ( id int primary key, customer varchar(5), year int, product varchar(5), sales int ); insert into t1 values(1, 'C1', 2009, 'P1', 100); insert into t1 values(2, 'C1', 2009, 'P2', 200); insert into t1 values(3, 'C1', 2010, 'P1', 50); insert into t1 values(4, 'C1', 2010, 'P2', 150); insert into t1 values(5, 'C2', 2009, 'P1', 200); insert into t1 values(6, 'C2', 2009, 'P2', 300); insert into t1 values(7, 'C2', 2010, 'P1', 100); insert into t1 values(8, 'C2', 2010, 'P2', 150);

Example 1 - GROUPING SETS

You use grouping sets to analyze the customer data.

NoteThe this query is equivalent to example 3 below.

select customer, year, product, sum(sales) from t1 group by GROUPING SETS

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 239

Page 240: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

( (customer, year), (customer, product) );

select customer, year, NULL, sum(sales) from t1 group by customer, year union all select customer, NULL, product, sum(sales) from t1 group by customer, product;

Observe that the two groups inside grouping sets in the first query are specified in each GROUP BY clause in the second query.

Example 2 - ROLLUP

You use ROLLUP to generates results with multiple levels of aggregation.

NoteThe following ROLLUP query is equivalent to Example 4 below.

select customer, year, sum(sales) from t1 group by ROLLUP(customer, year);

select customer, year, sum(sales) from t1 group by grouping sets ( (customer, year), (customer) ) union all select NULL, NULL, sum(sales) from t1;

Example 3 - CUBE

You use CUBE to generates results with multiple levels of aggregation.

NoteThe following CUBE query is equivalent to the query in Example 5.

select customer, year, sum(sales) from t1 group by CUBE(customer, year);

select customer, year, sum(sales) from t1 group by grouping sets ( (customer, year), (customer), (year) ) union all select NULL, NULL, sum(sales) from t1;

240P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 241: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Example 4 - BEST 1

You use BEST 1 to return only the best group of results.

select customer, year, product, sum(sales) from t1 group by grouping sets BEST 1 ( (customer, year), (product) );

In this example, 4 records exist for (customer, year) group and 2 records exist for (product) group, so the former 4 records are returned. If you used 'BEST -1' instead of 'BEST 1', the latter 2 records would be returned.

Example 5 - LIMIT

You use LIMIT 2 to limit the number of records to a maximum 2 for each group.

select customer, year, product, sum(sales) from t1 group by grouping sets LIMIT 2 ( (customer, year), (product) );

For the (customer, year) group, the number of records are 4, so only first 2 records will be returned. For the (product) group, the number of records are 2, in this case all the records will be returned.

Example 6 - WITH SUBTOTAL

you use WITH SUBTOTAL to produce an additional record for each group that displays a subtotal of returned records. These subtotal records are NULL for the customer, year, product columns and the sum of sum(sales) values in the select list.

select customer, year, product, sum(sales) from t1 group by grouping sets LIMIT 2 WITH SUBTOTAL ( (customer, year), (product) );

Example 7 - WITH BALANCE

You use WITH BALANCE to produce an additional record for each group that displays a subtotal of unreturned records.

select customer, year, product, sum(sales) from t1 group by grouping sets LIMIT 2 WITH BALANCE ( (customer, year), (product) );

Example 8 - WITH TOTAL

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 241

Page 242: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

You use WITH TOTAL to produce an additional record for each group that displays a total of all grouped records.

select customer, year, product, sum(sales) from t1 group by grouping sets LIMIT 2 WITH TOTAL ( (customer, year), (product) );

Example 9 - TEXT_FILTER

You use TEXT_FILTER to retrieve the first column of each group with a given <filterspec>. The following query will search for columns ending with '2'. This will be applied to customers for in first grouping set and products in the second. Only three matched records will be returned.

select customer, year, product, sum(sales), text_filter(customer), text_filter(product) from t1 group by grouping sets TEXT_FILTER '*2' ( (customer, year), (product) );

Example 10 - FILL UP

You use FILL UP to return both matched and non-matched records with <filterspec>. The following query returns six records whereas the previous example only returned three.

select customer, year, product, sum(sales), text_filter(customer), text_filter(product) from t1 group by grouping sets TEXT_FILTER '*2' FILL UP ( (customer, year), (product) );

Example 11 - SORT MATCHES TO TOP

SORT MATCHES TO TOP is used to raise matched records up. For each grouping set, its grouped records will be sorted.

select customer, year, product, sum(sales), text_filter(customer), text_filter(product) from t1 group by grouping sets TEXT_FILTER '*2' FILL UP SORT MATCHES TO TOP ( (customer, year), (product) );

Example 12 - STRUCTURED RESULT

You use STRUCTURED RESULT to create temporary tables, one for each grouping set and an additional table for the overview table.

select customer, year, product, sum(sales) from t1 group by grouping sets STRUCTURED RESULT

242P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 243: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

( (customer, year), (product) );

select * from "#GN1"; select * from "#GN2";

"#GN1" table is for (customer, year) grouping set and "#GN2" table is for (product) one.

NoteEach table contains only related columns. That is to say, "#GN1" table does not have "product" column and "#GN2" table does not have "customer" and "year" columns.

You use WITH OVERVIEW to create a temporary table "#GN0" for the overview table.

drop table "#G1"; drop table "#G2";

select customer, year, product, sum(sales) from t1 group by grouping sets structured result WITH OVERVIEW ( (customer, year), (product) );

select * from "#GN0"; select * from "#GN1"; select * from "#GN2";

You change the names of temporary tables by using the PREFIX keyword.

Notethe names of tables must still must start with '#' which is the prefix used for temporary tables.

select customer, year, product, sum(sales) from t1 group by grouping sets STRUCTURED RESULT WITH OVERVIEW PREFIX '#MYTAB' ( (customer, year), (product) );

select * from "#MYTAB0"; select * from "#MYTAB1"; select * from "#MYTAB2";

Temporary tables are dropped when the corresponding session is closed or when a user executes a drop command. A list of temporary tables are seen in m_temporary_tables.

select * from m_temporary_tables;

Example 13 - MULTIPLE RESULTSETS

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 243

Page 244: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

You use MULTIPLE RESULTSETS to return multiple result sets. The following query will return three result sets, one for the overview table and two for the grouping sets.

select customer, year, product, sum(sales) from t1 group by grouping sets MULTIPLE RESULTSETS ( (customer, year), (product) );

1.8.2.8 TRUNCATE TABLE

Syntax

TRUNCATE TABLE <table_name>

Syntax Elements

<table_name> ::= [<schema_name>.]<identifier> <schema_name> ::= <identifier>

The table to be truncated, with optional schema name.

Description

Deletes all rows from a table. TRUNCATE is faster than DELETE FROM when deleting all records from a table, but TRUNCATE cannot be rolled back. To be able to rollback from record deletion, DELETE should be used.

HISTORY tables can also be truncated using this command. All parts of the history table (main, delta, history main and history delta) will be truncated and the content will be permanently deleted.

Example

You create table A.

CREATE TABLE A (A INT PRIMARY KEY, B INT);

244P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 245: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

You truncate the contents of table A.

TRUNCATE TABLE A

1.8.2.9 UNLOAD

Syntax

UNLOAD <table_name>

Syntax Elements

<table_name> ::= [<schema_name>.]<identifier> <schema_name> ::= <identifier>

The name of the table to be unloaded from memory

Description

The UNLOAD statement unloads the column store table from memory. This can be done to free up memory.

The table will be loaded again on next access.

Example

You create column table A.

CREATE COLUMN TABLE A (A INT, B INT);

You load table A into memory.

LOAD A all;

You unload table A from memory.

UNLOAD A;

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 245

Page 246: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

You check the load status of table A.

select loaded from m_cs_tables where table_name = 'A'

1.8.2.10 UPDATE

Syntax

UPDATE <table_name> [<alias_name>] <set_clause> [ WHERE <condition> ]

Syntax Elements

<table_name> ::= [<schema_name>.]<identifier> <schema_name> ::= <identifier>

The table name where the UPDATE is to be performed, with optional schema name.

<alias_name> ::= [AS] <identifier>

An alias that can be used to refer to the table defined by <table_name>. For more information on identifiers, see Identifiers.

<set_clause> ::= SET {<column_name> = <expression> },...

The column names and associated values that are to be set by the update statement. For descriptions on expressions, please refer to Expressions.

WHERE <condition> <condition> ::= <condition> OR <condition> | <condition> AND <condition> | NOT <condition> | ( <condition> ) | <predicate>

Specifies the conditions where the command should be performed. For more information on predicates, see Predicates.

Description

The UPDATE statement changes the values of the records of a table.

246P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 247: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

If the WHERE condition is used and is true for a specific row, the an update is performed on that row. If the WHERE clause is omitted, the UPDATE command updates all records of a table.

Examples

You create table T, and insert two rows into it.

CREATE TABLE T (KEY INT PRIMARY KEY, VAL INT); INSERT INTO T VALUES (1, 1); INSERT INTO T VALUES (2, 2);

You update the rows of table T if the condition in the WHERE clause is true.

UPDATE T SET VAL = VAL + 1 WHERE KEY = 1;

KEY VAL

1 2

2 2

You update all rows of table T because a where clause is not specified as part of the update statement.

UPDATE T SET VAL = KEY + 10;

KEY VAL

1 11

2 12

You create table T2, and insert two rows into it.

CREATE TABLE T2 (KEY INT PRIMARY KEY, VAR INT); INSERT INTO T2 VALUES (1, 2); INSERT INTO T2 VALUES (3, 6);

You update the values of table T by joining the target table T with table T2.

UPDATE T SET VAL = T2.VAR FROM T, T2 WHERE T.KEY = T2.KEY;

KEY VAL

1 2

2 2

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 247

Page 248: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

1.8.3 System Management Statements

● ALTER SYSTEM ALTER CONFIGURATION● ALTER SYSTEM ALTER SESSION SET● ALTER SYSTEM ALTER SESSION UNSET● ALTER SYSTEM CANCEL [WORK IN] SESSION● ALTER SYSTEM CLEAR SQL PLAN CACHE● ALTER SYSTEM CLEAR TRACES● ALTER SYSTEM DISCONNECT SESSION● ALTER SYSTEM LOAD PERFTRACE● ALTER SYSTEM LOGGING● ALTER SYSTEM PERSISTENCE ENCRYPTION● ALTER SYSTEM RECLAIM DATA SPACE● ALTER SYSTEM RECLAIM DATAVOLUME● ALTER SYSTEM RECLAIM LOG● ALTER SYSTEM RECLAIM VERSION SPACE● ALTER SYSTEM RECONFIGURE SERVICE● ALTER SYSTEM REMOVE TRACES● ALTER SYSTEM RESET MONITORING VIEW● ALTER SYSTEM SAVE PERFTRACE● ALTER SYSTEM SAVEPOINT● ALTER SYSTEM START PERFTRACE● ALTER SYSTEM STOP PERFTRACE● ALTER SYSTEM STOP SERVICE● SET SYSTEM LICENSE● UNSET SYSTEM LICENSE ALL

1.8.3.1 ALTER SYSTEM ALTER CONFIGURATION

Syntax

ALTER SYSTEM ALTER CONFIGURATION (<filename>, <layer>[, <layer_name>]) {SET | UNSET} <parameter_key_value_list> [WITH RECONFIGURE]

Syntax Elements

<filename> ::= <string_literal>

248P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 249: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

The filename of the configuration file to be modified. If the file does not exist on the required layer, the file will be created when a SET command is used.

<layer> ::= <string_literal>

Sets the target layer for the configuration change. This parameter can be either 'SYSTEM' or 'HOST'. The SYSTEM layer is the recommended layer for customer settings. The HOST layer should generally only be used for minor configuration, for example parameters contained in daemon.ini.

<layer_name> ::= <string_literal>

If the layer parameter above is set to 'HOST', <layer_name> is used to target either a tenant name or a target host name. For example, 'selxeon12' would target the 'selxeon12' host.

SET

Updates the value of a key if the key already exists, or inserts a new key if required.

UNSET

Removes a key and its associated value.

<parameter_key_value_list> ::= <parameter_key_value_entry> [{, <parameter_key_value_entry>}...]

A list of configuration file entries to be modified or removed.

<parameter_key_value_entry> ::= (<section_name>,<parameter_name>) [ = <parameter_value>]

Specifies the section, key and value of the ini file parameter to be created, modified or removed.

<section_name> ::= <string_literal>

The section name of the parameter to be modified.

<parameter_name> ::= <string_literal>

The name of the parameter to be modified.

<parameter_value> ::= <string_literal>

The value of the parameter.

WITH RECONFIGURE

Specifies that the configuration changes will be directly applied to the running SAP HANA database instance.

When WITH RECONFIGURE is not specified the configuration changes will be written to the required ini file, however the modified values will not applied to the current running system. The changes will only be applied during a restart of the SAP HANA database. In this case there can be inconsistencies between the ini file contents and the actual configuration value that the SAP HANA database is currently using.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 249

Page 250: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Description

Sets or removes configuration parameters in an ini file. Ini file configuration is used for the layered configuration of DEFAULT, SYSTEM, HOST layers.

NoteThe DEFAULT layer configuration parameters cannot be changed or removed using this command.

The following is an example of ini file locations:

DEFAULT: /usr/sap/<SYSTEMNAME>/HDB<INSTANCENUMBER>/exe/config/indexserver.ini

SYSTEM: /usr/sap/<SYSTEMNAME>/SYS/global/hdb/custom/config/indexserver.ini

HOST: /usr/sap/<SYSTEMNAME>/HDB<INSTANCENUMBER>/<HOSTNAME>/indexserver.ini

The priority of the configuration layers is as follows: DEFAULT < SYSTEM < HOST.

This means that the layer that has the highest priority is the HOST layer, followed by the SYSTEM layer and finally the DEFAULT layer. The configuration with the highest priority will be applied to the running environment. If the highest priority level configuration is removed, then the configuration with the next highest priority will be applied.

System Views

M_INIFILES : Currently available ini files.

M_INIFILE_CONTENTS : Current ini file values that the SAP HANA database is using.

Example

You set a parameter new_test_value in the alt_sys_test section of the golbal.ini file.

ALTER SYSTEM ALTER CONFIGURATION ('global.ini', 'SYSTEM') SET ('alt_sys_test', 'new_test_value') = 'test';

You check the setting of the parameter in the SAP HANA studio. In the SAP HANA Systems view you right click on the system where you made the change and select Administration then select the Configuration tab. Expand the global.ini configuration file and then the alt_sys_test section.

You unset the new_test_value parameter set in the previous step.

ALTER SYSTEM ALTER CONFIGURATION ('global.ini', 'SYSTEM') UNSET ('alt_sys_test', 'new_test_value');

You check the removal of the parameter by clicking refresh on the Configuration page in the SAP HANA studio.

250P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 251: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

1.8.3.2 ALTER SYSTEM ALTER SESSION SET

Syntax

ALTER SYSTEM ALTER SESSION <session_id> SET <key> = <value>

Syntax Elements

<session_id> ::= <unsigned_integer>

The session ID of the session where the variable should be set.

<key> ::= <string_literal>

The key of a session variable. The maximum length of key is 32 characters.

<value> ::= <string_literal>

The desired value of a session variable. The maximum length of value is 512 characters.

Description

With this command you can set session variables of database sessions.

See M_SESSION_CONTEXT view for a list of predefined variables.

Session variables can be retrieved using SESSION_CONTEXT command or from M_SESSION_CONTEXT view and unset using the ALTER SYSTEM ALTER SESSION UNSET command.

Example

NotePlease run each command in this example in the same SQL Editor in the SAP HANA studio. This is because you need to use the same database session to make the example work properly.

You obtain your current session ID.

SELECT connection_id FROM m_connections WHERE OWN = 'TRUE';

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 251

Page 252: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

You set the variable MY_VAR to 'some_value' in your session. In the command below replace <your_session_id> with the session ID that you discovered from the command above.

ALTER SYSTEM ALTER SESSION <your_session_id> SET 'MY_VAR'= 'some_value';

You check the current value of MY_VAR in your session.

SELECT SESSION_CONTEXT('MY_VAR') FROM dummy;

1.8.3.3 ALTER SYSTEM ALTER SESSION UNSET

Syntax

ALTER SYSTEM ALTER SESSION <session_id> UNSET <key>

Syntax Elements

<session_id> ::= <unsigned_integer>

The session ID of the session where the variable should be unset.

<key> ::= <string_literal>

The key of a session variable. The maximum length of key is 32 characters.

Description

With this command you can unset session variables of database sessions.

See M_SESSION_CONTEXT view for a list of predefined variables.

Session variables can be retrieved using SESSION_CONTEXT function or from M_SESSION_CONTEXT view.

Example

You set the session variable MY_VAR to 'abc' in your database session.

SET 'MY_VAR' = 'abc';

252P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 253: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

You get a list of all the session variables of the current session.

SELECT * FROM M_SESSION_CONTEXT WHERE CONNECTION_ID = CURRENT_CONNECTION

You remove the session variable from the specified session. In the command below replace <your_session_id> with the session ID that you discovered from the command above.

ALTER SYSTEM ALTER SESSION <your_session_id> UNSET 'MY_VAR';

You get a list of all the session variables of the current session.

SELECT * FROM M_SESSION_CONTEXT WHERE CONNECTION_ID = CURRENT_CONNECTION

From the results of this command you can see that the MY_VAR variable has been unset.

1.8.3.4 ALTER SYSTEM CANCEL [WORK IN] SESSION

Syntax

ALTER SYSTEM CANCEL [WORK IN] SESSION <session_id>

Syntax Elements

<session_id> ::= <string_literal>

The session ID of the required session.

Description

Cancels the currently executing statement of a session. The transaction of the cancelled session will be rolled back. The statement that was executing will return error code 139 (current operation cancelled by request and transaction rolled back).

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 253

Page 254: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Example

You use the following query to obtain current database connection IDs and to view the statements that the sessions are executing.

SELECT C.CONNECTION_ID, PS.STATEMENT_STRING FROM M_CONNECTIONS C JOIN M_PREPARED_STATEMENTS PS ON C.CONNECTION_ID = PS.CONNECTION_ID AND C.CURRENT_STATEMENT_ID = PS.STATEMENT_ID WHERE C.CONNECTION_STATUS = 'RUNNING' AND C.CONNECTION_TYPE = 'Remote'

Using the connection ID information you obtained using the query above, you can now cancel a running query. In the statement below you replace <connection_id> with a connection ID from the query above.

ALTER SYSTEM CANCEL SESSION '<connection_id>'

1.8.3.5 ALTER SYSTEM CLEAR SQL PLAN CACHE

Syntax

ALTER SYSTEM CLEAR SQL PLAN CACHE

Description

The ALTER SYSTEM CLEAR SQL PLAN CACHE statement removes all the SQL plans that are not currently executing from the SAP HANA database plan cache. The command also removes all plans having reference count of '0' from the plan cache and resets all the statistics of the remaining plans. Lastly the command also reset the contents of M_SQL_PLAN_CACHE_OVERVIEW monitoring view.

SQL PLAN CACHE

The SQL PLAN CACHE stores plans generated by previous SQL statement executions. The plan cache is used by the SAP HANA database to speed up query execution if the same SQL statement is executed multiple times. The plan cache also collects some statistics regarding plan preparation and execution.

System Views

M_SQL_PLAN_CACHE : Execution plan statistics.

M_SQL_PLAN_CACHE_OVERVIEW : Overall SQL plan cache statistics.

254P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 255: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Example

You clear the SQL plan cache.

ALTER SYSTEM CLEAR SQL PLAN CACHE

1.8.3.6 ALTER SYSTEM CLEAR TRACES

Syntax

ALTER SYSTEM CLEAR TRACES (<trace_type_list>)

Syntax Elements

<trace_type_list> ::= <trace_type> [{,<trace_type>}...]

A list of trace types to be cleared.

<trace_type> ::= <string_literal>

You can selectively clear specific trace files by setting the trace_type to one of the following types:

<trace_type> Trace Files

ALERT *alert_*.trc

CLIENT localclient_*.trc

CRASHDUMP *.crashdump.*

EMERGENCYDUMP *.emergencydump.*

EXPENSIVESTATEMENT *.expensive_statements.*.trc

* all *.trc files of services listed below

INDEXSERVER,NAMESERVER,...,DAEMON open *.trc files of a single service type

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 255

Page 256: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Description

You use the ALTER SYSTEM CLEAR TRACES to clear trace contents from trace files. When you use this command all trace files that were opened by the SAP HANA database will be removed or cleared. On distributed systems, this command will clear all trace files on all hosts.

You use this command to reduce disk space used by large tracefiles for example, when trace components are set to INFO or DEBUG.

System Views

M_TRACEFILES : All trace files.

M_TRACEFILE_CONTENTS : Trace file content.

Examples

You clear the alert trace file.

ALTER SYSTEM CLEAR TRACES('ALERT');

You clear the alert and client trace files.

ALTER SYSTEM CLEAR TRACES('ALERT', 'CLIENT');

1.8.3.7 ALTER SYSTEM DISCONNECT SESSION

Syntax

ALTER SYSTEM DISCONNECT SESSION <session_id>

Syntax Elements

<session_id> ::= <string_literal>

The session ID of the session to be disconnected.

256P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 257: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Description

You use ALTER SYSTEM DISCONNECT SESSION to disconnect a specified session from the database. Before disconnection any currently running operations associated with the session will be terminated.

Example

You use the command below to obtain the session IDs of idle sessions.

SELECT CONNECTION_ID, IDLE_TIME FROM M_CONNECTIONS WHERE CONNECTION_STATUS = 'IDLE' AND CONNECTION_TYPE = 'Remote' ORDER BY IDLE_TIME DESC

You disconnect a session. In the statement below you replace <connection_id> with a connection ID from the query above.

ALTER SYSTEM DISCONNECT SESSION '<connection_id>'

1.8.3.8 ALTER SYSTEM LOAD PERFTRACE

NoteThe created tables are only to be used in conjunction with SAP tools or support personnel. The format of the tables is not documented for end user.

Syntax

ALTER SYSTEM LOAD PERFTRACE [FILE <file_name>] INTO TABLES <table_prefix> [WITH REPLACE]

Syntax Elements

FILE <file_name> <file_name> ::= <string_literal>

Specifies the file where raw performance data will loaded from.

<table_prefix> ::= [ <schema_name>. ]<identifier> <schema_name> ::= <identifier>

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 257

Page 258: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

The table prefix to be used, with optional schema name.

WITH REPLACE

When specified previously existing tables are removed. If the REPLACE option is not specified, an error will be thrown if tables with the specified prefix already exist.

Description

You use this command to convert a .tpt file into tables. Tables beginning with <table_prefix>_PERFTRACE_... are created and filled with the content from the .tpt file. The .tpt file will be loaded from the trace directory of your SAP HANA database instance. If you do not specify a file name then 'perftrace.tpt' will be used.

Example

You load performance trace data 'mytrace.tpt' file into tables <current_schema>.MYTRACE_PERFTRACE_....

ALTER SYSTEM LOAD PERFTRACE FILE 'mytrace.tpt' INTO TABLES mytrace WITH REPLACE

This statement will create various tables, for example:

MYTRACE_PERFTRACE_INFO MYTRACE_PERFTRACE_SERVICES MYTRACE_PERFTRACE_CALLS

1.8.3.9 ALTER SYSTEM LOGGING

Syntax

ALTER SYSTEM LOGGING <on_off>

Syntax Elements

<on_off> ::= ON | OFF

The logging status.

ON

258P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 259: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Enable logging.

OFF

Disable logging.

Description

You used this command to Enable or disable logging.

While logging is disabled no log entries will be persisted, only the data area will be written when a savepoint is reached. This can cause loss of committed transactions, when the indexserver terminates in the middle of a LOAD operation. In case of a termination, you will have to truncate and insert all data again.

After enabling logging you have to perform a savepoint to be sure that all data will be persisted. You will also have to perform a data backup, otherwise you will be unable to recover this data.

ALTER SYSTEM LOGGING waits for the end (commit/rollback) of existing active write transactions. During the execution of this command write transactions are blocked. In the event that there is a long-running write transaction, this command can be failed with a lock wait timeout error. Starting a new write transaction also can be blocked and failed with the same error.

Due to the potential generation of the errors mentioned above you should only use this command whilst performing a database initial load. If used at other times data loss can occur if the indexserver is terminated whilst logging is disabled. Consequently, in a running system, the logging mode should be always ON and should not be modified.

You can also adjust the logging settings for single column tables with ALTER TABLE <table_name> {ENABLE | DISABLE} DELTA LOG, see <delta_log_option>.

Example

You disable system logging.

ALTER SYSTEM LOGGING OFF;

You enable system logging.

ALTER SYSTEM LOGGING ON;

See Also

ALTER TABLE

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 259

Page 260: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

1.8.3.10 ALTER SYSTEM PERSISTENCE ENCRYPTION

Syntax

ALTER SYSTEM PERSISTENCE ENCRYPTION <encrypt_option>

Syntax Elements

<encrypt_option> ::= ON | OFF | CREATE NEW KEY | APPLY CURRENT KEY

Persistence encryption options.

ON

Specifies that encryption should be enabled. When you switch on encryption a random encryption key is prepared and an asynchronous background task is started that encrypts all disk data with this key.

OFF

Specifies that encryption should be disabled. When you switch off encryption, an asynchronous background task is started which decrypts all encrypted disk data.

CREATE NEW KEY

Forces the creation of a new random encryption key. The new key will begin to be used after the next savepoint has occurred. The time in which this takes to occur depends upon the current workload of the SAP HANA database. No changes will be made to data that has already been written to disk.

APPLY CURRENT KEY

Force all data using old encryption keys to be decrypted and then re-encrypted using the current encryption key. You may wish to do this if an old key has been compromised or if you want to consolidate a set of old keys.

NoteWhen new key has been created with CREATE NEW KEY and then APPLY CURRENT KEY is called, a savepoint is automatically triggered so that the new key can be used for encryption of existing disk data.

260P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 261: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Description

The ALTER SYSTEM PERSISTENCE ENCRYPTION statement controls if persistent data should be stored on disk in an encrypted or non-encrypted format. You can also use this command to recreate the random encryption key or apply a new key to existing disk data.

NoteCurrently only the finally written disk data will be encrypted. The redo log is not affected by this command. For more information about the redo log please see the "Backing Up and Recovering the SAP HANA database" section in the "SAP HANA Administration guide" available from the SAP HANA Appliance page.

Example

You cause a non-encrypted instance to begin the asynchronous task of encrypting disk data.

ALTER SYSTEM PERSISTENCE ENCRYPTION ON

See Also

For more information about the use of Encryption in the SAP HANA database please see the "Managing Data Volume Encryption" section in the "SAP HANA Administration guide" available from the SAP HANA Appliance page.

1.8.3.11 ALTER SYSTEM RECLAIM DATA SPACE

Syntax

ALTER SYSTEM RECLAIM [ROW] DATA SPACE [IMMEDIATE] [<host:port>]

Syntax Elements

<host_port> ::= 'host_name:port_number'

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 261

Page 262: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Host and port of the service to reorganize row store. If omitted, the reorganization is executed on the host which the connection is made.

IMMEDIATE Execute row store reorganization right away. The same for omitted case.

Description

The command will execute row store memory reorganization at runtime. It first inspects the system in order to analyze the current status of row store memory utilization. After that, it calculates how much memory can be reduced.

When this inspection is complete, a table list is generated. It then locks the member tables in the table list and executes actual row store memory reorganization.

Please note that the table list is determined at runtime and it can affect a number of row tables.

Example

ALTER SYSTEM RECLAIM DATA SPACE

1.8.3.12 ALTER SYSTEM RECLAIM DATAVOLUME

Syntax

ALTER SYSTEM RECLAIM DATA VOLUME [SPACE] [<host_port>] <percentage_of_overload_size> <shrink_mode>

Syntax Elements

<host_port> ::= '<hostname>:<port_number>'

The server on which the size of the persistency should be reduced. If <host_port> is omitted the statement is distributed to all servers with persistence.

For information about hostname and port number, see notation_host_name_and_port "Notation"

<percentage_of_overload_size> ::= <unsigned_integer>

262P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 263: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

The desired percentage of the overload size by which the data volume should be reduced.

<shrink_mode> ::= DEFRAGMENT | SPARSIFY

The strategy to be used to reduce the persistency size. DEFRAGEMENT is the default.

NoteSPARSIFY is not supported yet and is reserved for future use.

Description

You use this command when unused space inside a SAP HANA database disk persistence should be freed. It reduces data volume size to a percentage of overload size.

This command works in a similar way to defragmenting a hard drive. Pages that are scattered around a data volume will be moved to the front of the volume, and the free space at the end of the data volume will be truncated.

Example

In the example below the persistence of all servers in the landscape are defragmented and reduced to 120% of the overload size.

ALTER SYSTEM RECLAIM DATAVOLUME 120 DEFRAGMENT

1.8.3.13 ALTER SYSTEM RECLAIM LOG

Syntax

ALTER SYSTEM RECLAIM LOG

Description

You use this command when the SAP HANA database has accumulated a lot of log segments and you want to reclaim disk space of currently unused log segments.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 263

Page 264: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Log segment accumulation can be caused in several ways. For example, when automatic log backup is not operational for a long period or a log savepoint is blocked for an extended time. When such issues occur you use the ALTER SYSTEM RECLAIM LOG command, but only after the root cause of the log accumulation has been fixed.

System Views

M_LOG_SEGMENTS : Currently allocated log segments.

Example

You reclaim disk space of currently unused log segments.

ALTER SYSTEM RECLAIM LOG

1.8.3.14 ALTER SYSTEM RECLAIM VERSION SPACE

Syntax

ALTER SYSTEM RECLAIM VERSION SPACE

Description

This command triggers the row-store garbage collector to free up memory space and enhance system responsiveness.

You do not need to use this command if only short transactions are being executed on the system. This is because the garbage collector is automatically triggered when a transaction ends. If there are long-running transactions on the system, this command helps overall system performance if the m_mvcc_tables monitoring view shows a large number of row-store versions(e.g. over 1M).

264P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 265: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

System Views

M_MVCC_TABLES : The number of row-store versions in the system.

Example

You check the number of row-store versions on the system using the m_mvcc_tables monitoring view.

SELECT * FROM m_mvcc_tables

You trigger row-store garbage collection.

ALTER SYSTEM RECLAIM VERSION SPACE

1.8.3.15 ALTER SYSTEM RECONFIGURE SERVICE

Syntax

ALTER SYSTEM RECONFIGURE SERVICE (<service_name>,<host>,<port>)

Syntax Element

<service_name> ::= <string_literal>

The name of the service you wish to reconfigure. See M_SERVICE_TYPES monitoring view for a list of available service types.

<host> ::= <string_literal> <port> ::= <unsigned_integer>

The host and port number where you would like to reconfigure a service.

Description

You use ALTER SYSTEM RECONFIGURE SERVICE to reconfigures a specified service by applying the current configuration parameters.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 265

Page 266: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

This command is used after changing multiple configuration parameters with the ALTER CONFIGURATION command without the RECONFIGURE option set. See ALTER SYSTEM ALTER CONFIGURATION

To reconfigure a specific service specify <host> and <port> and leave <service_name> empty.

To reconfigure all services of a type, specify <service_name> and leave <host> and <port> empty.

To reconfigure all services, leave all parameters empty.

Example

You use the following command to reconfigure all services on the hana.hana.com host using port number 30303:

ALTER SYSTEM RECONFIGURE SERVICE ('','hana.yourcompany.com',30303)

You use the following command to reconfigure all services of type indexserver:

ALTER SYSTEM RECONFIGURE SERVICE ('indexserver','',0)

See Also

ALTER SYSTEM ALTER CONFIGURATION

1.8.3.16 ALTER SYSTEM REMOVE TRACES

Syntax

ALTER SYSTEM REMOVE TRACES (<host>, <trace_file_list>)

Syntax Elements

<host> ::= <string_literal>

The name of the host where the traces are to be removed.

<trace_file_list> ::= <trace_file> [{, <trace_file>}...]

266P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 267: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

The trace files to be removed.

<trace_file> ::= <string_literal>

The name of a file to be removed.

Valid host name and file name combinations can be retrieved from M_TRACEFILES view.

Description

You use this command to delete the trace files on a specified host, thereby reducing disk space used by large trace files.

When a service has a trace file open it cannot be deleted. In this case you can clear the trace file using the ALTER SYSTEM CLEAR TRACES command.

System Views

M_TRACEFILES : All trace files.

Example

ALTER SYSTEM REMOVE TRACES ('hananode01', 'extrace.py', 'extrace.py.old');

See Also

ALTER SYSTEM CLEAR TRACES

1.8.3.17 ALTER SYSTEM RESET MONITORING VIEW

Syntax

ALTER SYSTEM RESET MONITORING VIEW <view_name>

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 267

Page 268: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Syntax Elements

<view_name> ::= [<schema_name>.]<identifier> <schema_name> ::= <identifier>

The name of the resettable monitoring view to be reset.

NoteNot all monitoring views can be reset using this command. You can identify a view as being able to be reset as its view name will have the suffix "_RESET".

Description

You use this command to reset statistics data for the specified monitoring view.

You use this command to define a starting point for your measurements. First, you reset the monitoring view, then execute an action. After the action is completed, query "_RESET" version of the monitor view to get the statistical information gathered since the last reset.

Example

In the example below you reset the "SYS"."M_HEAP_MEMORY_RESET" monitoring view.

ALTER SYSTEM RESET MONITORING VIEW "SYS"."M_HEAP_MEMORY_RESET"

1.8.3.18 ALTER SYSTEM SAVE PERFTRACE

NotePerformance tracing is only to be used in conjunction with SAP Support personnel. The collected perftrace data cannot be analyzed by an end user.

Syntax

ALTER SYSTEM SAVE PERFTRACE [INTO FILE <file_name>]

268P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 269: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Syntax Elements

INTO FILE <file_name> <file_name> ::= <string_literal>

Specifies a file where raw performance data will be saved.

Description

You use this command to collect raw performance trace data from .prf files and save the information into a single .tpt file. The .tpt file will be saved in the trace directory of your SAP HANA database instance. If you do not specify a file name then 'perftrace.tpt' will be used.

The performance trace data (.tpt) file can be downloaded from SAP HANA Studio. To obtain the trace files in the SAP HANA Systems view you right click on the system you wish to diagnose. You select Administration from the context menu and in the dialog that appears you then select the Diagnosis Files tab. You right click on a Trace file and select Download. The (.tpt) file can be loaded into tables with ALTER SYSTEM LOAD PERFTRACE

System Views

M_PERFTRACE : Status of performance tracing.

M_JOB_PROGRESS : Monitor the saving of a trace file. The save job will be shown as 'Save PerfTrace' in the system view.

Cancellation

Saving a perftrace can take some time. You can cancel the job shown in M_JOB_PROGRESS with ALTER SYSTEM CANCEL [WORK IN] SESSION

Example

You save raw performance trace data into the 'mytrace.tpt' file.

ALTER SYSTEM SAVE PERFTRACE INTO FILE 'mytrace.tpt'

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 269

Page 270: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

1.8.3.19 ALTER SYSTEM SAVEPOINT

Syntax

ALTER SYSTEM SAVEPOINT

Description

Executes a savepoint on the persistence manager. A savepoint is a point in time when a complete consistent image of the database is persisted to disk. The consistent image can be used to restart the database.

Normally a savepoint is executed periodically as configured by the configuration parameter savepoint_interval_s in section [persistence]. For special (normally test) purposes, the savepoint can be disabled. In this case, you can use this command to manually execute a savepoint.

System Views

M_SAVEPOINT_STATISTICS : Savepoint statistics.

Example

You execute a savepoint on the persistence manager.

ALTER SYSTEM SAVEPOINT

1.8.3.20 ALTER SYSTEM START PERFTRACE

NotePerformance tracing is only to be used in conjunction with SAP Support personnel. The collected perftrace data cannot be analyzed by an end user.

270P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 271: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Syntax

ALTER SYSTEM START PERFTRACE [<user_name>] [<application_user_name>] [<application_name>] [PASSPORT_TRACELEVEL <passport_level>] [PLAN_EXECUTION] [FUNCTION_PROFILER] [DURATION <duration_seconds>]

Syntax Element

<user_name> ::= USER <simple_identifier>

Restricts perftrace collection to an SQL user name

<application_user_name> ::= APPLICATIONUSER <string_literal>

Restricts perftrace collection to the application user name.

<application_name> ::= APPLICATION <string_literal>

Restricts perftrace collection to the application name.

<passport_level> ::= MEDIUM | HIGH

The level of trace data to be collected. This is effectively a filter controlling the amount of data collected in end-to-end scenarios.

PLAN_EXECUTION

Specifies that plan execution details should be traced.

FUNCTION_PROFILER

Specifies that function level details should be traced.

<duration_seconds> ::= <numeric_literal>

The number of seconds which perftrace should be collected. After this period expires perftrace is automatically stopped. If you do not specify this parameter you must stop perftrace with the ALTER SYSTEM STOP PERFTRACE statement.

Description

The ALTER SYSTEM START PERFTRACE command starts performance tracing.

Only one perftrace can be active at a time.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 271

Page 272: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

System Views

M_PERFTRACE : Status of performance tracing.

Example

You start performance tracing for the user sql_user on application user name app_user for application app_name. You also specify that plan execution and function level detail should be traced.

ALTER SYSTEM START PERFTRACE USER sql_user APPLICATIONUSER app_user APPLICATION app_name PLAN_EXECUTION FUNCTION_PROFILER

1.8.3.21 ALTER SYSTEM STOP PERFTRACE

NotePerformance tracing is only to be used in conjunction with SAP Support personnel. The collected perftrace data cannot be analyzed by an end user.

Syntax

ALTER SYSTEM STOP PERFTRACE

Description

Stops an active performance trace. After stopping the trace, you collect and save the performance trace data with ALTER SYSTEM SAVE PERFTRACE.

Example

You stop an active performance trace.

ALTER SYSTEM STOP PERFTRACE

272P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 273: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

1.8.3.22 ALTER SYSTEM STOP SERVICE

Syntax

ALTER SYSTEM STOP SERVICE <host_port> [IMMEDIATE [WITH COREFILE]]

Syntax Element

<host_port> ::= <host_name:port_number> | ('<host_name>',<port_number>)

Host and port of the service to be stopped.

IMMEDIATE

Immediately stop the service without waiting for regular shutdown.

WITH COREFILE

Write a core dump file.

Description

Stop single or multiple services on the designated host.

NoteTypically a service you stop will be automatically restarted by the SAP HANA database system.

You should use this command after changing a configuration parameter that can not be changed whilst the SAP HANA database is running.

Example

You stop a service running on host hdb1.yourcompany.com on port 30303.

ALTER SYSTEM STOP SERVICE 'hdb1.yourcompany.com:30303'

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 273

Page 274: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

1.8.3.23 SET SYSTEM LICENSE

Syntax

SET SYSTEM LICENSE <license key>

Syntax Elements

<license key> ::= <string_literal>

The license key to be set.

Description

Installs a license key to the database instance. The license key (<license key>="">) is to be copied and pasted from the license key file. The system privilege LICENSE ADMIN is required to execute this command.

Example

NoteThe license shown below does not contain a license key, so you cannot run this example.

You set the system license with a license code.

SET SYSTEM LICENSE '----- Begin SAP License ----- SAPSYSTEM=HD1 HARDWARE-KEY=K4150485960 INSTNO=0110008649 BEGIN=20110809 EXPIRATION=20151231 LKEY=... SWPRODUCTNAME=SAP-HANA SWPRODUCTLIMIT=2147483647 SYSTEM-NR=00000000031047460'

274P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 275: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

1.8.3.24 UNSET SYSTEM LICENSE ALL

CautionRunning this command immediately locks down your SAP HANA database. You will require a new license key before you can use the system further.

Syntax

UNSET SYSTEM LICENSE ALL

Description

Deletes all currently installed license keys. After using this command the SAP HANA database will be locked down immediately and will require a new valid license key before it can be used further. The system privilege LICENSE ADMIN is required to execute this command.

Example

You delete all currently installed license keys.

UNSET SYSTEM LICENSE ALL

1.8.4 Session Management Statements

● CONNECT● SET HISTORY SESSION● SET SCHEMA● SET [SESSION]● UNSET [SESSION]

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 275

Page 276: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

1.8.4.1 CONNECT

Syntax

CONNECT {<username> PASSWORD <password>} | {WITH SAML ASSERTION <xml>}

Syntax Elements

<username> ::= <simple_identifier>

The username for the connection.

<password> ::= <letter_or_digit>...

The password for the user.

WITH SAML ASSERTION <xml> <xml> ::= <string_literal>

Specifies a SAML assertion to use when connecting to the database.

Description

Connects to a database instance using either a username and password pair, or a SAML assertion, for identification.

Example

You create a SAML provider with the name ac_saml_provider specifying a subject and issuer for ACompany.

CREATE SAML PROVIDER ac_saml_provider WITH SUBJECT 'CN = wiki.detroit.ACompany.corp,OU = ACNet,O = ACompany,C = EN' ISSUER 'E = [email protected],CN = ACNetCA,OU = ACNet,O = ACompany,C = EN';

You create a user called new_user with password Password1. The user can connect to the system using the given password and with an assertion of the SAML provider ac_saml_provider.

CREATE USER new_user PASSWORD Password1 WITH IDENTITY ANY FOR SAML PROVIDER ac_saml_provider;

276P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 277: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

You connect to the database with the user name new_user and password Password1.

CONNECT new_user PASSWORD Password1

1.8.4.2 SET HISTORY SESSION

Syntax

SET HISTORY SESSION TO <when>

Elements

<when> ::= NOW | COMMIT ID <commit_id> | UTCTIMESTAMP <timestamp>

Specifies the time period of the history table that should be used in the current database session.

NOW

Specifies that the database session should use the current version of the history table.

COMMIT ID <commit_id> <commit_id> ::= <unsigned_integer>

Specifies that the database session should use a version of the database table that was available at a specific commit Id.

UTCTIMESTAMP <timestamp> <timestamp> ::= <string_literal>

Specifies that the database session should use a version of the database table that was available at a specific timestamp. The timestamp has to be in format 'YYYY-MM-DD HH:MM:SS[.FF7]'. For more information on timestamps, see Timestamp Formats

Description

You use SET HISTORY SESSSION to effectively "time travel" the current database session so that it can "see" a previous version of history tables. You can specify the table version required by COMMIT ID or UTCTIMESTAMP format. You can also set the session to see the current state of history tables by using the NOW parameter.

Note

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 277

Page 278: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

This command only effects history tables, normal tables will remain unchanged.

As an alternative to using SET HISTORY SESSION you can also use statement level time travel. For more information on this feature, see Statement level time travel

System Views

M_HISTORY_INDEX_LAST_COMMIT_ID : Last commit id after each commit.

TRANSACTION_HISTORY : Timestamp of the last commit.

Examples

You create a history column table x, so that you can time travel through the table's history.

CREATE HISTORY COLUMN TABLE x ( a int, b int ); // after turnning off auto commit

You insert some values into table x.

INSERT INTO x VALUES (1,1); COMMIT; INSERT INTO x VALUES (2,2); COMMIT;

You obtain the commit id of the last commit.

SELECT last_commit_id FROM M_HISTORY_INDEX_LAST_COMMIT_ID WHERE session_id = current_connection;

Noteplease replace <last_comit_id> in the steps below with the value you obtained in this step.

You delete all the data from table x.

DELETE FROM x; COMMIT;

You time travel into the history of table x before you deleted the data and perform a select.

SET HISTORY SESSION TO COMMIT ID <last_comit_id>; SELECT * FROM x;

The select query above returns the two records (1,1) and (2,2), which existed before you deleted the contents of table x.

You obtain the timestamp of <last_comit_id>.

SELECT COMMIT_TIME FROM SYS.TRANSACTION_HISTORY WHERE commit_id = <last_comit_id>;

278P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 279: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Noteplease replace <commit_time> in the steps below with the value you obtained in this step.

You time travel into the history of table x using a timestamp and perform a select.

SET HISTORY SESSION TO UTCTIMESTAMP '<commit_time>'; SELECT * FROM x;

The select query above returns the two records (1,1) and (2,2), which existed before you deleted the contents of table x.

You set the history session to the current commit state and perform a select.

SET HISTORY SESSION TO NOW; SELECT * FROM x;

The select query returns an empty table because, at the current state, the table has had all of its data deleted.

See Also

HISTORY time travel

1.8.4.3 SET SCHEMA

Syntax

SET SCHEMA <schema_name>

Syntax Elements

<schema_name> ::= <string_literal>

The name of the schema that the session should change to.

Description

Changes the current schema of the session.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 279

Page 280: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

The current schema is used when SQL statements use database object names, for example table names, that are not prefixed with a schema name.

Example

You create new schema called MY_SCHEMA.

CREATE SCHEMA MY_SCHEMA;

You change the current schema of the session to MY_SCHEMA.

SET SCHEMA MY_SCHEMA;

1.8.4.4 SET [SESSION]

Syntax

SET [SESSION] <key> = <value>

Syntax Elements

<key> ::= <string_literal>

The key of a session variable. The maximum length of key is 32 characters.

<value> ::= <string_literal>

The desired value of a session variable. The maximum length of value is 512 characters.

Description

With this command you can set session variables of your own database session by providing key and value pairs.

See M_SESSION_CONTEXT view for a list of predefined session variables.

Session variables can be retrieved using SESSION_CONTEXT function or from M_SESSION_CONTEXT view and unset using the UNSET [SESSION] command.

280P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 281: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Example

You set the session variable MY_VAR to 'abc'.

SET 'MY_VAR' = 'abc';

You select the variable MY_VAR from the current session.

SELECT SESSION_CONTEXT('MY_VAR') FROM DUMMY;

or

SELECT * FROM SYS.M_SESSION_CONTEXT WHERE CONNECTION_ID = CURRENT_CONNECTION

You unset the session variable MY_VAR.

UNSET 'MY_VAR';

1.8.4.5 UNSET [SESSION]

Syntax

UNSET [SESSION] <key>

Syntax Elements

<key> ::= <string_literal>

The key of a session variable. The maximum length of key is 32 characters.

Description

Using UNSET [SESSION] you can unset session variables of the current session.

See M_SESSION_CONTEXT view for a list of predefined variables.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 281

Page 282: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Example

You set the session variable MY_VAR to 'abc'.

SET 'MY_VAR' = 'abc';

You select the variable MY_VAR from the current session.

SELECT SESSION_CONTEXT('MY_VAR') FROM dummy;

You unset the session variable MY_VAR.

UNSET 'MY_VAR';

1.8.5 Transaction Management Statements

● COMMIT● LOCK TABLE● ROLLBACK● SET TRANSACTION

1.8.5.1 COMMIT

Syntax

COMMIT

Description

The system supports transactional consistency which guarantees current job to be either completely applied to the system or disposed. If a user wants to apply current job to the system persistently, the user should issue COMMIT command. If COMMIT command is issued and successfully processed, any change on the system which current transaction has done is applied to the system and the change will be visible to other jobs which will start in the future. The job which has already committed via COMMIT command cannot be reverted. In a distributed system, standard 2-phase-commit protocol is complied. In the first phase, transaction coordinator consults every participant whether if it is ready to commit, and sends the result to the participants in the second phase. COMMIT command only works with 'autocommit' disabled session.

282P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 283: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Example

COMMIT

1.8.5.2 LOCK TABLE

Syntax

LOCK TABLE <table_name> IN EXCLUSIVE MODE [NOWAIT]

Syntax Elements

<table_name> ::= [<schema_name>.]<identifier> <schema_name> ::= <identifier>

For more information on schema names and identifiers, see Identifiers.

Description

LOCK TABLE command acquires an exclusive lock for a table.

If the NOWAIT option is specified and LOCK TABLE fails to acquire lock an error code is returned.

NoteWhen the error is generated the current transaction is not rolled-back.

LOCK MODE: EXCLUSIVE

● Can be acquired by LOCK TABLE command explicitly or DDL command implicitly● The transaction that holds the lock can read and write the table.● Only the transaction that holds the lock can access the table.● Lock requests for the table by other transactions are blocked while the EXCLUSIVE lock is held.● The database releases acquired locks at the end of the transaction.

LOCK MODE: INTENTIONAL EXCLUSIVE

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 283

Page 284: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

● Acquired by DML implicitly.● Multiple transactions can acquired a INTENTIONAL EXCLUSIVE lock.● EXCLUSIVE lock requests for the table by other transactions are blocked while the INTENTIONAL EXCLUSIVE

lock is held.● The database releases acquired locks at the end of the transaction.

System Views

M_OBJECT_LOCKS : Status of lock acquisition.

Example

You create table A.

CREATE TABLE A (A INT PRIMARY KEY, B INT);

You acquire an exclusive lock for table A.

LOCK TABLE A IN EXCLUSIVE MODE

You attempt to acquire an exclusive lock for table A and specify that an error should be returned if the lock cannot be immediately obtained.

LOCK TABLE A IN EXCLUSIVE MODE NOWAIT

1.8.5.3 ROLLBACK

Syntax

ROLLBACK

Description

The SAP HANA database supports transactional consistency which guarantees that a transaction will be completely applied to the system or disposed. During a transaction data manipulation language (DML) modifications to the database can be explicitly reverted via ROLLBACK command. After ROLLBACK command is

284P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 285: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

issued, changes made during the current transaction are reverted and current database session is set to an idle state. ROLLBACK command only works with an autocommit disabled session.

If you attempt to use the ROLLBACK statements in an autocommit enabled session, nothing will occur as transactions are automatically committed to the database.

Example

NoteBefore attempting to execute the example below, please ensure that you are using an autocommit disabled session.

You create a table T.

CREATE TABLE T (KEY INT PRIMARY KEY, VAL INT);

You insert three rows into table T.

INSERT INTO T VALUES (1, 1); INSERT INTO T VALUES (2, 2); INSERT INTO T VALUES (3, 3);

You rollback the current transaction.

ROLLBACK;

You select the data in table T.

SELECT * FROM T;

The SELECT command above returns an empty table. From this you can see that the data definition language (DDL) command used to create the table has persisted, but the DML used to create the table data has been rolled back.

See Also

For more information on changing the autocommit status of your database session, please see "Customizing the Administration Console" section in the "SAP HANA Administration guide" available from the SAP HANA Appliance page.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 285

Page 286: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

1.8.5.4 SET TRANSACTION

Syntax

SET TRANSACTION {<isolation_level> | <transaction_access_mode>}

Syntax Elements

<isolation_level> ::= ISOLATION LEVEL <level> <level> ::= READ COMMITTED | REPEATABLE READ | SERIALIZABLE

Sets the statement level read consistency of the data in the database. If <isolation_level> is omitted, the default is READ COMMITTED.

READ COMMITTED

The READ COMMITTED isolation level provides statement level read consistency during a transaction. Each statement in a transaction uses the committed state of the data in the database as the execution of the statement begins. This means that each statement in the same transaction may see varying snapshots of the data in the database as they are executed. This is because data can be committed during the transaction.

REPEATABLE READ | SERIALIZABLE

The REPEATABLE READ or SERIALIZABLE isolation levels provide transaction level snapshot isolation. All statements of a transaction use the same snapshot of the database data. This snapshot contains all changes that were committed at the time the transaction started along with the changes made by the transaction itself.

<transaction_access_mode> ::= READ ONLY | READ WRITE

Controls whether a transaction can modify data during execution. If transaction_access_mode is omitted the default is READ ONLY.

READ ONLY

When READ ONLY access mode is set, then only read operations with SELECT statements are allowed. An exception will be thrown if update or insert operations are attempted whilst in this mode.

READ WRITE

When READ WRITE access mode is set, statements within a transaction can freely read or make changes to the database data as required.

286P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 287: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Description

The SAP HANA database uses multi-version concurrency control (MVCC) to ensure consistent read operations. Concurrent read operations "see" a consistent view of the database data without blocking concurrent write operations. Updates are implemented by inserting new versions of data and not by overwriting existing records.

The isolation level specified determines the lock operation type that will be used. The system supports both statement level snapshot isolation and transaction level snapshot isolation.

● For statement snapshot isolation use level READ COMMITTED.● For transaction snapshot isolation use REPEATABLE READ or SERIALIZABLE.

During a transaction when rows are inserted, updated or deleted, the system sets exclusive locks on the affected rows for the duration of the transaction. The system also sets shared locks on the affected tables for the duration of the transaction. This guarantees that the table is not dropped or altered while rows of the table are being updated. The database releases these locks at the end of the transaction.

NoteReading a row does not set any locks on either tables or rows within the database regardless of the isolation level used.

Data Definition Language and Transaction Isolation

Data Definition Language (DDL) statements (CREATE TABLE, DROP TABLE, CREATE VIEW, etc) always take an instantaneous effect on following SQL statements regardless of the transaction isolation level being used. For an example of this behavior please consider the following sequence:

1. A long running SERIALIZABLE isolation transaction begins operating on Table C.2. From outside the transaction some DDL is executed which adds a new column to Table C.3. From within the SERIALIZABLE isolation transaction the new column will be accessible as soon as the DDL

statement completes. This access occurs regardless of the isolation level of the transaction.

Example

You set the transaction isolation level to READ COMMITTED to provide statement level read consistency during the current transaction.

SET TRANSACTION ISOLATION LEVEL READ COMMITTED;

1.8.6 Access Control Statements

● ALTER CREDENTIAL● ALTER SAML PROVIDER● ALTER USER

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 287

Page 288: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

● CREATE CREDENTIAL● CREATE USER● CREATE REMOTE SOURCE● CREATE ROLE● CREATE SAML PROVIDER● DROP CREDENTIAL● DROP REMOTE SOURCE● DROP ROLE● DROP SAML PROVIDER● DROP USER● GRANT● REVOKE

1.8.6.1 ALTER CREDENTIAL

Syntax

ALTER CREDENTIAL FOR [USER <user_name>] COMPONENT <component_id> PURPOSE <purpose_def> TYPE <type_def> USING <using_param>

Syntax Elements

<user_name> ::= <simple_identifier>

The user that owns the credential.

NoteOnly users having the system privilege CREDENTIAL ADMIN are allowed to alter credentials for other users.

<component_id> ::= <string_literal>

An identifier for the component that uses the credential.

<purpose_def> ::= <string_literal>

The application-specific or component-specific purpose string.

<type_def>::= <string_literal>

288P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 289: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Specifies a connection mechanism, for example 'PASSWORD'.

<using_param> ::= <string_literal>

Specifies the connection parameter. This will be using a type specified by the <type_def> parameter.

Description

The ALTER CREDENTIAL statement modifies an existing component-specific or application-specific credential. Only the credentials can be changed using this command.

Each user has the privilege to alter their own credentials.

System Views

CREDENTIALS : Credentials defined for users and component

Example

You create a credential for all users that will be used by the component INTERNAL_APP. This credential will use the password mechanism for the PURPOSE COMPANY_MASTER_MACHINE.

CREATE CREDENTIAL FOR COMPONENT 'INTERNAL_APP' PURPOSE 'COMPANY_MASTER_MACHINE' TYPE 'PASSWORD' USING 'PASSWORD_9876';

You change the password of the credential created in the previous step.

ALTER CREDENTIAL FOR COMPONENT 'INTERNAL_APP' PURPOSE 'COMPANY_MASTER_MACHINE' TYPE 'PASSWORD' USING '1234_PASSWORD';

1.8.6.2 ALTER SAML PROVIDER

Syntax

ALTER SAML PROVIDER <saml_provider_name> <alter_saml_provider_option>

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 289

Page 290: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Syntax Elements

<saml_provider_name> ::= <simple_identifier>

The identifier of the SAML provider to be altered.

<alter_saml_provider_option> ::= <subject_issuer_clause> | <user_creation_clause>

You can alter the subject and issuer names or the user creation settings.

<subject_issuer_clause> ::= SET SUBJECT <subject_distinguished_name> ISSUER <issuer_distinguished_name>

Sets SAML identity provider information.

<subject_distinguished_name> ::= <string_literal>

The subject name provided in the certificate of the SAML identity provider.

<issuer_distinguished_name> ::= <string_literal>

The issuer name provided in the certificate of the SAML identity provider.

<user_creation_clause> ::= {ENABLE | DISABLE} USER CREATION

Enables or disables user creation.

When enabled, and a connection is opened for an unknown user using the saml provider identified by <saml_provider_name>, an implicit user creation occurs.

Description

The ALTER SAML PROVIDER statement changes properties of a SAML provider identified by <saml_provider_name>. The SAML provider must already exist in the SAP HANA database.

Only database users that have the system privilege USER ADMIN are allowed to change SAML providers.

System Views

SAML_PROVIDERS : Existing SAML providers with their subject name and issuer name.

290P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 291: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Example

You create the ac_saml_provider SAML provider.

CREATE SAML PROVIDER ac_saml_provider WITH SUBJECT 'CN = wiki.detroit.ACompany.corp,OU = ACNet,O = ACompany,C = EN' ISSUER 'E = [email protected],CN = ACNetCA,OU = ACNet,O = ACompany,C = EN';

You view the current defined SAML providers in the SAP HANA database.

select * from sys.SAML_PROVIDERS

You alter the ac_saml_provider.

ALTER SAML PROVIDER ac_saml_provider SET SUBJECT 'CN = wiki.detroit.BCompany.corp,OU = BCNet,O = BCompany,C = EN' ISSUER 'E = [email protected],CN = BCNetCA,OU = BCNet,O = BCompany,C = EN';

You check the current defined SAML providers in the SAP HANA database. You should now see the updated SAML provider.

select * from sys.SAML_PROVIDERS

See Also

CREATE SAML PROVIDER

1.8.6.3 ALTER USER

Syntax

ALTER USER <user_name> <alter_user_option>

Syntax Elements

<user_name> ::= <simple_identifier>

<alter_user_option> ::= PASSWORD <password> [VALID <validity_specification>] [<user_parameter_option>] | VALID <validity_specification> [<user_parameter_option>]

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 291

Page 292: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

| <user_parameter_option> | IDENTIFIED EXTERNALLY AS <external_identity> [VALID <validity_specification>] [<user_parameter_option>] | RESET CONNECT ATTEMPTS | DROP CONNECT ATTEMPTS | DISABLE PASSWORD LIFETIME | FORCE PASSWORD CHANGE | DEACTIVATE [USER NOW] | ACTIVATE [USER NOW] | DISABLE <authentication_mechanism> | ENABLE <authentication_mechanism> | ADD IDENTITY <provider_identity>... | ADD IDENTITY <external_identity> FOR KERBEROS | DROP IDENTITY <provider_info>... | DROP IDENTITY FOR KERBEROS

<password> ::= <letter_or_digit>...

<validity_specification> ::= <from_specification> <until_specification> | <until_specification>

<from_specification> ::= FROM {<timestamp> | NOW}

<until_specification> ::= UNTIL {<timestamp> | FOREVER}

<timestamp> ::= <string_literal>

<user_parameter_option> ::= <set_user_parameters> [<clear_user_parameter_option>] | <clear_user_parameter_option>

<set_user_parameters> ::= SET PARAMETER <user_parameter_list>

<user_parameter_list> ::= <user_parameter> [{, <user_parameter>} ...]

<user_parameter> ::= CLIENT = <string_literal> | LOCALE = <string_literal> | TIME ZONE = <string_literal> | EMAIL ADDRESS = <string_literal>

<clear_user_parameter_option> ::= CLEAR PARAMETER <clear_user_parameter_list> | CLEAR ALL PARAMETERS

<clear_user_parameter_list> ::= <clear_user_parameter> [{, <clear_user_parameter>} ...]

<clear_user_parameter> ::= CLIENT | LOCALE | TIME ZONE | EMAIL ADDRESS

<external_identity> ::= <simple_identifier> | <string_literal>

<authentication_mechanism> ::= PASSWORD | KERBEROS | SAML | X509

<provider_identity> ::= <mapped_user_name> FOR SAML PROVIDER <saml_provider_name> | <subject_distinguished_name> ISSUER <issuer_distinguished_name> FOR X509 | <kerberos_principal_name> FOR KERBEROS <mapped_user_name> ::= ANY | <string_literal>

292P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 293: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

<saml_provider_name> ::= <simple_identifier>

<subject_distinguished_name> ::= <string_literal>

<issuer_distinguished_name> ::= <string_literal>

<kerberos_principal_name> ::= <string_literal>

<provider_info> ::= FOR SAML PROVIDER <saml_provider_name> | <subject_distinguished_name> ISSUER <issuer_distinguished_name> FOR X509

Description

The ALTER USER statement modifies the database user. <user_name> must specify an existing database user.

Each user can do the ALTER USER statement for his own. But not all of the <alter_user_option>s can be specified by the user himself. The ALTER USER statement for other users with all <alter_user_option>s can only be done by users having the system privilege USER ADMIN.

Users created with PASSWORD cannot be changed to EXTERNALLY and vice versa: the users created with EXTERNALLY cannot be changed to PASSWORD. But their <password> or their <external_identity> can be changed.

You can change a user's password with this command. Password must follow the rules defined for the current database. The password rules include the minimal password length and the definition which of the character types ( lower, upper, digit, special characters ) have to be part of the password. The password for a user has to be changed regularly according to the password policy specified for the database instance or changed by the user himself when first connecting to the database instance.

You can change the external authentication. External users are authenticated using an external system, e.g. a Kerberos system. Such users do not have a password, but , e.g. a Kerberos principal name. For detailed information about external identities, contact your domain administrator.

If a <validity_specification> is given, then this user is only allowed to connect within that given range of timestamps. With this feature, users can be created and prepared in advance or restricted to be used to the date of user's retirement, for example.

<user_parameter_option> can be used to set, change or clean the user parameter CLIENT.

<set_user_parameters> can be used to set different parameters for the user. When using reports the user parameter CLIENT can be used to restrict the access rights of user <user_name> to info concerning the specified client.

When using reports the user parameter LOCALE can be used to translate information accordingly.

User parameter TIME ZONE and EMAIL ADDRESS will not be taken into account within the server, but can be used by applications.

The <user_parameter_option> CLIENT can not be specified by the user himself.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 293

Page 294: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

If the number of MAXIMUM_INVALID_CONNECT_ATTEMPTS (see monitoring view M_PASSWORD_POLICY) is reached before a successful (correct user/password-combination) connect is done, then this user is locked for some minutes before being allowed to connect (even with correct user/password-combination) again. With the command

ALTER USER <user_name> RESET CONNECT ATTEMPTS

a user with system privilege USER ADMIN can reset the number of invalid attempts to 0 and therefore allow the user to connect immediately.

Information on invalid connect attempts having happened can be checked in system view INVALID_CONNECT_ATTEMPTS. With the command

ALTER USER <user_name> DROP CONNECT ATTEMPTS

a user with system privilege USER ADMIN or the user himself can delete the information of invalid connect attempts having happened.

With the command

ALTER USER <user_name> DISABLE PASSWORD LIFETIME

a user with system privilege USER ADMIN can exclude user <user_name> from all password-life-time-checks. This should be used only for technical users, not for normal database users. Please check the description of configuration parameters concerning the password policy.

With the command

ALTER USER <user_name> FORCE PASSWORD CHANGE

a user with system privilege USER ADMIN can force user <user_name> to change his password immediately after the next connect before being allowed to work any further.

With the command

ALTER USER <user_name> DEACTIVATE USER NOW

a user with system privilege USER ADMIN can deactivate / lock the user account of user <user_name>. After the user account is deactivated / locked, the user cannot connect to the SAP HANA database. To re-activate / unlock user <user_name> a user with system privilege USER ADMIN has either to use the command ALTER USER <user_name> ACTIVATE USER NOW or, in case of a user with PASSWORD authentication mechanism, to reset the user's password with ALTER USER <user_name> PASSWORD <password>.

With the command

ALTER USER <user_name> ACTIVATE USER NOW

a user with system privilege USER ADMIN can re-activate / unlock the user account of user <user_name> who had been deactivated before.

Configuration Parameter

Conguration parameters concerning the password can be checked with the monitoring view M_PASSWORD_POLICY. These parameter are stored in indexserver.ini, section 'password policy'.

294P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 295: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

The description of the parameters concerned can be found in SAP HANA Security Guide, Appendix, Password Policy Parameters.

System Views

USERS : All users, their creator, creation date and some information about their current status.

USER_PARAMETERS : Defined user_parameters.

INVALID_CONNECT_ATTEMPTS : How many invalid connect attempts were made for each user.

M_PASSWORD_POLICY : Configuration parameters describing the allowed layout of the password and its lifetimes.

Examples

You create a SAML provider named ac_saml_provider in the database specifying a subject and issuer for ACompany.

CREATE SAML PROVIDER ac_saml_provider WITH SUBJECT 'CN = wiki.detroit.ACompany.corp,OU = ACNet,O = ACompany,C = EN' ISSUER 'E = [email protected],CN = ACNetCA,OU = ACNet,O = ACompany,C = EN';

You create user named new_user that can connect using a password or with an assertion of the SAML provider ac_saml_provider. The <mapped_user_name> was set to ANY as the assertion will provide the database user name.

CREATE USER new_user PASSWORD Password1 WITH IDENTITY ANY FOR SAML PROVIDER ac_saml_provider;

You force the user to change their password.

ALTER USER new_user FORCE PASSWORD CHANGE;

You disable SAML authentication for the user.

ALTER USER new_user DISABLE SAML;

You reset the number of invalid connect attempts to zero for new_user.

ALTER USER new_user RESET CONNECT ATTEMPTS;

You define the external identity for KERBEROS and enable KERBEROS for this user.

ALTER USER new_user ADD IDENTITY 'testkerberosName' FOR KERBEROS; ALTER USER new_user ENABLE KERBEROS;

Note

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 295

Page 296: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Adding an external identification mechanism to a user does not automatically enable it. You must do this as a separate step as shown in this example.

You remove ac_saml_provider SAML provider identity from new_user.

ALTER USER new_user DROP IDENTITY FOR SAML PROVIDER ac_saml_provider;

You disable the account.

ALTER USER new_user DEACTIVATE;

1.8.6.4 CREATE CREDENTIAL

Syntax

CREATE CREDENTIAL FOR [USER <user_name>] COMPONENT <component_id> PURPOSE <purpose_def> TYPE <type_def> USING <using_param>

Syntax Elements

<user_name> ::= <simple_identifier>

The user that can use the credential. When this parameter is specified the created credential will be used for this database user only.

If USER <user_name> is not provided, then every user of the current instance will use the same credential when the following conditions are true.

● The user is using the specified component.● The component needs access to the remote system specified by the PURPOSE parameter.

NoteOnly users having the system privilege CREDENTIAL ADMIN are allowed to alter credentials for other users.

<component_id> ::= <string_literal>

An identifier for the component that uses the credential.

<purpose_def> ::= <string_literal>

The application-specific or component-specific purpose string.

<type_def>::= <string_literal>

296P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 297: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Specifies a connection mechanism, for example 'PASSWORD'.

<using_param> ::= <string_literal>

Specifies the connection parameter. This will be using a type specified by the <type_def> parameter.

Description

The CREATE CREDENTIAL statement creates a component-specific or application-specific credential.

System Views

CREDENTIALS : Credentials defined for users and components.

Example

You create a credential for all users that will be used by the component INTERNAL_APP. This credential will use the password mechanism for the PURPOSE COMPANY_MASTER_MACHINE.

CREATE CREDENTIAL FOR COMPONENT 'INTERNAL_APP' PURPOSE 'COMPANY_MASTER_MASCHINE' TYPE 'PASSWORD' USING 'PASSWORD_9876';

1.8.6.5 CREATE USER

Syntax

CREATE USER <user_name> [PASSWORD <password>] [IDENTIFIED EXTERNALLY AS <external_identity>] [WITH IDENTITY <provider_identity>...] [VALID <validity_specification>] [<set_user_parameters>]

Syntax Elements

<user_name> ::= <simple_identifier>

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 297

Page 298: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

<password> ::= <letter_or_digit>...

<external_identity> ::= <simple_identifier> | <string_literal>

<provider_identity> ::= <mapped_user_name> FOR SAML PROVIDER <saml_provider_name> | <subject_distinguished_name> ISSUER <issuer_distinguished_name> FOR X509 | <kerberos_principal_name> FOR KERBEROS

<mapped_user_name> ::= ANY | <string_literal>

<saml_provider_name> ::= <simple_identifier>

<subject_distinguished_name> ::= <string_literal>

<issuer_distinguished_name> ::= <string_literal>

<kerberos_principal_name> ::= <string_literal>

<validity_specification> ::= FROM <timestamp> [UNTIL <timestamp>] | UNTIL <timestamp>

<timestamp> ::= <string_literal>

<set_user_parameters> ::= SET PARAMETER <user_parameter_list>

<user_parameter_list> ::= <user_parameter> [{, <user_parameter>} ...]

<user_parameter> ::= CLIENT = <string_literal> | LOCALE = string_literal> | TIME ZONE = <string_literal> | EMAIL ADDRESS = <string_literal>

Description

The CREATE USER statement creates a new database user.

Only database users having the system privilege USER ADMIN are allowed to create another database user.

The specified user name must not be identical to the name of an existing user, role, or schema.

There are some users, which are delivered with the SAP HANA database: SYS, SYSTEM, _SYS_REPO, _SYS_STATISTICS.

Users in the database can be authenticated by different mechanism, the internal authentication mechanism using password and by external mechanism, like Kerberos, SAML or X.509. One user can be authenticated by more than one mechanism at one time, but only one password and one principal name for Kerberos can be valid at one time. At least one authentication mechanism has to be specified to allow the user to connect and work with the database instance.

For compatibility reasons the syntax IDENTIFIED EXTERNALLY AS <external_identity> will stay alive and do the same as the syntax <kerberos_principal_name> FOR KERBEROS.

Password must follow the rules defined for the current database. The password rules include the minimal password length and the definition which of the character types ( lower, upper, digit, special characters ) have to

298P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 299: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

be part of the password. The password for a user has to be changed regularly according to the password policy specified for the database instance.

The password provided during CREATE USER command will be taken as provided, whereas the <user_name> will be changed to upper_case as every <simple_identifier>.

External users are authenticated using an external system, e.g. a Kerberos system. Such users do not have a password, but, e.g. a Kerberos principal name. For detailed information about external identities, contact your domain administrator.

If ANY is given as mapped user name, the SAML assertion will contain the name of the database user, the assertion is valid for.

<saml_provider_name> must specify an existing SAML provider.

If a <validity_specification> is given, then this user is only allowed to connect within that given range of timestamps. With this feature, users can be created and prepared in advance or restricted to be used to the date of user's retirement, for example.

<set_user_parameters> can be used to set different parameters for the user. When using reports the user parameter CLIENT can be used to restrict the access rights of user <user_name> to info concerning the specified client.

When using reports the user parameter LOCALE can be used to translate information accordingly.

User parameter TIME ZONE and EMAIL ADDRESS will not be taken into account within the server, but can be used by applications. In future EMAIL ADDRESS will be usable for connecting to the server. Therefore the value of user parameter EMAIL ADDRESS has to be unique.

For each database user a schema with the user's name is created implicitly. This can not be dropped explicitly. It will be dropped when the user is dropped. The database user owns that schema and uses it as his default schema, when he does not specify a schema name explicitly.

Configuration Parameter

Conguration parameters concerning the password can be checked with the monitoring view M_PASSWORD_POLICY. These parameter are stored in indexserver.ini, section 'password policy'.

The description of the parameters concerned can be found in SAP HANA Security Guide, Appendix, Password Policy Parameters.

System Views

USERS : All users, their creator, creation date and some information about their current status.

USER_PARAMETERS : Defined user_parameters.

INVALID_CONNECT_ATTEMPTS : How many invalid connect attempts were made for each user.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 299

Page 300: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

M_PASSWORD_POLICY : Configuration parameters describing the allowed layout of the password and its lifetimes.

SAML_PROVIDERS : Existing SAML providers.

SAML_USER_MAPPINGS : Users mapping names for each SAML provider.

Examples

Example 1 - Create user with password.

You create a user T12345 with a password Password123.

CREATE USER T12345 PASSWORD Password123

Example 2 - Create user that uses an external authentication mechanism.

You create a SAML provider named ac_saml_provider in the database, specifying a subject and issuer for ACompany.

CREATE SAML PROVIDER ac_saml_provider WITH SUBJECT 'CN = wiki.detroit.ACompany.corp,OU = ACNet,O = ACompany,C = EN' ISSUER 'E = [email protected],CN = ACNetCA,OU = ACNet,O = ACompany,C = EN';

You create a user called new_user with password Password1. The user can connect to the system using the given password and with an assertion of the existing SAML provider ac_saml_provider. The <mapped_user_name> is set to ANY as the assertion will provide the database user name.

CREATE USER new_user PASSWORD Password1 WITH IDENTITY ANY FOR SAML PROVIDER ac_saml_provider;

1.8.6.6 CREATE REMOTE SOURCE

Syntax

CREATE REMOTE SOURCE <remote_source_name> ADAPTER <adapter_name> CONFIGURATION <connection_info_string> [WITH CREDENTIAL <credential>]

300P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 301: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

CREATE REMOTE SOURCE

<remote_source_name> ::= <identifier>

The identifier of the remote source.

<adapter_name> ::= <identifier>

The corresponding adapter, and the type of access method, to be used by the SAP HANA database to access the data.

<connection_info_string> ::= <string_literal>

Connection parameters for a given adapter.

<credential> ::= TYPE <string_literal> USING <string_literal>

A credential type and the credential.

NoteFor SPS6 only, PASSWORD will be supported as credential type which specifies a clear text user name and password.

Description

The CREATE REMOTE SOURCE statement defines an external data source connected to SAP HANA database. Only database users having the system privilege CREATE SOURCE or DATA ADMIN are allowed to add a new remote source.

Example

You can create a remote source S using the DSN ProductionASE that has already been defined in the system.

CREATE REMOTE SOURCE S ADAPTER ASE_ODBC CONFIGURATION 'DSN=ProductionASE' WITH CREDENTIAL TYPE 'PASSWORD' USING 'user="aseuser";password="asepassword"'

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 301

Page 302: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

1.8.6.7 CREATE ROLE

Syntax

CREATE ROLE <role_name>

The name of the role to be created. The specified role name must not be identical to the name of an existing user or role.

Syntax Elements

<role_name> ::= <identifier>

The name of the role to be created.

Description

The CREATE ROLE statement creates a new role.

Only database users with the system privilege ROLE ADMIN are allowed to create roles.

A role is a named collection of privileges and can be granted to either a user or another role. If you want to allow several database users to perform the same actions you can create a role, grant the needed privileges to this role, and then grant the role to the database users.

Every user is allowed to grant privileges to an existing role, but only users having system privilege ROLE ADMIN are allowed to grant roles to roles and users.

There are 5 roles that are delivered with the SAP HANA database:

Role Purpose

PUBLIC Every database user is granted this role automatically.

This role contains read-only access to system views and execute privileges for some procedures.

These privileges cannot be revoked.

This role can be granted further privileges that can then be revoked afterwards.

302P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 303: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Role Purpose

MODELING Contains all privileges required for using the information modeler in the SAP HANA studio.

CONTENT_ADMIN Contains the same privileges as the MODELING role, but with the addition that this role is allowed to grant these privileges to other users.

In addition, it contains the repository privileges to work with imported objects.

MONITORING Contains privileges for full read-only access to all meta data, the current system status in system and monitoring views, and the data of the statistics server.

SAP_INTERNAL_HANA_SUPPORT This role bundles system privileges and object privileges that allow access to certain low-level internal system views. Access to these views is required by SAP HANA development support during support scenarios. All access is read-only. In particular, this role does not provide access to any of your data.

The definition of these low-level internal system views is not part of the stable end-user interface and might change from revision to revision. For this reason the use of this role has been limited in order to avoid administrators and end-users accessing these internal system views in applications and scripts. Ideally, this role should only been granted to SAP HANA development support users for their support activities.

Specifically, this role contains privileges for read-only access to all metadata, the current system status, and the data of the statistics server. Additionally, it contains the privileges for accessing the low level internal system views.

NoteAs well as users with the SAP_INTERNAL_HANA_SUPPORT role, the SYSTEM user also has access to these views.

To avoid accidental usage of this role in day-to-day activities, the following restrictions apply for the SAP_INTERNAL_HANA_SUPPORT role.

The role:

● Cannot be granted to more than one user at a time.● Cannot be granted to another role.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 303

Page 304: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Role Purpose

● Cannot have another role granted to it.● Cannot have object privileges granted to it.● Can only have system privileges granted to it.

However for security reasons SAP recommends system privileges should be granted to the user and not to the role.

With every upgrade of the SAP HANA engine, the support role is automatically reset to its default privileges.

System Views

ROLES : All roles, their creator and creation date.

GRANTED_ROLES : Roles that are granted to users or roles.

GRANTED_PRIVILEGES : Privileges that are granted to users or roles.

Example

You create a role with the name role_for_work_on_my_schema.

CREATE ROLE role_for_work_on_my_schema;

1.8.6.8 CREATE SAML PROVIDER

Syntax

CREATE SAML PROVIDER <saml_provider_name> <subject_issuer_clause> [<user_creation_clause>]

304P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 305: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Syntax Elements

<saml_provider_name> ::= <simple_identifier>

The identifier of a SAML provider to be created. The SAML provider name must not already be defined.

<subject_issuer_clause> ::= WITH SUBJECT <subject_distinguished_name> ISSUER <issuer_distinguished_name>

Sets SAML identity provider information.

<subject_distinguished_name> ::= <string_literal>

The subject name provided in the certificate of the SAML identity provider.

<issuer_distinguished_name> ::= <string_literal>

The issuer name provided in the certificate of the SAML identity provider

<user_creation_clause> ::= ENABLE USER CREATION

When specified and a connection is opened for an unknown user using the saml provider identified by <saml_provider_name>, an implicit user creation occurs.

Description

The CREATE SAML PROVIDER statement defines a SAML provider in the the SAP HANA database.

Only database users that have the system privilege USER ADMIN are allowed to create a SAML provider.

A SAML provider is required to be able to provide a SAML connection facility for users.

The <subject_distinguished_name> and the <issuer_distinguished_name> correspond to the subject and issuer of the X.509 certificate used by the SAML identity provider to sign assertions. The syntax of these names can be found in ISO/IEC 9594-1.

A detailed description of the concepts of SAML can be found in Oasis SAML 2.0.

System Views

SAML_PROVIDERS : Existing SAML providers with their subject name and issuer name.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 305

Page 306: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Example

You create a SAML provider with the name ac_saml_provider in the database specifying the subject and issuer to belong to ACompany.

CREATE SAML PROVIDER ac_saml_provider WITH SUBJECT 'CN = wiki.detroit.ACompany.corp,OU = ACNet,O = ACompany,C = EN' ISSUER 'E = [email protected],CN = ACNetCA,OU = ACNet,O = ACompany,C = EN';

1.8.6.9 DROP CREDENTIAL

Syntax

DROP CREDENTIAL FOR [USER <user_name>] COMPONENT <component_id> PURPOSE <purpose_def> TYPE <type_def>

Syntax Elements

<user_name> ::= <simple_identifier>

The owner of the credential to be dropped.

NoteOnly users having the system privilege CREDENTIAL ADMIN are allowed to drop credentials for other users.

<component_id> ::= <string_literal>

An identifier for the component that uses the credential.

<purpose_def> ::= <string_literal>

The application-specific or component-specific purpose string.

<type_def>::= <string_literal>

Specifies a connection mechanism, for example 'PASSWORD'.

306P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 307: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Description

The DROP CREDENTIAL statement drops an existing component-specific or application-specific credential.

Each user has the privilege to drop credentials they own.

System Views

CREDENTIALS : Credentials defined for users and component

Example

You create a credential for user WORKER that will be used by the component INTERNAL_APP. This credential will use the password mechanism for the PURPOSE COMPANY_MASTER_MACHINE.

CREATE CREDENTIAL FOR USER WORKER COMPONENT 'INTERNAL_APP' PURPOSE 'COMPANY_MASTER_MASCHINE' TYPE 'PASSWORD' USING 'PASSWORD_9876';

You drop the credential created in the previous step.

CREATE CREDENTIAL FOR USER WORKER COMPONENT 'INTERNAL_APP' PURPOSE 'COMPANY_MASTER_MASCHINE' TYPE 'PASSWORD';

1.8.6.10 DROP REMOTE SOURCE

Syntax

DROP REMOTE SOURCE <remote_source_name> [<drop_option>]

DROP REMOTE SOURCE

<remote_source_name> ::= <identifier>

The identifier of the remote source.

<drop_option> ::= CASCADE | RESTRICT

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 307

Page 308: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

When <drop_option> is not specified a restrict drop will be performed.

CASCADE

Drops the remote source and dependent objects.

RESTRICT

Drops the remote source only when dependent objects do not exist. If this drop option is used and a dependent object exists an error will be thrown.

Description

The DROP REMOTE SOURCE statement removes an existing remote source.

Example

You create remote source S and then drop it.

CREATE REMOTE SOURCE S ADAPTER ASE_ODBC CONFIGURATION 'DSN=ProductionASE' WITH CREDENTIAL TYPE 'PASSWORD' USING 'user="aseuser";password="asepassword"'

DROP REMOTE SOURCE S

1.8.6.11 DROP ROLE

Syntax

DROP ROLE <role_name>

Syntax Elements

<role_name> ::= <identifier>

308P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 309: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Description

The DROP ROLE statement drops a role. <role_name> must specify an existing role.

Only database users with the system privilege ROLE ADMIN are allowed to drop a role. Each user that has this privilege is allowed to drop any role.

NoteRoles that are delivered with the SAP HANA database cannot be dropped: PUBLIC, CONTENT_ADMIN, MODELING, MONITORING and SAP_INTERNAL_HANA_SUPPORT.

If a role has granted to a user or another role, it is revoked when the role is dropped. Revoking a role may lead to making some views inaccessible or making procedures not executable. This will occur if a view or procedures depends on any of the privileges of the dropped role.

System Views

ROLES : All roles, their creator and creation date.

GRANTED_ROLES : Roles that are granted to users or roles.

GRANTED_PRIVILEGES : Privileges that are granted to users or roles.

Example

You create role with the name role_for_work_on_my_schema.

CREATE ROLE role_for_work_on_my_schema;

You drop the role you create in the previous step.

DROP ROLE role_for_work_on_my_schema;

1.8.6.12 DROP SAML PROVIDER

Syntax

DROP SAML PROVIDER <saml_provider_name>

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 309

Page 310: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Syntax Elements

<saml_provider_name> ::= <simple_identifier>

Description

The DROP SAML PROVIDER statement drops the specified SAML provider. <saml_provider_name> has to be an existing SAML provider. If the SAML provider specified is currently used by a SAP HANA database user the SAML provider cannot be dropped.

Only database users having the system privilege USER ADMIN are allowed to drop a SAML provider.

System Views

SAML_PROVIDERS : Existing SAML providers with their subject name and issuer name.

Example

You create SAML provider named ac_saml_provider, specifying a subject and issuer for ACompany.

CREATE SAML PROVIDER ac_saml_provider WITH SUBJECT 'CN = wiki.detroit.ACompany.corp,OU = ACNet,O = ACompany,C = EN' ISSUER 'E = [email protected],CN = ACNetCA,OU = ACNet,O = ACompany,C = EN';

You drop the SAML provider ac_saml_provider.

DROP SAML PROVIDER ac_saml_provider

1.8.6.13 DROP USER

Syntax

DROP USER <user_name> [<drop_option>]

310P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 311: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Syntax Elements

<user_name> ::= <simple_identifier>

The name of the user to be dropped.

<drop_option> ::= CASCADE | RESTRICT

Specifies the drop option to use. When <drop_option> is not specified RESTRICT will be used by default.

CASCADE

Drops the user, as well carrying as the following actions:

● User's home schema and other schemas belonging to the user together with all objects stored in them regardless of which user created them are dropped.

● Objects owned by the user, even if they are part of another schema are dropped.● Objects that are dependent on deleted objects are dropped.● Public synonyms owned by the deleted user are dropped.● Privileges on deleted objects are revoked.● Privileges granted by the deleted user are revoked.

NoteRevoked privileges may cause further revokes if the privileges have been granted further.

RESTRICT

Drops the user only if they are not the owner of any other object than their home schema and other schemas created by the user. RESTRICT prevents the user from being dropped if schemas owned by the user contain objects owned by other users.

Description

The DROP USER statement deletes a database user. <user_name> must specify an existing database user.

Only database users having the system privilege USER ADMIN are allowed to drop a database user. Each user having this privilege is allowed to drop any user. Only those users which are delivered with the SAP HANA database cannot be dropped: SYS, SYSTEM, _SYS_REPO, _SYS_STATISTICS.

Users created by the deleted user and roles created by them are not deleted.

Audit policies created by the deleted user are not deleted.

It is possible to delete a user even if an open session for this user exists.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 311

Page 312: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

System Views

The deleted user will be deleted in the following views:

USERS : All users, their creator, creation date and some information about their current status.

USER_PARAMETERS : Defined user_parameters (Currently only CLIENT is available).

INVALID_CONNECT_ATTEMPTS : How many invalid connect attempts were made for each user.

The deletion of objects influence all of the system views describing objects, for example TABLES, VIEWS, PROCEDURES, etc.

The deletion of objects influence the view describing privileges like GRANTED_PRIVILEGES and all of the monitoring views like M_RS_TABLES, M_TABLE_LOCATIONS, etc.

Example

You create a new user called new_user.

CREATE USER new_user PASSWORD Password1;

You now drop the user new_user you created in the previous step. As the CASCADE option is used, the user is dropped together with all of the objects belonging to that user.

DROP USER new_user CASCADE;

1.8.6.14 GRANT

Syntax

GRANT <system_privilege>[{, <system_privilege>}...] TO <grantee> [WITH ADMIN OPTION] | GRANT <source_privilege>[{, <source_privilege>}...] ON REMOTE SOURCE <source_name> TO <grantee> [WITH GRANT OPTION] | GRANT <schema_privilege>[{, <schema_privilege>}...] ON SCHEMA <schema_name> TO <grantee> [WITH GRANT OPTION] | GRANT <object_privilege>[{, <object_privilege>}...] ON <object_name> TO <grantee> [WITH GRANT OPTION] | GRANT <role_name>[{, <role_name>}...] TO <grantee> [WITH ADMIN OPTION] | GRANT STRUCTURED PRIVILEGE <privilege_name> TO <grantee>

312P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 313: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Syntax Elements

<system_privilege> ::= AUDIT ADMIN | BACKUP ADMIN | BACKUP OPERATOR | CATALOG READ | CREATE REMOTE SOURCE | CREATE SCENARIO | CREATE SCHEMA | CREATE STRUCTURED PRIVILEGE | CREDENTIAL ADMIN | DATA ADMIN | EXPORT | IMPORT | INIFILE ADMIN | LICENSE ADMIN | LOG ADMIN | MONITOR ADMIN | OPTIMIZER ADMIN | RESOURCE ADMIN | ROLE ADMIN | SAVEPOINT ADMIN | SCENARIO ADMIN | SERVICE ADMIN | SESSION ADMIN | STRUCTUREDPRIVILEGE ADMIN | TRACE ADMIN | TRUST ADMIN | USER ADMIN | VERSION ADMIN | <identifier>.<identifier>

System privileges are used to restrict administrative tasks. The table below describes the supported system privileges.

System Privilege Privilege Purpose Comment

AUDIT ADMIN Controls the execution of the following auditing-related commands: CREATE AUDIT POLICY, DROP AUDIT POLICY and ALTER AUDIT POLICY and the changes of the auditing configuration.

BACKUP ADMIN Authorizes BACKUP and RECOVERY commands for defining and initiating backup and recovery procedures. Also changing system configuration options with respect to backup and recovery.

BACKUP OPERATOR Authorizes the BACKUP command to initiate a backup process.

CATALOG READ Authorizes users to have unfiltered read-only access to all system views.

Normally, the content of these views is filtered based on the privileges of the accessing user.

18

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 313

Page 314: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

System Privilege Privilege Purpose Comment

CREATE SCENARIO Controls the creation of calculation scenarios and cubes (calculation database)

CREATE SCHEMA Authorizes the creation of database schemas using the CREATE SCHEMA command.

By default each user owns one schema, with this privilege the user is allowed to create additional schemas.

CREATE REMOTE SOURCE Authorizes the creation of remote data sources using the CREATE REMOTE SOURCE command.

CREATE STRUCTURED PRIVILEGE Authorizes the creation of Structured Privileges (Analytical Privileges)

Only the owner of an Analytical Privilege can further grant or revoke that privilege to other users or roles.

CREDENTIAL ADMIN Authorizes the credential commands: CREATE/ALTER/DROP CREDENTIAL.

DATA ADMIN Authorizes reading all data in the system views. It also enables execution of any Data Definition Language (DDL) commands in the SAP HANA database

A user having this privilege cannot select or change data stored tables for which they do not have access privileges, but they can drop tables or modify table definitions.

EXPORT Authorizes export activity in the database via the EXPORT TABLE command.

Note that beside this privilege the user requires the SELECT privilege on the source tables to be exported.

IMPORT Authorizes the import activity in the database using the IMPORT commands.

Note that beside this privilege the user requires the INSERT privilege on the target tables to be imported.

INIFILE ADMIN Authorizes changing of system settings.

LICENSE ADMIN Authorizes the SET SYSTEM LICENSE command install a new license.

LOG ADMIN Authorizes the ALTER SYSTEM LOGGING [ON|OFF] commands to enable or disable the log flush mechanism.

MONITOR ADMIN Authorizes the ALTER SYSTEM commands for EVENTs.

314P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 315: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

System Privilege Privilege Purpose Comment

OPTIMIZER ADMIN Authorizes the ALTER SYSTEM commands concerning SQL PLAN CACHE and ALTER SYSTEM UPDATE STATISTICS commands, which influence the behavior of the query optimizer.

RESOURCE ADMIN This privilege authorizes commands concerning system resources, for example ALTER SYSTEM RECLAIM DATAVOLUME and ALTER SYSTEM RESET MONITORING VIEW. It also authorizes many of the commands available in the Management Console.

ROLE ADMIN This privilege authorizes the creation and deletion of roles using the CREATE ROLE and DROP ROLE commands. It also authorizes the granting and revocation of roles using the GRANT and REVOKE commands.

Activated roles, meaning roles whose creator is the pre-defined user _SYS_REPO, can neither be granted to other roles or users nor dropped directly. Not even users having ROLE ADMIN privilege are able to do so. Please check documentation concerning activated objects.

SAVEPOINT ADMIN Authorizes the execution of a savepoint process using the ALTER SYSTEM SAVEPOINT command.

SCENARIO ADMIN Authorizes all calculation scenario-related activities (including creation).

SERVICE ADMIN Authorizes the ALTER SYSTEM [START|CANCEL|RECONFIGURE] commands.

This privilege is for administering system services of the database

SESSION ADMIN authorizes the ALTER SYSTEM commands concerning sessions to stop or disconnect a user session or to change session variables.

STRUCTUREDPRIVILEGE ADMIN Authorizes the creation, reactivation, and dropping of structured privileges.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 315

Page 316: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

System Privilege Privilege Purpose Comment

TRACE ADMIN Authorizes the ALTER SYSTEM [CLEAR|REMOVE] TRACES commands for operations on database trace files and authorizes changing trace system settings.

TRUST ADMIN Authorizes commands to update the trust store.

USER ADMIN Authorizes the creation and modification of users using the CREATE USER, ALTER USER, and DROP USER commands.

VERSION ADMIN Authorizes the ALTER SYSTEM RECLAIM VERSION SPACE command of the multi-version concurrency control (MVCC) mechanism.

<identifier>.<identifier> Components of the SAP HANA database can create new system privileges. These privileges use the component-name as first identifier of the system privilege and the component-privilege-name as the second identifier.

<source_privilege> ::= CREATE VIRTUAL TABLE | DROP

Source privileges are used to restrict the access and modifications of a source entry.

CREATE VIRTUAL TABLE

This privilege allows the creation of proxy tables pointing to remote tables from the source entry.

Proxy tables are created in a schema and point to remote entries found in a source.

DROP

Authorizes the DROP REMOTE SOURCE command for the related source entry.

<schema_privilege> ::= CREATE ANY | DEBUG | DELETE | DROP | EXECUTE | INDEX | INSERT | SELECT | TRIGGER | UPDATE

Schema privileges are used to restrict the access and modifications on a schema and the objects stored in this schema. The following schema privileges are defined:

316P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 317: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

CREATE ANY

This privilege allows the creation of all kinds of objects, in particular, tables, views, sequences, synonyms, SQLScript functions, or database procedures in a schema.

DELETE, DROP, EXECUTE, INDEX, INSERT, SELECT, UPDATE

The specified privilege is granted on every object stored in the specified schema currently and in future. For detailed description of the privileges please see the part describing object privileges below and please check below, which privileges are applicable for which kind of object.

<object_privilege> ::= ALL PRIVILEGES | ALTER | DEBUG | DELETE | DROP | EXECUTE | INDEX | INSERT | SELECT | REFERENCES | TRIGGER | UPDATE | <identifier>.<identifier>

Object privileges are used to restrict the access and modifications on database objects. Database objects are tables, views, sequences, procedures, etc. The table below describes the supported object privileges.

Object Privilege Command Types Privilege Description Comment

ALL PRIVILEGES DDL & DML This privilege is a collection of all Data Definition Language(DDL) and Data Manipulation Language(DML) privileges that the grantor currently possesses and is allowed to grant further. The privilege it grants is specific to the particular object being acted upon.

This privilege collection is dynamically evaluated for the given grantor and object. ALL PRIVILEGES is applicable to a table or view

ALTER DDL Authorizes the ALTER command for the object

DEBUG DML Authorizes debug-functionality for the procedure or calculation view or for the procedures and calculation views of a schema.

DELETE DML Authorizes the DELETE and TRUNCATE commands for the object

DROP DDL Authorizes the DROP commands for the object

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 317

Page 318: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Object Privilege Command Types Privilege Description Comment

EXECUTE DML Authorizes the execution of an SQLScript function or a database procedure using the CALLS or CALL command respectively.

INDEX DDL Authorizes the creation, modification or dropping of indexes for the object

INSERT DML Authorizes the INSERT command for the object.

The INSERT and UPDATE privilege are both required on the object to allow the REPLACE and UPSERT commands to be used.

REFERENCES DDL Authorizes the usage of all tables in this schema or this table in a foreign key definition.

SELECT DML Authorizes the SELECT command for this object or the usage of a sequence.

TRIGGER DDL Authorizes the CREATE TRIGGER / DROP TRIGGER command for the specified table or the tables in the specified schema.

UPDATE DML Authorizes the UPDATE command for that object.

he INSERT and UPDATE privilege are both required on the object to allow the REPLACE and UPSERT commands to be used. The UPDATE privilege is also required to perform delta merges of column store tables using the MERGE DELTA command.

<identifier>.<identifier> DDL Components of the SAP HANA database can create new system privileges. These

318P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 319: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Object Privilege Command Types Privilege Description Comment

privileges use the component-name as first identifier of the system privilege and the component-privilege-name as the second identifier.

Not all object privileges are applicable to all kinds of database objects. For details of which object types allow which privilege to be used please see the table below.

Privilege Schema Table View Sequence Function/Procedure

ALL PRIVILEGES --- YES YES --- ---

ALTER YES YES --- --- YES

CREATE ANY YES --- --- --- ---

DEBUG YES --- YES --- YES

DELETE YES YES YES --- ---

DROP YES YES YES YES YES

EXECUTE YES --- --- --- YES

INDEX YES YES --- --- ---

INSERT YES YES YES --- ---

REFERENCES YES YES --- --- ---

SELECT YES YES YES YES ---

TRIGGER YES YES --- --- ---

UPDATE YES YES YES --- ---

DELETE, INSERT and UPDATE on views are valid for updatable views only. Updatable views have the following characteristics:

● Does not use a join● Does not contain a UNION● Does not use aggregation

DEBUG is only valid for calculation views.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 319

Page 320: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

For synonyms, the same restrictions apply to the synonym as they would do for the object the synonym represents.

<object_name> ::= <table_name> | <view_name> | <sequence_name> | <procedure_name> | <synonym_name>

Object privileges are used to restrict the access and modifications on database objects like tables, views, sequences, procedures and synonyms.

<grantee> :: = <user_name> | <role_name>

The grantee can be a user or a role. In case a privilege or role is granted to a role, then all user being granted that role, will have the specified privilege or role.

A role is a named collection of privileges and can be granted to either a user or a role.

If you want to allow several database users to perform the same actions, you should create a role, grant the needed privileges to this role, and finally grant the role to the different database users.

When granting roles to roles, a tree of roles can be build. When granting a role (R) to a role or user (G), G will have all privileges directly granted to R and all privileges granted to roles which had been granted to R.

<user_name> ::= <simple_identifier>

The grantee username.

<role_name> ::= <identifier>

The grantee role name.

<schema_name> ::= <identifier>

The schema containing the database object to be acted upon.

<table_name> ::= [<schema_name>.]<identifier>

The database table object name.

<view_name> ::= [<schema_name>.]<identifier>

The database view object name.

<sequence_name> ::= [<schema_name>.]<identifier>

The sequence object name.

<procedure_name> ::= [<schema_name>.]<identifier>

The procedure object name.

<synonym_name> ::= [<schema_name>.]<identifier>

320P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 321: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

The synonym name.

<privilege_name> ::= <identifier>

The name of the privilege to be granted.

WITH ADMIN OPTION and WITH GRANT OPTION

Specifies that the granted privileges can be granted further by the specified user or by those user having the specified role.

With GRANT STRUCTURED PRIVILEGE <privilege_name>

A previously defined analytical privilege based on a generic structured privilege is granted to a user or role. This analytical privileges is used to restrict the access for read operations to certain data in Analytic, Attribute, and Calculation Views by filtering the attribute values.

Description

GRANT is used to grant privileges and structured privileges to users and roles. GRANT is also used to grant roles to users and other roles.

The specified users, roles, objects, and structured privileges have to exist before they can be used in the GRANT command.

In order to use the GRANT command to grant privileges to other users and roles, a user must have the privilege and also the permissions required to grant that privilege.

A user can not grant a privilege to themselves.

User SYSTEM has at all system privileges and the role PUBLIC. All other users have the role PUBLIC. These privileges and roles cannot be revoked.

Although the SYSTEM user has many privileges, it cannot select or change data in other user's tables unless this privilege has been explicitly granted.

All users have the privilege to create objects in their own default schema. The default schema for a user always has the same schema name as the user.

For tables created by users, users have all privileges and may grant all privileges further to other users and roles.

For objects which are dependent on other objects, like views being dependent on tables, it can occur the owner of the dependent object does not have a complete set of privileges. This can occur if the user do not have the privileges on the underlying objects on which their object depends.

Users can have privileges on an object, but may not have sufficient privileges to grant them to other users and roles.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 321

Page 322: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

System Views

USERS : All users, their creator, creation date and some information about their current status.

ROLES : All roles, their creator and creation date.

GRANTED_ROLES : Roles that are granted to users or roles.

GRANTED_PRIVILEGES : Privileges that are granted to users or roles.

Examples

You create a schema called my_schema.

CREATE SCHEMA my_schema;

You create a table named work_done in the my_schema schema.

CREATE TABLE my_schema.work_done (t TIMESTAMP, user NVARCHAR (256), work_done VARCHAR (256));

You create a new user named worker with password His_Password_1.

CREATE USER worker PASSWORD His_Password_1;

You create role called role_for_work_on_my_schema.

CREATE ROLE role_for_work_on_my_schema;

You grant the SELECT on any object privilege in my_schema to the role role_for_work_on_my_schema.

GRANT SELECT ON SCHEMA my_schema TO role_for_work_on_my_schema;

You grant the INSERT privilege for the work_done table to the role role_for_work_on_my_schema.

GRANT INSERT ON my_schema.work_done TO role_for_work_on_my_schema;

You grant the role_for_work_on_my_schema role to the worker user.

GRANT role_for_work_on_my_schema TO worker WITH ADMIN OPTION;

You grant DELETE privilege for this table to the worker user.

GRANT DELETE ON my_schema.work_done TO worker;

You grant the worker user the privilege to create any kind of object in the my_schema schema.

GRANT CREATE ANY ON SCHEMA my_schema TO worker;

The result of the above commands is that the worker user has the privilege to SELECT all tables and views in schema my_schema, to INSERT into and DELETE from table my_schema.work_done and to create objects in schema my_schema. Additionally the worker user is allowed to grant DELETE on the table myschema.work_done to other users and roles.

322P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 323: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

You grant the privileges INIFILE ADMIN and TRACE ADMIN to the user worker. You grant these privileges along with the permission for the worker user to grant them further.

GRANT INIFILE ADMIN, TRACE ADMIN TO worker WITH ADMIN OPTION;

1.8.6.15 REVOKE

Syntax

REVOKE <system_privilege>,... FROM <grantee> | REVOKE <source_privilege>,... ON REMOTE SOURCE <source_name> FROM <grantee> | REVOKE <schema_privilege>,... ON SCHEMA <schema_name> FROM <grantee> | REVOKE <object_privilege>,... ON <object_name> FROM <grantee> | REVOKE <role_name>,... FROM <grantee> | REVOKE STRUCTURED PRIVILEGE <privilege_name> FROM <grantee>

Syntax Elements

For the definition of syntax elements, please refer to GRANT.

Description

The REVOKE statement revokes roles, or privileges, for the specified objects from a user or role.

For users without ROLE ADMIN privileges, only the user that granted a specific privilege can revoke it.

By default, the SYSTEM user has all the system privileges and the PUBLIC role, all other users have the PUBLIC role. These privileges and roles cannot be revoked.

If a user has been granted a role, it is not possible to revoke a subset of the privileges belonging to that role. If you want to grant just a subset of privileges contained within a role you should revoke the entire role and grant the required privileges separately instead.

Revoking a privilege or role can lead to some views becoming inaccessible or procedures that the user can no longer execute. This will occur if a view or procedures depends on a revoked privilege or on one of the privileges the role had.

Revoking a privilege that had been granted with WITH GRANT OPTION or with WITH ADMIN OPTION will result in recursive revocation of privileges. That is to say privileges will not only be revoked from the user specified in the command, but also from all the users and roles having been granted that privilege directly, or indirectly, by the specified user.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 323

Page 324: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Privileges can be granted to a target grantee user or role by different grantor users. Revocation of a privilege by one grantor user does not necessarily mean that the privilege will be lost by the target grantee user.

System Views

USERS : All users, their creator, creation date and some information about their current status.

ROLES : All roles, their creator and creation date.

GRANTED_ROLES : Roles that are granted to users or roles.

GRANTED_PRIVILEGES : Privileges that are granted to users or roles.

Example

You create new user named worker.

CREATE USER worker PASSWORD His_Password_1;

You create new role named role_for_work_on_my_schema.

CREATE ROLE role_for_work_on_my_schema;

You create new schema named my_schema.

CREATE SCHEMA my_schema OWNED BY system;

You create new table named work_done in the schema.

CREATE TABLE my_schema.work_done (t TIMESTAMP, user NVARCHAR (256), work_done VARCHAR (256) );

You grant the SELECT on any object privilege in my_schema to the role role_for_work_on_my_schema.

GRANT SELECT ON SCHEMA my_schema TO role_for_work_on_my_schema;

You grant the INSERT privilege for the work_done table to the role role_for_work_on_my_schema.

GRANT INSERT ON my_schema.work_done TO role_for_work_on_my_schema;

You grant the role_for_work_on_my_schema role to the worker user.

GRANT role_for_work_on_my_schema TO worker;

You grant TRACE ADMIN privilege for the worker user.

GRANT TRACE ADMIN TO worker WITH ADMIN OPTION;

You grant DELETE from work_done table to the worker user.

GRANT DELETE ON my_schema.work_done TO worker WITH GRANT OPTION;

324P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 325: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

You revoke from the role role_for_work_on_my_schema the privilege to select from my_schema.

REVOKE SELECT ON SCHEMA my_schema FROM role_for_work_on_my_schema;

You revoke TRACE ADMIN privilege from the worker.

REVOKE TRACE ADMIN FROM worker;

1.8.7 Data Import Export Statements

● EXPORT● IMPORT● IMPORT FROM● IMPORT SCAN

1.8.7.1 EXPORT

Syntax

EXPORT <object_name_list> AS <export_format> INTO <path> [WITH <export_option_list>]

Syntax Elements

<object_name_list> ::= {<object_name>[{, <object_name>}...] } | ALL

Specifies a list of objects that are to be exported. Optionally the ALL parameter can be used to export all objects in all schemas.

<object_name> ::= [<schema_name>.]{<identifier> | "*" } <schema_name> ::= <identifier>

You use [<schema_name>.]<identifier> to select specific objects in a schema for export. You use <schema_name>."*" to select all objects within a schema for export.

<export_import_format> ::= BINARY | CSV

The export format.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 325

Page 326: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Format type Details

BINARY Table data will be exported in internal binary format. Exporting in this format is orders of magnitude faster than exporting the same table in CSV format. Only column tables can be exported in binary format. Row tables are always exported in CSV format regardless of the format specified.

CSV Table data will be exported in CSV format. With this export format the exported data can be scrambled. Both column and row tables can be exported in CSV format.

<path> ::= <string_literal>

The server path where export files will be stored.

NoteWhen using a distributed system, the FULL_PATH must point to a shared disk. For security reasons, the path may not contain symbolic links and may not point inside the database instance folder, except its 'backup' and 'work' subfolders. Examples for valid export path (assuming the database instance is located at /usr/sap/HDB/HDB00):

'/tmp' '/usr/sap/HDB/HDB00/backup' '/usr/sap/HDB/HDB00/work'

WITH <export_option_list> <export_option_list> ::= <export_option> [{, <export_option>}] <export_option> ::= REPLACE | CATALOG ONLY | NO DEPENDENCIES | SCRAMBLE [BY <password>] | STRIP | THREADS <number_of_threads>

A list of export options.

REPLACE

REPLACE removes previously exported data on disk and replaces it with the new export. If the REPLACE option is not specified, an error will be thrown if previously exported data already exists in the specified export directory.

CATALOG ONLY

Only the database catalog will be exported.

NO DEPENDENCIES

The underlying dependencies of an export object will not be exported.

SCRAMBLE [BY <scramble_seed>] <scramble_seed> = <string_literal>

326P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 327: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Obfuscates CSV format exported data. This option can be used to provide an export of the structure of your database with the string data scrambled so that it cannot easily be interpreted. When the optional <scramble_seed> is not specified, a default scramble seed is used. SAP recommends that the <scramble_seed> should be at least 8 to 10 characters.

NoteOnly CSV format character string data will be scrambled by this parameter.

STRIP

Attributes that can be reconstructed at import time will not be stored in the export file. This option can reduce the size of the export file in some cases.

THREADS <number_of_threads> <number_of_threads> ::= <unsigned_integer>

The number of process threads to be used for concurrent export processing. For more information on this parameter see Export threads

Description

The EXPORT command exports tables, views, column views, synonyms, sequences, or procedures in the specified format as BINARY or CSV.

NoteData stored in temporary tables or "no logging" tables can only be exported in CSV format.

Detailed results of an export are stored in the session-local temporary table #EXPORT_RESULT.

Export threads

The THREADS parameter specifies how many objects will be exported in parallel, the default is 1. Increasing number of threads reduces export time, but can also negatively affect database system performance. Following items should be considered when using this parameter:

● When exporting a single table THREADS has no effect.● When exporting a view or procedure 2 or more threads should be used, up to the number of dependent

objects.● When exporting a whole schema consider using more than 10 threads. With a maximum being the number of

CPU cores in the system.● When exporting a whole BW / ERP system database with tens of thousands of tables using the ALL keyword,

a large number of threads can be used e.g. up to 256.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 327

Page 328: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

System Views

M_EXPORT_BINARY_STATUS : Monitor the progress of a running export.

NoteYou can abort an export session using the connection ID from the M_EXPORT_BINARY_STATUS view with the following command:

ALTER SYSTEM CANCEL [WORK IN] SESSION '<CONNECTION_ID>'

Examples

Simple export example.

You create new schema named MY_SCHEMA.

CREATE SCHEMA MY_SCHEMA; CREATE TABLE MY_SCHEMA.tab1 (A INT PRIMARY KEY, B INT);

You export the information from MY_SCHEMA tab1 in CSV format with the REPLACE and SCRAMBLE options enabled.

EXPORT MY_SCHEMA.tab1 AS CSV INTO '/tmp' WITH REPLACE SCRAMBLE THREADS 10

Selecting all objects within a schema.

You create two schemas and some tables within them.

CREATE SCHEMA a; CREATE TABLE a.tab1 (A INT PRIMARY KEY, B INT); CREATE TABLE a.tab2 (A INT PRIMARY KEY, B INT); CREATE SCHEMA b; CREATE TABLE b.tab1 (A INT PRIMARY KEY, B INT);

You export all the database objects in schema A and B, replacing any existing export that may be present in the tmp directory.

EXPORT a."*", b."*" AS CSV INTO '/tmp' WITH REPLACE

328P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 329: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

1.8.7.2 IMPORT

Syntax

IMPORT <object_name_list> FROM <path> [WITH <import_option_list>] [AT [LOCATION] <indexserver_host_port>]

Syntax Elements

<object_name_list> ::= {<object_name>[{, <object_name>}...] } | ALL

Specifies a list of objects that are to be imported. Optionally the ALL parameter can be used to import all objects in all schemas.

<path> ::= <string_literal>

The server path where the import files are stored.

NoteWhen using a distributed system, the FULL_PATH must point to a shared disk. Examples for import path, assuming the database instance is located at /usr/sap/HDB/HDB00:

'/tmp' '/usr/sap/HDB/HDB00/backup' '/usr/sap/HDB/HDB00/work'

WITH <import_option_list> <import_option_list> ::= <import_option> [{, <import_option>}] <import_option> ::= REPLACE | CATALOG ONLY | DATA ONLY | NO DEPENDENCIES | THREADS <number_of_threads>

A list of import options.

REPLACE

When specified, if a table defined in the import data currently exists in the database it will be dropped and recreated before the data is imported. If the REPLACE option is not specified an error will be thrown if an existing database table is defined in the import data.

CATALOG ONLY

Specifies that only the database catalog should be imported.

DATA ONLY

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 329

Page 330: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Specifies that only the data of the import file should be imported. This option can only be used when the existing table definitions in the database match with those of the data to be imported.

NoteFor BINARY export data, existing table data will be overwritten with the imported data. For CSV format data, the import data will be appended to existing table data.

NO DEPENDENCIES

When specified the underlying dependencies of an import object will not be imported.

THREADS <number_of_threads> <number_of_threads> ::= <unsigned_integer>

The number of process threads to be used for concurrent data import processing. For more information on this parameter see Number of threads to use

AT [LOCATION] <indexserver_host_port> <indexserver_host_port> ::= 'host_name:port_number'

It is possible to specify the index server at which tables are created and imported. If you specify the hostname and port, the tables will be created and imported on there. For more information on this parameter see Number of threads to use

Description

The IMPORT statement imports tables, views, column views, synonyms, sequences, or procedures. Data for temporary tables or "no logging" tables cannot be imported using IMPORT command.

NoteThe file format (BINARY | CSV) of the file being imported will be automatically detected.

Number of threads to use

The THREADS parameter specifies how many objects will be imported in parallel, the default is 1. Increasing number of threads reduces import time, but can also negatively affect database system performance. Following items should be considered when using this parameter:

● When importing a single table THREADS has no effect.● When importing a view or procedure 2 or more threads should be used, up to the number of dependent

objects.● When importing a whole schema consider using more than 10 threads. With a maximum being the number of

CPU cores in the system.● When importing a whole BW / ERP system database with tens of thousands of tables using the ALL keyword,

a large number of threads can be used e.g. up to 256.

330P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 331: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

System Views

M_IMPORT_BINARY_STATUS : Monitor the progress of a running import.

NoteYou can abort an import session using the connection ID from the M_IMPORT_BINARY_STATUS view with the following command:

ALTER SYSTEM CANCEL WORK IN SESSION '<CONNECTION_ID>'

The detailed result of the import is stored in session-local temporary tables. #IMPORT_RESULT.

Example

You import all tables from schema TESTSCH using the REPLACE option and 10 execution threads.

IMPORT "TESTSCH"."*" AS CSV FROM '/tmp' WITH REPLACE THREADS 10

See Also

ALTER SYSTEM CANCEL [WORK IN] SESSION

1.8.7.3 IMPORT FROM

Syntax

IMPORT FROM [<file_type>] <file_path> [INTO <table_name>] [WITH <import_from_option_list>] [AT [LOCATION] <indexserver_host_port>]

Syntax Elements

<file_type> ::= CSV FILE | CONTROL FILE

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 331

Page 332: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

The type of the file to be imported. You can specify either Comma-separated values or control file formats. For more information on CSV and control file formats, see Examples.

<file_path> ::= <string_literal>

The complete path and filename of the file to import.

<table_name> ::= [<schema_name>.]<identifier> <schema_name> ::= <identifier>

The target table name, with optional schema name, where the imported data will be stored.

WITH <import_from_option_list> <import_from_option_list> ::= <import_from_option>[{, <import_from_option>}...] <import_from_option> ::= THREADS <number_of_threads> | BATCH <number_of_records_of_each_commit> | TABLE LOCK | NO TYPE CHECK | SKIP FIRST <number_of_rows_to_skip> ROW | COLUMN LIST IN FIRST ROW | COLUMN LIST ( <column_name_list> ) | RECORD DELIMITED BY <string_for_record_delimiter> | FIELD DELIMITED BY <string_for_field_delimiter> | OPTIONALLY ENCLOSED BY <character_for_optional_enclosure> | DATE FORMAT <string_for_date_format> | TIME FORMAT <string_for_time_format> | TIMESTAMP FORMAT <string_for_timestamp_format> | ERROR LOG <file_path_of_error_log>

A list of import options.

THREADS <number_of_threads> <number_of_threads> ::= <unsigned_integer>

The number of threads that can be used for concurrent import. The default value is 1 and maximum allowed is 256.

BATCH <number_of_records_of_each_commit> <number_of_records_of_each_commit> ::= <unsigned_integer>

The number of records to be inserted in each commit.

NoteTHREADS and BATCH can be used to achieve high loading performance by enabling parallel loading and also by committing many records at once. In general, for column tables, a good setting to use is 10 parallel loading threads, with a commit frequency of 10,000 records or greater.

TABLE LOCK

Uses table locks for fast import of column store tables.

NO TYPE CHECK

Specifies that the record will be inserted without checking the type of each field.

SKIP FIRST <number_of_rows_to_skip> ROW <number_of_rows_to_skip> ::= <unsigned_integer>

332P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 333: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Skips the specified number of rows in the import file.

COLUMN LIST IN FIRST ROW

Indicates that the column list is stored in the first row of the CSV import file.

COLUMN LIST ( <column_name_list> ) <column_name_list> ::= <column_name> [{, <column_name>}...] <column_name> ::= <string_literal>

The column list for the data being imported. The name list has one or more column names. The ordering of the column names has to match the order of the column data in the CSV file and the columns in the target table.

RECORD DELIMITED BY <string_for_record_delimiter> <string_for_record_delimiter> ::= <string_literal>

The record delimiter used in the CSV file being imported.

FIELD DELIMITED BY <string_for_field_delimiter> <string_for_field_delimiter> ::= <string_literal>

The field delimiter of the CSV file.

OPTIONALLY ENCLOSED BY <character_for_optional_enclosure> <character_for_optional_enclosure> ::= <character_literal>

The optional enclosure character used to delimit field data.

DATE FORMAT <string_for_date_format> <string_for_date_format> ::= <string_literal>

The format that date strings are encoded with in the import data.

Y : year , MM : month , MON : name of month, DD : day

For example:

● 'YYYYMMDD' = 20120520● 'YYYY-MM-DD' = 2012-05-20● 'YYYY-MON-DD' : 2012-MAY-20

For more information on date format strings, see Date Formats

TIME FORMAT <string_for_time_format> <string_for_time_format> ::= <string_literal>

The format that time strings are encoded with in the import data.

HH24 : hour , MI : minute , SS : second

For example:

'HH24MISS' : 143025 , 'HH24:MI:SS' : 14:30:25

For more information on time format strings, see Time Formats

TIMESTAMP FORMAT <string_for_timestamp_format> <string_for_timestamp_format> ::= <string_literal>

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 333

Page 334: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

The format that timestamp strings are encoded with in the import data.

For example:

● 'YYYY-MM-DD HH24:MI:SS' : 2012-05-20 14:30:25

ERROR LOG <file_path_of_error_log> <file_path_of_error_log> ::= <string_literal>

When specified a log file of errors generated will be stored in this file. Please ensure the file path you use is writeable by the database.

AT [LOCATION] <indexserver_host_port> <indexserver_host_port> ::= 'host_name:port_number'

It is possible to specify the index server at which tables are created and imported. If you specify the hostname and port, the tables will be created and imported on there. If no locations are specified, the tables will be created and imported following a certain internal mechanism (by default round-robin). You can specify the location only for IMPORT command (not for EXPORT) and it is not allowed to specify multiple locations to be imported.

Description

The IMPORT FROM statement imports external data from a file into an existing table.

NoteAll <string_literal>s in the <import_from_option> support UTF-8 except surrogate-pair encoding.

Examples

Example 1 -Importing CSV data

You create a table MYTABLE to store the imported data.

CREATE TABLE MYTABLE ( A INT, B VARCHAR(10), C DATE, D TIME, E DECIMAL );

You create a CSV text file /data/data.csv and add the following contents.

1,"DATA1","2012-05-20","14:30:25",123456 2,"DATA2","2012-05-21","15:30:25",234567 3,"DATA3","2012-05-22","16:30:25",345678 4,"DATA4","2012-05-23","17:30:25",456789

You execute the following command to import the data.

IMPORT FROM CSV FILE '/data/data.csv' INTO "MYTABLE" WITH RECORD DELIMITED BY '\n' FIELD DELIMITED BY ',';

Example 2 - Importing using a control file

In the example below you import the CSV data from Example 1 using a control file:

334P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 335: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

You can create a control file /data/data.ctl and add the contents shown below to the file.

IMPORT DATA INTO TABLE "MYTABLE" FROM '/data/data.csv' RECORD DELIMITED BY '\n' FIELD DELIMITED BY ',' OPTIONALLY ENCLOSED BY '"' ERROR LOG '/data/data.err'

You execute the following command to import the data using the control file.

IMPORT FROM CONTROL FILE '/data/data.ctl';

Example 3 - Import using date formats

In the example below the date format is of the CSV import data is different to the default date format 'YYYY-MM-DD'. In this import data the date format used is 'MM-DD-YYYY'.

You create a CSV text file /data/data_different_date.csv and add the following contents.

1,"DATA1","05-20-2012","14:30:25",123456 2,"DATA2","05-21-2012","15:30:25",234567 3,"DATA3","05-22-2012","16:30:25",345678 4,"DATA4","05-23-2012","17:30:25",456789

You execute the following command to import the data.

IMPORT FROM CSV FILE '/data/data_different_date.csv' INTO "MYTABLE" WITH RECORD DELIMITED BY '\n' FIELD DELIMITED BY ',' DATE FORMAT 'MM-DD-YYYY';

Example 4 - Import using COLUMN LIST

You create a table called COLLIST to store the imported data.

CREATE TABLE COLLIST ( A INT, B VARCHAR(10), c DATE, D DECIMAL );

You create a CSV text file '/data/data_col_list.csv' and add the following contents.

1,"DATA1","2012-05-20",123456 2,"DATA2","2012-05-21",234567 3,"DATA3","2012-05-22",345678 4,"DATA4","2012-05-23",456789

You execute the following commands to import the data using a column list.

IMPORT FROM CSV FILE '/data/data_col_list.csv' INTO "COLLIST" WITH RECORD DELIMITED BY '\n' FIELD DELIMITED BY ',' COLUMN LIST ("A", "B", "D");

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 335

Page 336: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

1.8.7.4 IMPORT SCAN

Syntax

IMPORT SCAN <path>

Syntax Elements

<path> ::= <string_literal>

The path of the directory to be scanned for import data.

Description

The IMPORT SCAN statement scans the path and fills the session-local temporary table #IMPORT_SCAN_RESULT with the contents in the path.

Example

You scan the path '/data/import_path' for import data.

IMPORT SCAN '/data/import_path'

You select the data in the #IMPORT_SCAN_RESULT table to view the result of the scan.

SELECT * FROM #IMPORT_SCAN_RESULT;

1.8.8 Procedural Statements

● ALTER PROCEDURE RECOMPILE● CALL● CREATE FUNCTION● CREATE PROCEDURE● CREATE TYPE

336P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 337: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

● DROP FUNCTION● DROP PROCEDURE● DROP TYPE

1.8.8.1 ALTER PROCEDURE RECOMPILE

Syntax

ALTER PROCEDURE <proc_name> RECOMPILE [WITH PLAN]

Syntax Elements

<proc_name> ::= [<schema_name>.]<identifier> <schema_name> ::= <identifier>

The identifier of the procedure to be altered, with optional schema name.

WITH PLAN

Specifies that internal debug information should be created during execution of the procedure.

Description

The ALTER PROCEDURE RECOMPILE statement manually triggers a recompilation of a procedure by generating an updated execution plan. For production code a procedure should be compiled without the WITH PLAN option to avoid overhead during compilation and execution of the procedure.

Example

You trigger the recompilation of the my_proc procedure to produce debugging information.

ALTER PROCEDURE my_proc RECOMPILE WITH PLAN;

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 337

Page 338: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

1.8.8.2 CALL

Syntax

CALL <proc_name> (<param_list>) [WITH OVERVIEW] [IN DEBUG MODE]

Syntax Elements

<proc_name> ::= [<schema_name>.]<identifier> <schema_name> ::= <identifier>

The identifier of the procedure to be called, with optional schema name.

<param_list> ::= <proc_param>[{, <proc_param>}...]

Specifies one or more procedure parameters.

<proc_param> ::= <identifier> | <string_literal> | <unsigned_integer> | <signed_integer>| <signed_numeric_literal> | <unsigned_numeric_literal>

Procedure parameters. For more information on these data types please see BNF Lowest Terms Representations and Data Types.

Parameters passed to a procedure are scalar constants and can be passed either as IN, OUT or INOUT parameters. Scalar parameters are assumed to be NOT NULL. Arguments for IN parameters of table type can either be physical tables or views. The actual value passed for tabular OUT parameters must be`?`.

WITH OVERVIEW

Defines that the result of a procedure call will be stored directly into a physical table.

Calling a procedure WITH OVERVIW will return one result set that holds the information of which table contains the result of a particular table's output variable. Scalar outputs will be represented as temporary tables with only one cell. When you pass existing tables to the output parameters WITH OVERVIEW will insert the result set tuples of the procedure into the provided tables. When you pass NULL to the output parameters, temporary tables holding the result sets will be generated. These tables will be dropped automatically once the database session is closed.

IN DEBUG MODE

When specified additional debug information will be created during the execution of the procedure. This information can be used to debug the instantiation of the internal execution plan of the procedure.

Note

338P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 339: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

that this type of call implies additional runtime overhead and so it should only be used for debugging purposes.

Description

Calls a procedure defined with CREATE PROCEDURE.

CALL conceptually returns list of result sets with one entry for every tabular result. An iterator can be used to iterate over these results sets. For each result set you can iterate over the result table in the same way as for query results. SQL statements that are not assigned to any table variable in the procedure body will be added as result sets at the end of the list of result sets. The type of the result structures will be determined during compilation time but will not be visible in the signature of the procedure.

CALL when executed by the client the syntax behaves in a way consistent with the SQL standard semantics, e.g. Java clients can call a procedure using a JDBC CallableStatement. Scalar output variables will be a scalar value that can be retrieved from the callable statement directly.

NoteUnquoted identifiers are implicitly treated as upper case. Quoting identifiers will respect capitalization and allow for using white spaces which are normally not allowed in SQL identifiers.

Examples

You call the getOutput procedure in debug mode.

CALL getOutput (1000, 'EUR', NULL, NULL) IN DEBUG MODE;

You call the procedure getOutput using the WITH OVERVIEW option.

CALL getOutput(1000, 'EUR', ot_publishers, NULL) WITH OVERVIEW;

1.8.8.3 CREATE FUNCTION

Syntax

CREATE FUNCTION <func_name> [(<parameter_clause>)] RETURNS <return_type> [LANGUAGE <lang>] [SQL SECURITY <mode>] AS BEGIN

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 339

Page 340: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

<function_body> END

NoteUser defined functions are read-only functions that are free of side effects. That is to say that DDL or DML statements are not allowed within the function body.

Syntax Elements

<func_name > ::= [<schema_name>.]<identifier> <schema_name> ::= <identifier>

The identifier of the function to be created, with optional schema name.

<parameter_clause> ::= <parameter> [{,<parameter>}...]

The input parameters of the function.

<parameter> ::= [IN] <param_name> <datatype>

A function parameter with associated data type.

<param_name> ::= <identifier>

The variable name for a parameter.

<datatype> ::= <sql_type> | <table_type>

The input parameters of a function can have any of the primitive SQL types or a table type.

<sql_type> ::= BIGINT | INTEGER | SMALLINT | TINYINT | DATE | TIME | TIMESTAMP | SMALLDECIMAL | DECIMAL | REAL | DOUBLE

The data type of the variable. Please see Data Types.

<table_type> ::= <identifier>

A table type previously defined with the CREATE TYPE command. Please see CREATE TYPE.

<return_type> ::= <return_parameter_list> | <return_table_type>

The function must return scalar values specified in <return_parameter_list> or a result set specified in <return_table_type>. The function returning scalar values is called a scalar-valued function, which can be used in expressions of SQL statements like other built-in SQL functions. The function returning a table is called a table-valued function, which can be referenced in the FROM clause of a SELECT statement like a table. In SP6,

<return_parameter_list> ::= <return_parameter>[{, <return_parameter>}] <return_parameter> ::= <parameter_name> <sql_type>

340P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 341: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Defines the output parameters

<return_table_type> ::= TABLE (<ret_column_list>)

Defines the structure of the returned table data.

<ret_column_list> ::= <ret_column_elem>[{, <ret_column_elem>}]

Defines the list of columns returned from the function.

<ret_column_elem> ::= <column_name> <sql_type> <column_name> ::= <identifier>

Defines the name of column element with associated datatype.

LANGUAGE <lang> <lang> ::= SQLSCRIPT

Default: SQLSCRIPT

Defines the programming language used in the function.

NoteOnly SQLScript functions can currently be defined.

SQL SECURITY <mode> <mode> ::= DEFINER | INVOKER

Default: DEFINER

Specifies the security mode of the function.

DEFINER

Specifies that the execution of the function is performed with the privileges of the definer of the function.

INVOKER

Specifies that the execution of the function is performed with the privileges of the invoker of the function.

<function_body> ::= <scalar_function_body>|<table_function_body>

<scalar_function_body> ::= [DECLARE <func_var>] <proc_assign>

<table_function_body> ::= [<func_block_decl_list>] [<func_handler_list>] <func_stmt_list> <func_return_statement>

Defines the main body of the table function and scalar function. As the function is flagged as read-only, neither DDL or DML statements (INSERT, UPDATE, and DELETE) are allowed in the function body.

A scalar-value function does not support table-typed variables as its input and table operations in the function body.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 341

Page 342: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

For the definition of <proc_assign>, see CREATE PROCEDURE.

<func_block_decl_list> ::= DECLARE (<func_var>|<func_cursor>|<func_condition>) <func_var> ::= <variable_name> [CONSTANT] (<sql_type>|<array_datatype>) [NOT NULL][<func_default>]; <array_datatype> ::= <sql_type> ARRAY [ := <array_constructor> ] <array_constructor> ::= ARRAY (<value_expression> [{,<value_expression>}...]) <func_default> ::= (DEFAULT|':=')<func_expr> <func_expr> !!= An element of the type specified by <sql_type>

Defines one or more local variables with associated scalar type or array type.

An array type has <type> as its element type. An Array has a range from 1 to 2,147,483,647, which is the limitation of underlying structure.

You can assign default values by specifying <value_expression>s. See Data Types.

<func_handler_list> ::= <proc_handler_list>

Please see CREATE PROCEDURE.

<func_stmt_list> ::= <func_stmt>| <func_stmt_list> <func_stmt> <func_stmt> ::= <proc_block> | <proc_assign> | <proc_single_assign> | <proc_if> | <proc_while> | <proc_for> | <proc_foreach> | <proc_exit> | <proc_signal> | <proc_resignal> | <proc_open> | <proc_fetch> | <proc_close>

For further information of the definitions in <func_stmt> see CREATE PROCEDURE.

<func_return_statement> ::= RETURN <function_return_expr> <func_return_expr> ::= <table_variable> | <select_stmt>

A table function must contain a return statement.

Description

The CREATE FUNCTION statement creates a read only function which is free of side-effects. That is to say that neither DDL or DML statements (INSERT, UPDATE, and DELETE) are allowed in the function body.

Also functions or procedures selected/called from the body of the function must also be read-only.

In SP6, a scalar-valued function does not support table-typed variables as its input and table operations in the function body.

342P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 343: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Example

You create an SQLScript table function with the following definition.

CREATE FUNCTION scale (val INT) RETURNS TABLE (a INT, b INT) LANGUAGE SQLSCRIPT AS BEGIN RETURN SELECT a, :val * b AS b FROM mytab; END;

You use the scale function like a table. Please see the following example:

select * from scale(10); select * from scale(10) as a, scale(10) as b where a.a = b.a

You also create an SQLScript scalar function with the following definition.

CREATE FUNCTION func_add_mul(x Double, y Double) RETURNS result_add Double, result_mul Double LANGUAGE SQLSCRIPT READS SQL DATA AS BEGIN result_add := :x + :y; result_mul := :x * :y; END;

You use the func_add_mul function like a built-in function. Please see the following example:

CREATE TABLE TAB (a Double, b Double); INSERT INTO TAB VALUES (1.0, 2.0); INSERT INTO TAB VALUES (3.0, 4.0); SELECT a, b, func_add_mul(a, b).result_add as ADD, func_add_mul(a, b).result_mul as MUL FROM TAB ORDER BY a;

A B ADD MUL ------------------- 1 2 3 2 3 4 7 12

1.8.8.4 CREATE PROCEDURE

Syntax

CREATE PROCEDURE <proc_name> [(<parameter_clause>)] [LANGUAGE <lang>] [SQL SECURITY <mode>] [DEFAULT SCHEMA <default_schema_name>] [READS SQL DATA [WITH RESULT VIEW <view_name>]] AS BEGIN [SEQUENTIAL EXECUTION] <procedure_body> END

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 343

Page 344: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Syntax Elements

<proc_name > ::= [<schema_name>.]<identifier> <schema_name> ::= <identifier>

The identifier of the procedure to be created, with optional schema name.

<parameter_clause> ::= <parameter> [{,<parameter>}...]

The input and output parameters of the procedure.

<parameter> ::= [<param_inout>] <param_name> <datatype>

A procedure parameter with associated data type.

<param_inout> ::= IN|OUT|INOUT

Default: IN

Each parameter is marked using the keywords IN/OUT/INOUT. Input and output parameters must be explicitly typed (i.e. no un-typed tables are supported).

<param_name> ::= <identifier>

The variable name for a parameter.

<datatype> ::= <sql_type> | <table_type>

The input and output parameters of a procedure can have any of the primitive SQL types or a table type. INOUT parameters can only be of scalar type.

<sql_type> ::= DATE | TIME| TIMESTAMP | SECONDDATE | TINYINT | SMALLINT | INTEGER | BIGINT | DECIMAL | SMALLDECIMAL | REAL | DOUBLE | VARCHAR | NVARCHAR | ALPHANUM | VARBINARY | CLOB | NCLOB | BLOB

The data type of the variable. Please see Data Types.

<table_type> ::= <identifier>

A table type previously defined with the CREATE TYPE command. Please see CREATE TYPE.

LANGUAGE <lang> <lang> ::= SQLSCRIPT | R

Default: SQLSCRIPT

Defines the programming language used in the procedure. It is good practice to define the language in all procedure definitions.

SQL SECURITY <mode> <mode> ::= DEFINER | INVOKER

Default: DEFINER

344P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 345: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Specifies the security mode of the procedure.

DEFINER

Specifies that the execution of the procedure is performed with the privileges of the definer of the procedure.

INVOKER

Specifies that the execution of the procedure is performed with the privileges of the invoker of the procedure.

DEFAULT SCHEMA <default_schema_name> <default_schema_name> ::= <identifier>

Specifies the schema for unqualified objects in the procedure body. If nothing is specified, then the current_schema of the session is used.

READS SQL DATA

Marks the procedure as being read-only, side-effect free i.e. the procedure does not make modifications to the database data or its structure. This means that the procedure does not contain DDL or DML statements, and that the procedure only calls other read-only procedures. The advantage of using this parameter is that certain optimizations are available for read-only procedures.

WITH RESULT VIEW <view_name> <view_name> ::= <identifier>

Specifies the result view to be used as the output of a read-only procedure.

When a result view is defined for a procedure, it can be called by an SQL statement in the same way as a table or view. Please see Example 2 - Using a result view below.

SEQUENTIAL EXECUTION

This statement will force sequential execution of the procedure logic. No parallelism takes place.

<procedure_body> := [<proc_block_decl_list>] [<proc_handler_list>] <proc_stmt_list>

Defines the main body of the procedure according to the programming language selected.

<proc_block_decl_list> ::= DECLARE (<proc_var>|<proc_cursor>|<proc_condition>) <proc_var> ::= <variable_name_list> [CONSTANT] (<sql_type>|<array_datatype>) [NOT NULL][<proc_default>]; <variable_name_list> ::= <variable_name>[{, <variable_name}...] <array_datatype> ::= <sql_type> ARRAY [ := <array_constructor> ] <array_constructor> ::= ARRAY (<value_expression> [{,<value_expression>}...])

<proc_var> ::= <variable_name> [CONSTANT] (<sql_type>|<array_datatype>) [NOT NULL][<proc_default>]; <array_datatype> ::= <sql_type> ARRAY [ := <array_constructor> ] <array_constructor> ::= ARRAY (<value_expression> [{,<value_expression>}...])

<proc_cursor> ::= CURSOR <cursor_name> ['(' proc_cursor_param_list ')'] FOR <select_stmt> <proc_cursor_param_list> ::= <proc_cursor_param> | <proc_cursor_param_list> ',' <proc_cursor_param>

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 345

Page 346: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

<cursor_name> ::= <identifier>

<proc_condition> ::= <variable_name> CONDITION | <variable_name> CONDITION FOR <sql_error_code>

Condition handler declaration.

<proc_handler_list> ::= <proc_handler> [{, <proc_handler>}...] <proc_handler> ::= DECLARE EXIT HANDLER FOR <proc_condition_value_list> <proc_stmt>

Declares exception handlers to catch SQL exceptions.

<proc_condition_value_list> ::= <proc_condition_value> [{, <proc_condition_value>}]

One or more condition values.

<proc_condition_value> ::= SQLEXCEPTION | SQLWARNING | <sql_error_code> | <condition_name>

You can use a specific error code number or condition name declared on condition variable.

<proc_stmt_list> := {<proc_stmt>}...

<proc_stmt> ::= <proc_block> | <proc_assign> | <proc_single_assign> | <proc_if> | <proc_loop> | <proc_while> | <proc_for> | <proc_foreach> | <proc_exit> | <proc_continue> | <proc_signal> | <proc_resignal> | <proc_sql> | <proc_open> | <proc_fetch> | <proc_close> | <proc_call> | <proc_exec> | <proc_return>

Procedure body statements.

<proc_block> ::= BEGIN [SEQUENTIAL EXECUTION] [<proc_decl_list>] [<proc_handler_list>] <proc_stmt_list> END ;

Sections of your procedures can be nested using BEGIN and END terminals.

<proc_assign> ::= <variable_name> ':=' <proc_expr> | <variable_name> '[' <expr> ']' ':=' <proc_expr>

Assign values to variables.

<func_array> := ARRAY_AGG '(' <table_variable>.<column_name> [ ORDER BY <sort_spec_list> ] ')'

346P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 347: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

| CARDINALITY '(' <array_variable_name>')' | TRIM_ARRAY '(' <array_variable_name> ',' <array_variable_name>')' | ARRAY '(' <array_variable_name_list> ')'

<table_variable> ::= <identifier> <column_name> ::= <identifier> <array_variable_name> ::= <identifier>

The ARRAY_AGG function returns the array by aggregating the set of elements in the specified column of the table variable. Elements can optionally be ordered.

The CARDINALITY function returns the number of the elements in the array, <array_variable_name>.

The TRIM_ARRAY function returns the new array by removing the given number of elements, <numeric_value_expression>, from the end of the array, <array_value_expression>.

The ARRAY function returns an array whose elements are specified in the list <array_variable_name>. For more information see the "SQLScript reference".

<proc_single_assign> ::= <variable_name> '=' <proc_dml_select> | <variable_name> '=' <proc_ce_call> | <variable_name> '=' <proc_apply_filter> | <variable_name> '=' <func_unnest>

<proc_dml_select> ::= <select_stmt>

<proc_ce_call> ::= TRACE '(' <variable_name> ')' | CE_LEFT_OUTER_JOIN '(' <table_variable> ',' <table_variable> ',' '[' expr_alias_comma_list ']' [ <expr_alias_vector>] ')' | CE_RIGHT_OUTER_JOIN '(' <table_variable> ',' <table_variable> ',' '[' expr_alias_comma_list ']' [ <expr_alias_vector>] ')' | CE_FULL_OUTER_JOIN '(' <table_variable> ',' <table_variable> ',' '[' expr_alias_comma_list ']' [ <expr_alias_vector>] ')' | CE_JOIN '(' <table_variable> ',' <table_variable> ',' '[' expr_alias_comma_list ']' [<expr_alias_vector>] ')' | CE_UNION_ALL '(' <table_variable> ',' <table_variable> ')' | CE_COLUMN_TABLE '(' <table_name> [ <expr_alias_vector>] ')' | CE_JOIN_VIEW '(' <table_name> [ <expr_alias_vector>] ')' | CE_CALC_VIEW '(' <table_name> [ <expr_alias_vector>] ')' | CE_OLAP_VIEW '(' <table_name> [ <expr_alias_vector>] ')' | CE_PROJECTION '(' <table_variable> ',' '[' <expr_alias_comma_list> ']' <opt_str_const> ')' | CE_PROJECTION '(' <table_variable> <opt_str_const> ')' | CE_AGGREGATION '(' <table_variable> ',' '[' <agg_alias_comma_list> ']' [ <expr_alias_vector>] ')' | CE_CONVERSION '(' <table_variable> ',' '[' <proc_key_value_pair_comma_list> ']' [ <expr_alias_vector>] ')' | CE_VERTICAL_UNION '(' <table_variable> ',' '[' <expr_alias_comma_list> ']' <vertical_union_param_pair_list> ')' | CE_COMM2R '(' <table_variable> ',' <int_const> ',' <str_const> ',' <int_const> ',' <int_const> ',' <str_const> ')'

<table_nam> ::= [<schema_name>.]<identifier> <schema_name> ::= <identifier>

For more information about the CE-Operators, see "SQLScript reference".

<proc_apply_filter> ::= APPLY_FILTER '(' (<table_name> | <table_variable>), <variable_name> ')'

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 347

Page 348: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

APPLY_FILTER defines a dynamic WHERE condition <variable_name> that will be applied during runtime. For more information about APPLY_FILTER please see the "SQLScript reference".

<func_unnest> ::= UNNEST '(' <variable_name_list> ')' [ WITH ORDINALITY ] [<as_col_names>]

<variable_name_list> ::= <variable_name> [{, <variable_name>}...]

<as_col_names> ::= AS [table_name] '(' <column_name_list> ')'

The UNNEST function returns a table including a row for each element of the specified array.

[WITH ORDINALTIY]

Appends an ordinal column to the return values.

<as_col_names> ::= <col_name> [{, <col_name>}...]

Specifies the column names of the return table.

<proc_if> ::= IF <condition> THEN [SEQUENTIEL EXECUTION][<proc_decl_list>] [<proc_handler_list>] <proc_stmt_list> [<proc_elsif_list>] [<proc_else>] END IF ;

<proc_elsif_list> ::= ELSEIF <condition> THEN [SEQUENTIEL EXECUTION][<proc_decl_list>] [<proc_handler_list>] <proc_stmt_list>

<proc_else> ::= ELSE [SEQUENTIEL EXECUTION][<proc_decl_list>] [<proc_handler_list>] <proc_stmt_list>

You use IF - THEN - ELSE IF to control execution flow with conditionals.

<proc_loop> ::= LOOP [SEQUENTIEL EXECUTION][<proc_decl_list>] [<proc_handler_list>] <proc_stmt_list> END LOOP ;

You use loop to repeatedly execute a set of statements.

<proc_while> ::= WHILE <condition> DO [SEQUENTIEL EXECUTION][<proc_decl_list>] [<proc_handler_list>] <proc_stmt_list> END WHILE ;

You use while to repeatedly call a set of trigger statements while a condition is true.

<proc_for> ::= FOR <column_name> IN [ REVERSE ] <expression> [...] <expression> DO [SEQUENTIEL EXECUTION][<proc_decl_list>] [<proc_handler_list>] <proc_stmt_list> END FOR ;

You use FOR - IN loops to iterate over a set of data.

<proc_foreach> ::= FOR <column_name> AS <column_name> [<open_param_list>] DO [SEQUENTIEL EXECUTION][<proc_decl_list>] [<proc_handler_list>] <proc_stmt_list> END FOR ;

<open_param_list> ::= '(' <expr_list> ')'

<expr_list> ::= <expression> | <expr_list> , <expression>

348P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 349: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

You use FOR - EACH loops to iterate over all elements in a set of data.

<proc_exit> ::= BREAK

Terminates a loop.

<proc_continue> ::= CONTINUE

Skips a current loop iteration and continues with the next value.

<proc_signal> ::= SIGNAL <signal_value> [<set_signal_info>] ;

You use the SIGNAL statement to explicitly raise an exception from within your trigger procedures.

<proc_resignal> ::= RESIGNAL [<signal_value>] [<set_signal_info>] ;

You use the RESIGNAL statement to raise an exception on the action statement in an exception handler. If an error code is not specified, RESIGNAL will throw the caught exception.

<signal_value> ::= <signal_name> | <sql_error_code> <signal_name> ::= <identifier> <sql_error_code> ::= <unsigned_integer>

You can SIGNAL or RESIGNAL a signal name or an SQL error code.

<set_signal_info> ::= SET MESSAGE_TEXT = '<message_string>' <message_string> ::= <any_character>

You use SET MESSAGE_TEXT to deliver an error message to users when specified error is thrown during procedure execution.

<proc_sql> ::= <select_stmt> | <select_into_stmt> | <insert_stmt> | <delete_stmt> | <update_stmt> | <replace_stmt> | <call_stmt> | <create_table> | <drop_table>

For information on <insert_stmt>, see INSERT.

For information on <delete_stmt>, see DELETE.

For information on <update_stmt>, see UPDATE.

For information on <replace_stmt> and <upsert_stmt>, see REPLACE | UPSERT

<select_into_stmt> ::= SELECT <select_list> INTO <var_name_list> <from_clause > [<where_clause>] [<group_by_clause>] [<having_clause>] [{<set_operator> <subquery>, ... }] [<order_by_clause>] [<limit>]

<var_name_list> ::= <var_name> | <var_name_list> , <var_name>

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 349

Page 350: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

<var_name> ::= <identifier>

For information on <select_list>, <from_clause>, <where_clause>, <group_by_clause>, <having_clause>, <set_operator>, <subquery, <order_by_clause> and <limit> see SELECT.

<var_name_list> ::= <var_name>[{, <var_name>}] <var_name> ::= <identifier>

<var_name> is scalar variable. You can assign selected item value to this scalar variable.

<proc_open> ::= OPEN <cursor_name> [proc_open_param_list]

<proc_fetch> ::= FETCH <cursor_name> INTO <column_name_list>

<proc_close> ::= CLOSE <cursor_name>

Cursor operations.

<proc_exec> ::= EXEC [IMMEDIATE] <proc_expr>

You use EXEC to make dynamic SQL calls.

<proc_return> ::= RETURN [<proc_expr>]

Return a value from a procedure.

For more information about SQLScript please see the "SQLScript reference". For more information on the R-Language please see the "R-Language reference". Both reference documents are available from the SAP HANA Appliance page.

Description

The CREATE PROCEDURE statement creates a procedure using the specified programming language <lang>.

Examples

Example 1 - Creating an SQL Procedure

You create an SQLScript procedure with the following definition.

CREATE PROCEDURE orchestrationProc LANGUAGE SQLSCRIPT AS BEGIN DECLARE v_id BIGINT; DECLARE v_name VARCHAR(30); DECLARE v_pmnt BIGINT; DECLARE v_msg VARCHAR(200); DECLARE CURSOR c_cursor1 (p_payment BIGINT) FOR SELECT id, name, payment FROM control_tab WHERE payment > :p_payment ORDER BY id ASC; CALL init_proc();

350P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 351: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

OPEN c_cursor1(250000); FETCH c_cursor1 INTO v_id, v_name, v_pmnt; v_msg := :v_name || ' (id ' || :v_id || ') earns ' || :v_pmnt || ' $.'; CALL ins_msg_proc(:v_msg); CLOSE c_cursor1; END;

The procedure features a number of imperative constructs including the use of a cursor (with associated state) and local scalar variables with assignments.

Example 2 - Using a result view

You create a procedure using a result view ProcView to return its results.

CREATE PROCEDURE ProcWithResultView(IN id INT, OUT o1 CUSTOMER) LANGUAGE SQLSCRIPT READS SQL DATA WITH RESULT VIEW ProcView AS BEGIN o1 = SELECT * FROM CUSTOMER WHERE CUST_ID = :id; END;

You call this procedure from an SQL statement as follows.

SELECT * FROM ProcView WITH PARAMETERS ('placeholder' = ('$$id$$', '5'));

1.8.8.5 CREATE TYPE

Syntax

CREATE TYPE <type_name> AS TABLE (<column_definition>[{,<column_definition>}...])

Syntax Elements

<type_name> ::= [<schema_name>.]<identifier> <schema_name> ::= <identifier>

Identifies the table type to be created and, optionally, in which schema the creation should take place.

<column_definition> ::= <column_name> <data_type> [<column_store_data_type>] [<ddic_data_type>]

Defines a table column.

<column_name> ::= <identifier>

19

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 351

Page 352: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

The table column name.

<data_type> ::= DATE | TIME | SECONDDATE | TIMESTAMP | TINYINT | SMALLINT | INTEGER | BIGINT | SMALLDECIMAL | DECIMAL | REAL | DOUBLE | VARCHAR | NVARCHAR | ALPHANUM | SHORTTEXT | VARBINARY | BLOB | CLOB | NCLOB | TEXT

<column_store_data_type> ::= CS_ALPHANUM | CS_INT | CS_FIXED | CS_FLOAT | CS_DOUBLE | CS_DECIMAL_FLOAT | CS_FIXED(p-s, s) | CS_SDFLOAT | CS_STRING | CS_UNITEDECFLOAT | CS_DATE | CS_TIME | CS_FIXEDSTRING | CS_RAW | CS_DAYDATE | CS_SECONDTIME | CS_LONGDATE | CS_SECONDDATE

<ddic_data_type> ::= DDIC_ACCP | DDIC_ALNM | DDIC_CHAR | DDIC_CDAY | DDIC_CLNT | DDIC_CUKY | DDIC_CURR | DDIC_D16D | DDIC_D34D | DDIC_D16R | DDIC_D34R | DDIC_D16S | DDIC_D34S | DDIC_DATS | DDIC_DAY | DDIC_DEC | DDIC_FLTP | DDIC_GUID | DDIC_INT1 | DDIC_INT2 | DDIC_INT4 | DDIC_INT8 | DDIC_LANG | DDIC_LCHR | DDIC_MIN | DDIC_MON | DDIC_LRAW | DDIC_NUMC | DDIC_PREC | DDIC_QUAN | DDIC_RAW | DDIC_RSTR | DDIC_SEC | DDIC_SRST | DDIC_SSTR | DDIC_STRG | DDIC_STXT | DDIC_TIMS | DDIC_UNIT | DDIC_UTCM | DDIC_UTCL | DDIC_UTCS | DDIC_TEXT | DDIC_VARC | DDIC_WEEK

The available data types. Please see Data Types

Description

The CREATE TYPE statement creates a user-defined type. Such a type can be used in CREATE PROCEDURE and CREATE FUNCTION commands. Please see CREATE PROCEDURE and CREATE FUNCTION.

The syntax for defining table types follows the SQL syntax for defining new types. The table type is specified using a list of attribute names and primitive data types. For each table type, attributes must have unique names.

Example

You create a table type called tt_publishers.

CREATE TYPE tt_publishers AS TABLE ( publisher INTEGER, name VARCHAR(50), price DECIMAL, cnt INTEGER);

You create a table type called tt_years.

CREATE TYPE tt_years AS TABLE ( year VARCHAR(4), price DECIMAL, cnt INTEGER);

352P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 353: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

1.8.8.6 DROP FUNCTION

Syntax

DROP FUNCTION <func_name> [<drop_option>]

Syntax Elements

<func_name> ::= [<schema_name>.]<identifier> <schema_name> ::= <identifier>

The name of the function to be dropped, with optional schema name.

<drop_option> ::= CASCADE | RESTRICT

When <drop_option> is not specified a non-cascaded drop will be performed. This will only drop the specified function, dependent objects of the function will be invalidated but not dropped.

The invalidated objects can be revalidated when an object that has same schema and object name is created.

CASCADE

Drops the function and dependent objects.

RESTRICT

Drops the function only when dependent objects do not exist. If this drop option is used and a dependent object exists an error will be thrown.

Description

Drops a function created using CREATE FUNCTION from the database catalog.

Examples

You drop a function called my_func from the database using a non-cascaded drop.

DROP FUNCTION my_func;

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 353

Page 354: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

1.8.8.7 DROP PROCEDURE

Syntax

DROP PROCEDURE <proc_name> [<drop_option>]

Syntax Elements

<proc_name> ::= [<schema_name>.]<identifier> <schema_name> ::= <identifier>

The name of the procedure to be dropped, with optional schema name.

<drop_option> ::= CASCADE | RESTRICT

When <drop_option> is not specified a non-cascaded drop will be performed. This will only drop the specified procedure, dependent objects of the procedure will be invalidated but not dropped.

The invalidated objects can be revalidated when an object that has same schema and object name is created.

CASCADE

Drops the procedure and dependent objects.

RESTRICT

Drops the procedure only when dependent objects do not exist. If this drop option is used and a dependent object exists an error will be thrown.

Description

Drops a procedure created using CREATE PROCEDURE from the database catalog.

Examples

You drop a procedure called my_proc from the database using a non-cascaded drop.

DROP PROCEDURE my_proc;

354P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 355: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

1.8.8.8 DROP TYPE

Syntax

DROP TYPE <type_name> [<drop_option>]

Syntax Elements

<type_name> ::= [<schema_name>.]<identifier> <schema_name> ::= <identifier>

The identifier of the table type to be droppped, with optional schema name.

<drop_option> ::= CASCADE | RESTRICT

When <drop_option> is not specified a non-cascaded drop will be performed. This will drop only the specified type, dependent objects of the type will be invalidated but not dropped.

The invalidated objects can be revalidated when an object that has same schema and object name is created.

Description

The DROP TYPE statement removes a user-defined table type.

Example

You create a table type called my_type.

CREATE TYPE my_type AS TABLE ( column_a DOUBLE );

You drop the my_type table type.

DROP TYPE my_type;

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 355

Page 356: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

1.9 Restrictions for SQL Statements

The table below shows the maximum allowable limit for each entry.

Database

Database size limit Limited by storage size RS: 1TB

Number of locks Unlimited for record locks,

16384 for table locks

Number of sessions 8192

Schemas

Number of tables in a schema 131072

Identifier length 127 characters

Length of an alias name 128 characters

Table name length Please see "Identifier length" above

Column name length Please see "Identifier length" above

Length of a constant string literal 32767 bytes

Number of hex characters in a binary literal 8192

Tables and Views

Number of columns in a table 1000

Number of columns in a view 1000

Number of partitions of a column table 1000

Number of rows in each table Limited by storage size RS: 1TB/sizeof(row),

CS: 2^31 * number of partitions

Length of a row Limited by RS storage size ( 1TB )

Size of a non-partitioned table Limited by RS storage size ( 1TB )

Indexes and Constraints

Number of indexes for each table 1023

356P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 357: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Number of primary key columns in each table 16

Number of columns in an index 16

Number of columns in a UNIQUE constraint 16

Size of sum of primary key, index, UNIQUE

constraint

16384

SQL

Length of an SQL statement 2GB

Depth of SQL view nesting 128

Depth of SQL parse tree 255

Number of joined tables in an SQL statement or view 255

Number of columns in an ORDER BY, GROUP BY or SELECT clause

65535

Number of elements in predicates 65535

Number of elements in SELECT clause 65535

SQLScript

Size of all stored procedures Limited by RS storage size ( 1TB )

NoteYou can obtain the current system limits from your SAP HANA Database instance by using

select * from m_system_limits

See Also

M_SYSTEM_LIMITS in the System Tables and Monitor Views Reference

1.10 SQL Error Codes

The following table lists error codes displayed by SAP HANA database and their descriptions.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 357

Page 358: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Error Code Description

1 General warning

2 General error

3 Fatal error

4 Cannot allocate enough memory

5 Initialization error

6 Invalid data

7 Feature not supported

8 Invalid argument

9 Index out of bounds

10 Invalid username or password

11 Invalid state

12 Cannot open file

13 Cannot create/write file

14 Cannot allocate enough disk space

15 Cannot find file

16 Statement retry

17 Metadata schema version incompatible between database and executable file

18 Service shutting down

19 Invalid license

128 Transaction error

129 Transaction rolled back by an internal error

130 Transaction rolled back by integrity constraint violation

131 Transaction rolled back by lock wait timeout

132 Transaction rolled back due to unavailable resource

133 Transaction rolled back by detected deadlock

358P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 359: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Error Code Description

134 Failure in accessing checkpoint file

135 Failure in accessing anchor file

136 Failure in accessing log file

137 Failure in accessing archive file

138 Transaction serialization failure

139 Current operation cancelled by request and transaction rolled back

140 Invalid write-transaction identifier

141 Failure in accessing invisible log file

142 Exceed max num of concurrent transactions

143 Transaction serialization failure until timeout expires

144 Transaction rollback, unique constraint violated

145 Transaction distribution work failure

146 Resource busy and acquire with NOWAIT specified

147 Inconsistency between data and log

148 Transaction start is blocked until Master_Restart finishes

149 Distributed transaction commit failure

150 Statement cancelled due to old snapshot

256 SQL processing error

257 SQL syntax error

258 Insufficient privilege

259 Invalid table name

260 Invalid column name

261 Invalid index name

262 Invalid query name

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 359

Page 360: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Error Code Description

263 Invalid alias name

264 Invalid datatype

265 Expression missing

266 Inconsistent datatype

267 Specified length too long for its datatype

268 Column ambiguously defined

269 Too many values

270 Not enough values

271 Duplicate alias

272 Duplicate column name

273 Not a single character string

274 Inserted value too large for column

275 Aggregate function not allowed

276 Missing aggregation or grouping

277 Not a GROUP BY expression

278 Nested group function without GROUP BY

279 Group function is nested

280 ORDER BY item must be the number of a SELECT-list

281 Outer join not allowed in operand of OR or IN

282 Two tables cannot be outer-joined to each other

283 A table may be outer joined to at most one other table

284 Join field does not match

285 Invalid join condition

286 Identifier is too long

287 Cannot insert NULL or update to NULL

288 Cannot use duplicate table name

360P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 361: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Error Code Description

289 Cannot use duplicate index name

290 Cannot use duplicate query name

291 Argument identifier must be positive

292 wrong number of arguments

293 Argument type mismatch

294 Cannot have more than one primary key

295 Too long multi key length

296 Replicated table must have a primary key

297 Cannot update primary key field in replicated table

298 Cannot store DDL

299 Cannot drop index used for enforcement of unique/primary key

300 Argument index is out of range

301 Unique constraint violated

302 Invalid CHAR or VARCHAR value

303 Invalid DATE, TIME or TIMESTAMP value

304 Division by zero undefined

305 Single-row query returns more than one row

306 Invalid cursor

307 Numeric value out of range

308 Column name already exists

309 Correlated subquery cannot have TOP or ORDER BY

310 SQL error in procedure

311 Cannot drop all columns in a table

312 Sequence is exhausted

313 Invalid sequence

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 361

Page 362: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Error Code Description

314 Numeric overflow

315 Invalid synonym

316 wrong number of arguments in function invocation

317 P_QUERYPLANS not exists nor valid format

318 Decimal precision specifier is out of range

319 Decimal scale specifier is out of range

320 Cannot create index on expression with datatype LOB

321 Invalid view name

322 Cannot use duplicate view name

323 Duplicate replication ID

324 Cannot use duplicate sequence name

325 Invalid escape sequence

326 CURRVAL of given sequence is not yet defined in this session

327 Cannot explain plan of given statement

328 Invalid name of function or procedure

329 Cannot use duplicate name of function or procedure

330 Cannot use duplicate synonym name

331 User name already exists

332 Invalid user name

333 Column not allowed

334 Invalid user privilege

335 Field alias name already exists

336 Invalid default value

337 INTO clause not allowed for this SELECT statement

338 Zero-length collumns are not allowed

362P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 363: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Error Code Description

339 Invalid number

340 Not all variables bound

341 Numeric underflow

342 Collation conflict

343 Invalid collate name

344 Parse error in data loader

345 Not a replication table

346 Invalid replication ID

347 Invalid option in monitor

348 Invalid datetime format

349 Cannot CREATE UNIQUE INDEX

350 Cannot drop columns in the primary-key column list

351 Column is referenced in a multi-column constraint

352 Cannot create unique index on CDX table

353 Update log group name already exists

354 Invalid update log group name

355 The base table of the update log table must have a primary key

356 Exceed maximum number of update log group

357 The base table already has a update log table

358 Update log table can not have a update log table

359 Concatenated string is too long

360 View WITH CHECK OPTION where-clause violation

361 Data manipulation operation not legal on this view

362 Invalid schema name

363 Number of index columns exceeds its maximum

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 363

Page 364: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Error Code Description

364 Invalid partial key size

365 No matching unique or primary key for this column list

366 Referenced table does not have a primary key

367 Number of referencing columns must match referenced columns

368 Unique constraint not allowed on temporary table

369 Exceed maximum view depth limit

370 Cannot perform DIRECT INSERT operation on table with unique indexes

371 Invalid XML document

372 Invalid XPATH

373 Invalid XML duration value

374 Invalid XML function usage

375 Invalid XML index operation

376 Python stored procedure error

377 JIT operation error

378 Invalid column view

379 Table schema mismatch

380 Fail to change run level

381 Fail to restart

382 Fail to collect all version garbage

383 Invalid identifier

384 Constant string is too long

385 Could not restore session

386 Cannot use duplicate schema name

387 Table ambiguously defined

364P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 365: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Error Code Description

388 Role already exists

389 Invalid role name

390 Invalid user type

391 Invalidated view

392 Can't assign cyclic role

393 Roles must not receive a privilege with grant option

394 Error revoking role

395 Invalid user-defined type name

396 Cannot use duplicate user-defined type name

397 Invalid object name

398 Cannot have more than one order by

399 Role tree too deep

400 Primary key not allowed on insert-only table

401 Unique constraint not allowed on insert-only table

402 The user was already dropped before query execution

403 Internal error

404 Invalid (non-existent) structured privilege name

405 Cannot use duplicate structured privilege name

406 INSERT, UPDATE and UPSERT are disallowed on the generated field

407 Invalid date format

408 Password or parameter required for user

409 Multiple values for a parameter not supported

410 Invalid privilege namespace

411 Invalid table type

412 Invalid password layout

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 365

Page 366: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Error Code Description

413 Last n passwords can not be reused

414 User is forced to change password

415 User is deactivated

416 User is locked

417 Can't drop without CASCADE specification

418 Invalid view query for creation

419 Can't drop with RESTRICT specification.

420 Password change currently not allowed

421 Cannot create fulltext index

422 Privileges must be either all SQL or all from one namespace

423 LiveCache error

424 Invalid name of package

425 Duplicate package name

426 Number of columns mismatch

427 Cannot reserve index ID any more

428 Invalid query plan ID

429 Integrity check failed

430 Invalidated procedure

431 User's password will expire within few days

432 This syntax has been deprecated and will be removed in next release

433 Null value found

434 Invalid object ID

435 Invalid expression

436 Could not set system license

366P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 367: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Error Code Description

437 Only commands for license handling are allowed in current state

438 Invalid user parameter value

439 Composite error

440 Table type conversion error

441 This feature has been deprecated and will be removed in next release

442 Number of columns exceeds its maximum

443 Invalid calculation scenario name

444 Package manager error

512 Replication error

513 Cannot execute DDL statement on replication table while replicating

514 Failure in accessing anchor file

515 Failure in accessing log file

516 Replication table has not conflict report table

517 Conflict report table already enabled

518 Conflict report table already disabled

576 API error

577 Cursor type of forward is not allowed

578 Invalid statement

579 Exceed maximum batch size

580 Server rejected the connection(protocol version mismatch)

581 This function can be called only in the case of single statement

582 This query does not have result set

583 Connection does not exist

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 367

Page 368: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Error Code Description

584 No more lob data

585 Operation is not permitted

586 Invalid parameter is received from server

587 Result set is currently invalid

588 Next() is not called for this result set

589 Too many parameters are set

590 Some paramters are missing

591 Internal error

592 Not supported type conversion

593 Remote-only function

594 No more result row in result set

595 Specified parameter is not output parameter

596 LOB streaming is not permitted in auto-commit mode

597 Session context error

598 Failed to execute the external statement

599 Session layer is not initialized yet

600 Failed routed execution

601 Too many session variables are set

602 Cannot set readonly session variable

603 Invalid LOB

604 Remote temp table access failure

605 Invalid XA join request

606 Exceed maximum LOB size

607 Failed to cleanup resources

608 Exceed maximum number of prepared statements

1024 Session error

368P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 369: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Error Code Description

1025 Communication error

1026 Cannot bind a communication port

1027 Communication initialization error

1028 I/O control error

1029 Connection failure

1030 Send error

1031 Receive error

1032 Cannot create a thread

1033 Error while parsing protocol

1034 Exceed maximum number of sessions

1035 Not supported version

1036 Invalid session ID

1037 Unknown hostname

1280 SqlScript error

1281 Wrong number or types of parameters in call

1282 Output parameter not avariable

1283 OUT and IN OUT parameters may not have default expressions

1284 Duplicate parameters are not permitted

1285 At most one declaration is permitted in the declaration section

1286 Cursor must be declared by SELECT statement

1287 Identifier must be declared

1288 Expression cannot be used as an assignment target

1289 Expression cannot be used as an INTO-target of SELECT/FETCH statement

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 369

Page 370: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Error Code Description

1290 Expression is inappropriate as the left hand side of an assignment statement

1291 Expression is of wrong type

1292 Illegal EXIT statement, it must appear inside a loop

1293 Identifier name must be an exception name

1294 An INTO clause is expected in SELECT statement

1295 EXPLAIN PLAN and CALL statement are not allowed

1296 Identifier is not a cursor

1297 Wrong number of values in the INTO list of a FETCH statement

1298 Unhandled user-defined exception

1299 No data found

1300 Fetch returns more than requested number of rows

1301 Numeric or value error

1302 Parallelizable function cannot have OUT or IN OUT parameter

1303 User-defined exception

1304 Cursor is already opened

1305 Return type is invalid

1306 Return type mismatch

1307 Unsupported datatype is used

1308 Illegal single assignment

1309 Invalid use of table variable

1310 Scalar type is not allowed

1311 Out parameter is not specified

1312 At most one output parameter is allowed

1313 Output parameter should be a table or a table variable

370P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 371: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Error Code Description

1314 Inappropriate variable name: do not allow "" for the name of variable or parameter

1315 Return result set from select stmt exist when result view is defined

1316 Some out table var is not assigned

1317 Function name exceedes max. limit

1318 Built-in function not defined

1319 Parameter must be a table name

1320 Parameter must be an attribute name without a table name upfront

1321 Parameter must be an attribute name without an alias

1322 CE_CALC not allowed

1323 Parameter must be a vector of columns or aggregations

1324 Join attribute must be available in projection list

1325 Parameter must be a vector of SQL identifiers

1326 Duplicate attribute name

1327 Parameter has a non supported type

1328 Attribute not found in column table

1329 Duplicate column name

1330 Syntax Error for calculated Attribute

1331 Syntax Error in filter expression

1332 Parameter must be a valid column table name

1333 Join attributes not found in variable

1334 Input parameters do not have the same table type

1335 Cyclic dependency found in a runtime procedure

1336 Unexpected internal exception caught in a runtime procedure

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 371

Page 372: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Error Code Description

1337 Variable depends on an unassigned variable

1338 CE_CONVERSION: customizing table missing

1339 Too many parameters

1340 The depth of the nested call is too deep

1536 Swapx error

1537 This table has no swap space

1538 Swap already activated

1539 Swap not yet activated

1540 Swap space is not created

1541 Failure in unpinning a swap page

1542 Failure in swap file

1543 Failure in accessing swap data file

1544 Failure in accessing swap log file

1545 Swap buffer overflow

1546 Swap buffer reservation failure

1792 Shared memory error

1793 Invalid key or invalid size

1794 The segment already exists

1795 Exceed the system-wide limit on shared memory

1796 No segment exists for the given key, and IPC_CREAT was not specified

1797 The user does not have permission to access the shared memory segment

1798 No memory could be allocated for segment overhead

1799 Invalid shmid

1800 Allow read access for shmid

372P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 373: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Error Code Description

1801 Shmid points to a removed identifier

1802 The effective user ID of the calling process is not the creator

1803 The GID or UID value is too large to be stored in the structure

1804 The user does not have permission to access the shared memory segment

1805 Invalid shmid

1806 No memory could be allocated for the descriptor or for the page tables

1807 Unknown shared memory error

2048 Column store error

2049 Primary key is not specified for column table

2050 Not supported ddl type for column table

2051 Not supported data type for column table

2052 Not supported dml type for column table

2053 Invalid returned value from attribute engine

2304 Python DBAPI error

2305 Interface failure

2306 Programming mistake

2307 Invalid query parameter

2308 Not supported encoding for string

2560 Distributed metadata error

2561 DDL redirect error

2562 DDL notification error

2563 DDL invalid container ID

2564 DDL invalid index ID

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 373

Page 374: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Error Code Description

2565 Distributed environment error

2566 Network error

2567 Metadata update not supported in slave

2568 Metadata update of master indexserver is failed

2816 SqlScript Error

2817 SqlScript Builtin Function

2818 - 2889 SqlScript

3584 Distributed SQL error

3585 Expression shipping failure

3586 Operator shipping failure

3587 Invalid protocol or indexserver (statisticsserver) shutdown during distributed query execution

3588 Sequence shipping failure

3589 Remote query exectuion failure

3840 general auditing error

3841 Invalid privilege

3842 Audit trail writer is blocked

3843 Audit policy with current name already exists

3844 Invalid combination of audit actions

3845 Invalid action status for auditing

3846 Invalid auditing level

3847 Invalid policy name

4096 General error in the process of stored plan

4097 Invalid operation in generating plans

4098 Invalid operation in execution the chosen plan

4099 Invalid operation in storing the pinned plan

374P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSQL Reference Manual

Page 375: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Error Code Description

4100 Invalid operation in loading the stored plan

4101 Invalid operation in deleting the chosen plan

4103 Failed to prepare for runtime reorganization

4104 Transaction blocked since runtime reorganization is in progress

4105 ERR_REORG_TRANS_EXISTS_GENERAL. Cannot start reorganization due to the transactions in execution

SAP HANA SQL and System Views ReferencesSQL Reference Manual

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 375

Page 376: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

2 System Views ReferenceSystem views allow you to query for various information about the system state using SQL commands. The results appear as tables.

System Views The following public system views are available:

● AFL_AREAS - Available AFL areas● AFL_FUNCTIONS - Available AFL functions● AFL_FUNCTION_PROPERTIES - Available AFL function properties● AFL_PACKAGES - Available AFL packages● AUDIT_POLICIES - Defined audit policies● AUTHORIZATION_GRAPH - Represents authorization dependencies of complex database objects● CONSTRAINTS - Constraints defined for tables● CREDENTIALS - Credentials defined for users and components● CS_BO_VIEWS - Business object views for column store join views● CS_FREESTYLE_COLUMNS - Freestyle search columns for column store join views● CS_JOIN_CONDITIONS - Join conditions defined for column store join views● CS_JOIN_CONSTRAINTS - Join constraints defined for column store join views● CS_JOIN_PATHS - Join paths defined for column store join views● CS_JOIN_TABLES - Physical tables referred by column store join views● CS_KEY_FIGURES - Key figures defined for column store join views● CS_VIEW_COLUMNS - Columns defined for column store join views● DATA_STATISTICS - Overview of data statistics objects● DATA_TYPES - Available SQL data types● EFFECTIVE_PRIVILEGES - Privileges of the current user● EFFECTIVE_ROLES - Roles of the current user● EXPLAIN_PLAN_TABLE - SQL query plan explanation result● FULLTEXT_INDEXES - Fulltext indexes on table columns● FUNCTIONS - Available functions● FUNCTION_PARAMETERS - Parameters of functions● GEOCODE_INDEXES - Geocode indexes on tables● GRANTED_PRIVILEGES - Privileges granted to users and roles● GRANTED_ROLES - Roles granted to users or other roles● INDEXES - Indexes on tables● INDEX_COLUMNS - Columns of indexes● INVALID_CONNECT_ATTEMPTS - Number of invalid connect attempts for a user between two successful

connects● M_ATTACHED_STORAGES - Information about currently attached devices● M_BACKUP_CATALOG - Common data for all backup catalog entries● M_BACKUP_CATALOG_FILES - Location information of all backup catalog entries● M_BACKUP_CONFIGURATION - Backup configuration statistics● M_BLOCKED_TRANSACTIONS - Transaction list waiting for locks● M_CACHES - Shows aggregated information on caches● M_CACHES_RESET - Shows aggregated information on caches

376P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 377: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

● M_CACHE_ENTRIES - Cache entry information● M_CATALOG_MEMORY - Memory usage information by catalog manager● M_CE_CALCSCENARIOS - All available CalculationScenarios● M_CE_CALCVIEW_DEPENDENCIES - All views that are referencing a CalculationScenario● M_CE_DEBUG_INFOS - Debug information after execution of a CalculationScenario● M_CE_DEBUG_JSONS - All available JSONS (original, instantiated, optimized) of a scenario for a concrete

query● M_CE_DEBUG_NODE_MAPPING - Node mapping between CalculationNodes and RuntimeNodes after

execution● M_CE_PLE_CALCSCENARIOS - All available CalculationScenarios created by the PlanningEngine● M_CLIENT_VERSIONS - Versions of all supported client applications● M_COMPACTION_THREAD - Compaction thread statistics● M_CONDITIONAL_VARIABLES - Semaphore statistics● M_CONDITIONAL_VARIABLES_RESET - Semaphore statistics● M_CONNECTIONS - Detailed information on connections between a client and database. Information includes

connection status, client information, connection type, resource utilization● M_CONNECTION_STATISTICS - Detailed statistics on each connection between an application and database● M_CONTAINER_DIRECTORY - ContainerDirectory statistics● M_CONTAINER_NAME_DIRECTORY - ContainerNameDirectory statistics● M_CONTEXT_MEMORY - Memory allocator statistics● M_CONTEXT_MEMORY_RESET - Memory allocator statistics● M_CONVERTER_STATISTICS - Converter statistics● M_CONVERTER_STATISTICS_RESET - Converter statistics● M_CS_ALL_COLUMNS - Runtime information from all columns of column tables, including internal ones● M_CS_COLUMNS - Runtime information of columns of column tables● M_CS_PARTITIONS - Partition information of column tables● M_CS_TABLES - Runtime data of column tables● M_CS_UNLOADS - A history of column unloads● M_DATABASE - Database information● M_DATABASE_HISTORY - Installation version history● M_DATA_VOLUMES - DataVolume statistics● M_DATA_VOLUME_PAGE_STATISTICS - Page usage statistics on data volumes● M_DATA_VOLUME_PAGE_STATISTICS_RESET - Page usage statistics on data volumes● M_DATA_VOLUME_SUPERBLOCK_STATISTICS - FreeBlockManager Superblock statistics● M_DEBUG_CONNECTIONS - Overview of connections used per debug session● M_DEBUG_SESSIONS - Overview of debug sessions and their properties● M_DELTA_MERGE_STATISTICS - Table delta merge statistics● M_DISKS - Disk configuration and utilization of the host machine● M_ERROR_CODES - Error codes with descriptions● M_EVENTS - Internal events● M_EXPENSIVE_STATEMENTS - All statements with duration longer than a threshold● M_EXPORT_BINARY_STATUS - Export status information for current session● M_EXTRACTORS - Direct extractor connection (DXC) status information● M_FEATURES - All supported features● M_FULLTEXT_QUEUES - Fulltext index queue status

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 377

Page 378: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

● M_FUZZY_SEARCH_INDEXES - Runtime information of fuzzy search indexes of column tables● M_GARBAGE_COLLECTION_STATISTICS - Garbage collection/history manager statistics● M_GARBAGE_COLLECTION_STATISTICS_RESET - Garbage collection/history manager statistics● M_HEAP_MEMORY - Memory allocator statistics● M_HEAP_MEMORY_RESET - Memory allocator statistics● M_HISTORY_INDEX_LAST_COMMIT_ID - Last commit ID of history index for each session● M_HOST_INFORMATION - Host information such as machine, OS configuration● M_HOST_RESOURCE_UTILIZATION - Host resource utilization, CPU time is in milliseconds and added across

all cores since system start● M_IMPORT_BINARY_STATUS - Import status information for current session● M_INIFILES - All configuration files● M_INIFILE_CONTENTS - Configuration information from inifiles● M_JOB_PROGRESS - Current long running system operations● M_LANDSCAPE_HOST_CONFIGURATION - Host roles in a distributed landscape● M_LICENSE - Information on the currently valid license (if any) installed on this system● M_LICENSE_USAGE_HISTORY - Information on the maximum resource consumption per time period, used

for validity check of license installed on this system (if any)● M_LIVECACHE_CONTAINER_STATISTICS - LiveCache container statistics● M_LIVECACHE_CONTAINER_STATISTICS_RESET - LiveCache container statistics● M_LIVECACHE_LOCKS - Detailed information on the Object Management System (OMS) locks● M_LIVECACHE_LOCK_STATISTICS - LiveCache lock statistics● M_LIVECACHE_LOCK_STATISTICS_RESET - LiveCache lock statistics● M_LIVECACHE_OMS_VERSIONS - Detailed information on the OMS versions that currently exists● M_LIVECACHE_PROCEDURE_STATISTICS - LiveCache procedure statistics● M_LIVECACHE_PROCEDURE_STATISTICS_RESET - LiveCache procedure statistics● M_LIVECACHE_SCHEMA_STATISTICS - LiveCache schema statistics● M_LIVECACHE_SCHEMA_STATISTICS_RESET - LiveCache schema statistics● M_LOCK_WAITS_STATISTICS - Accumulated lock wait count and duration for record lock, table lock and

metadata lock for all available services from DB startup until now● M_LOG_BUFFERS - Log buffer statistics● M_LOG_BUFFERS_RESET - Log buffer statistics● M_LOG_PARTITIONS - Log partition statistics● M_LOG_PARTITIONS_RESET - Log partition statistics● M_LOG_SEGMENTS - Log segment statistics● M_LOG_SEGMENTS_RESET - Log segment statistics● M_MEMORY_OBJECTS - Memory object statistics● M_MEMORY_OBJECTS_RESET - Memory object statistics● M_MEMORY_OBJECT_DISPOSITIONS - Disposition specific memory object statistics. The statistics are

calculated and reading them may take a while.● M_MERGED_TRACES - Contains the merged content of the server trace files for all of the SAP HANA

processes● M_MONITORS - Available monitoring views● M_MONITOR_COLUMNS - All the columns in the monitoring views● M_MUTEXES - Mutex statistics● M_MUTEXES_RESET - Mutex statistics

378P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 379: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

● M_MVCC_TABLES - Statistics of row-store Multiversion Concurrency Control (MVCC) manager● M_OBJECT_LOCKS - Status of currently acquired locks on objects with detailed information such as lock

acquisition time, lock mode● M_OBJECT_LOCK_STATISTICS - Lock contention statistics - lock wait count, wait time, failed count for each

objects● M_OBJECT_LOCK_STATISTICS_RESET - Lock contention statistics - lock wait count, wait time, failed count

for each objects● M_PAGEACCESS_STATISTICS - PageAccess statistics● M_PAGEACCESS_STATISTICS_RESET - PageAccess statistics● M_PASSWORD_POLICY - Effective password policy settings● M_PERFTRACE - Current PerfTrace state● M_PERSISTENCE_ENCRYPTION_KEYS - Information about encryption page keys● M_PERSISTENCE_ENCRYPTION_STATUS - Information about persistence encryption● M_PERSISTENCE_MANAGERS - Persistence manager statistics● M_PERSISTENCE_MANAGERS_RESET - Persistence manager statistics● M_PLUGIN_MANIFESTS - Information about installed plugins● M_PREPARED_STATEMENTS - Prepared statements list● M_READWRITELOCKS - Read/Write lock statistics● M_READWRITELOCKS_RESET - Read/Write lock statistics● M_RECORD_LOCKS - Record lock status● M_REMOTE_CONNECTIONS - Detailed information on remote connections between database and remote

sources. Information includes connection status, adapter name and adapter properties● M_REMOTE_STATEMENTS - Detailed information on executed remote queries. Information includes query

status, number of fetched rows● M_REORG_ALGORITHMS - Landscape redistribution algorithms● M_REPO_TRANSPORT_FILES - All repository transport files● M_RS_INDEXES - Statistics of B-tree and CPB-tree indexes● M_RS_MEMORY - RS Memory Statistics● M_RS_TABLES - Information on row tables: detailed table sizes and record count● M_RS_TABLE_VERSION_STATISTICS - Information on row table versions: detailed version counts and used

sizes● M_SAVEPOINTS - Current and historical savepoint statistics● M_SAVEPOINT_STATISTICS - Savepoint statistics● M_SAVEPOINT_STATISTICS_RESET - Savepoint statistics● M_SEMAPHORES - Semaphore statistics● M_SEMAPHORES_RESET - Semaphore statistics● M_SEQUENCES - Sequence statistics● M_SERVICES - Status of all services● M_SERVICE_COMPONENT_MEMORY - Service-specific memory usage by logical component● M_SERVICE_MEMORY - Detailed information on memory utilization by services● M_SERVICE_NETWORK_IO - Service network I/O statistics● M_SERVICE_NETWORK_IO_RESET - Service network I/O statistics● M_SERVICE_REPLICATION - Information about replicated services● M_SERVICE_STATISTICS - Statistics on active services● M_SERVICE_THREADS - Detailed information on threads created by services

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 379

Page 380: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

● M_SERVICE_THREAD_CALLSTACKS - Stack frame information for service threads● M_SERVICE_TRACES - Configured trace components for each service type● M_SERVICE_TYPES - Service types● M_SESSION_CONTEXT - Session variables for each connection● M_SHARED_MEMORY - Shared memory usage information by SAP HANA indexserver● M_SNAPSHOTS - Existing snapshots● M_SQL_PLAN_CACHE - Statistics of an individual execution plan● M_SQL_PLAN_CACHE_OVERVIEW - Overall statistics of evicted and cached plans● M_SQL_PLAN_CACHE_RESET - Statistics of an individual execution plan● M_SYSTEM_INFORMATION_STATEMENTS - System information statements● M_SYSTEM_LIMITS - System limits information● M_SYSTEM_OVERVIEW - Overview of system status including important resource usage information and

alerts● M_TABLES - Information on row and column tables● M_TABLE_LOB_FILES - All LOB files that belong to a table● M_TABLE_LOCATIONS - Tables and their logical location. Physical locations are shown in

M_TABLE_PERSISTENCE_LOCATIONS● M_TABLE_PERSISTENCE_LOCATIONS - Column store tables and their physical data locations● M_TABLE_PERSISTENCE_STATISTICS - Persistence virtual file summary statistics for tables● M_TABLE_VIRTUAL_FILES - All virtual files that belong to a table● M_TEMPORARY_OBJECT_DEPENDENCIES - Temporary object dependencies for transient objects● M_TEMPORARY_TABLES - Temporary tables● M_TEMPORARY_TABLE_COLUMNS - Columns of temporary tables● M_TEMPORARY_VIEWS - Temporary views● M_TEMPORARY_VIEW_COLUMNS - Columns of temporary tables● M_TENANTS - Available tenant information● M_TEXT_ANALYSIS_LANGUAGES - List of supported languages● M_TEXT_ANALYSIS_MIME_TYPES - List of supported mime types● M_TOPOLOGY_TREE - SAP HANA nameserver topology content● M_TRACEFILES - All trace files● M_TRACEFILE_CONTENTS - SAP HANA information from trace files● M_TRACE_CONFIGURATION - Trace configuration statistics● M_TRACE_CONFIGURATION_RESET - Trace configuration statistics● M_TRANSACTIONS - All transactions created by users or database● M_UNDO_CLEANUP_FILES - Information about undo files and cleanup files● M_VERSION_MEMORY - Memory usage of row-store Multiversion Concurrency Control (MVCC) manager● M_VOLUMES - Volumes used by SAP HANA servers● M_VOLUME_FILES - Information about volume files● M_VOLUME_IO_DETAILED_STATISTICS - File access detailed statistics● M_VOLUME_IO_DETAILED_STATISTICS_RESET - File access detailed statistics● M_VOLUME_IO_PERFORMANCE_STATISTICS - Deprecated. Please use M_VOLUME_IO_TOTAL_STATISTICS

instead● M_VOLUME_IO_PERFORMANCE_STATISTICS_RESET - Deprecated. Please use

M_VOLUME_IO_TOTAL_STATISTICS instead● M_VOLUME_IO_RETRY_STATISTICS - File access retry statistics

380P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 381: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

● M_VOLUME_IO_RETRY_STATISTICS_RESET - File access retry statistics● M_VOLUME_IO_STATISTICS - Deprecated. Please use M_VOLUME_IO_TOTAL_STATISTICS instead● M_VOLUME_IO_STATISTICS_RESET - Deprecated. Please use M_VOLUME_IO_TOTAL_STATISTICS instead● M_VOLUME_IO_TOTAL_STATISTICS - File access statistics● M_VOLUME_IO_TOTAL_STATISTICS_RESET - File access statistics● M_VOLUME_SIZES - Volume sizes used by SAP HANA servers● M_WORKLOAD - Database workload collected every minute● M_XS_APPLICATIONS - Applications deployed and running in SAP HANA XS● M_XS_APPLICATION_ISSUES - Issues related to applications in SAP HANA XS● OBJECTS - Available objects● OBJECT_DEPENDENCIES - Dependencies between objects, for example, views which refer to a specific table● OWNERSHIP - Ownership of available objects when users create any object in other users' schemas● PRIVILEGES - Available privileges● PROCEDURES - Available stored procedures● PROCEDURE_OBJECTS - Contains results of the system procedure GET_PROCEDURE_OBJECTS● PROCEDURE_PARAMETERS - Parameters of stored procedures● QUERY_PLANS - Plans how to handle query execution● REFERENTIAL_CONSTRAINTS - Referential constraints● REMOTE_SOURCES - Remote sources● REORG_OVERVIEW - Overview of landscape redistributions● REORG_PLAN - Current plan for landscape reorganization● REORG_PLAN_INFOS - Additional informations about current landscape reorganization plan● REORG_STEPS - Details of landscape redistribution● ROLES - Shows available roles● SAML_PROVIDERS - Shows available SAML provider● SAML_USER_MAPPINGS - Shows the SAML providers known for each user● SCHEMAS - Shows available schemas● SEARCH_RULE_SETS - Shows information about available search rule sets● SEARCH_RULE_SET_CONDITIONS - Shows conditions to available search rule sets● SEQUENCES - Available sequences● SESSION_COOKIES - Shows information about available session cookies● SQLSCRIPT_TRACE - Contains the names of the local temporary tables created by the SQLScript TRACE

operator● STATISTICS - Stores a histogram of tables. The histogram can be used by query optimizer to calculate size of

an intermediate result● STRUCTURED_PRIVILEGES - Available structured privileges● SYNONYMS - Available synonyms● TABLES - Available tables● TABLE_COLUMNS - Available table columns● TABLE_COLUMNS_ODBC - Available table columns● TABLE_GROUPS - Overview of table groups relations● TRANSACTION_HISTORY - Committed transactions and their users● TRIGGERS - Triggers defined for tables● USERS - All users

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 381

Page 382: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

● USER_PARAMETERS - All parameters and their values, which have been assigned to users in the system (using CREATE USER ... SET PARAMETER or ALTER USER ... SET PARAMETER)

● VIEWS - Available views● VIEW_COLUMNS - Available view columns● VIRTUAL_COLUMNS - Virtual columns● VIRTUAL_TABLES - Virtual tables● X509_USER_MAPPINGS - Shows the X.509 certificates known for each user

Statistics Server The following Statistics Server tables are available:

● Statistics Server Tables

2.1 Statistics Server Tables

The following tables and views are from the _SYS_STATISTICS schema.

GLOBAL_COLUMN_TABLES_SIZE (Deprecated)

This table is deprecated. Instead, use GLOBAL_ROWSTORE_TABLES_SIZE, HOST_COLUMN_TABLES_PART_SIZE

GLOBAL_CPU_STATISTICS (Deprecated)

This table is deprecated. Instead, use HOST_RESOURCE_UTILIZATION_STATISTICS, HOST_SERVICE_MEMORY

GLOBAL_DEC_EXTRACTOR_STATUS

Short description

Direct Extractor Connection (DXC) status information. The table contains information only for the last 7 days.

Structure

Column name Data type Unit Description

SNAPSHOT_ID TIMESTAMP Datetime ID of the snapshot

INDEX NVARCHAR(1024) Specifies an index on the rows of the result set that a particular snapshot of a data collection represents

382P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 383: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

SERVER_TIMESTAMP TIMESTAMP Datetime Server time of snapshot

CLIENT NVARCHAR(3) The ID of the client

DATA_SEQ (deprecated) INTEGER Data sequence ID of the statistics

ERROR_MESSAGE NVARCHAR(5000) The message in case of an error

PHASE VARCHAR(20) The phase of the last running operation

REQUEST_ID INTEGER SID of the request used for activation

SCHEMA_NAME NVARCHAR(256) Name of the schema where the DSO tables are generated

STATUS VARCHAR(5) General status overview saying 'OK' or 'ERROR'

TABLE_NAME NVARCHAR(256) Name of the DSO specific status table

TIMESTAMP TIMESTAMP Timestamp of the operation phase

GLOBAL_DISKS

Short description

Disk configuration and utilization of the host machine. The table contains information only for the last 30 days.

Structure

Column name Data type Unit Description

SNAPSHOT_ID TIMESTAMP Datetime ID of the snapshot

INDEX NVARCHAR(1024) Specifies an index on the rows of the result set that a particular snapshot of a data collection represents

SERVER_TIMESTAMP TIMESTAMP Datetime Server time of snapshot

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 383

Page 384: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

DATA_SEQ (deprecated) INTEGER Data sequence ID of the statistics

DEVICE_ID BIGINT Database internal device ID

DISK_ID INTEGER Disk ID

FILESYSTEM_TYPE VARCHAR(16) Filesystem type

HOST VARCHAR(64) Host name. Will only be set if disk is used by exactly one host.

PATH VARCHAR(512) Path

SUBPATH VARCHAR(512) Subpath

TOTAL_SIZE BIGINT Byte Volume Used Space

USAGE_TYPE VARCHAR(16) Usage Type: LOG, DATA, TRACE, DATA_BACKUP and LOG_BACKUP

USED_SIZE BIGINT Byte Volume Size

GLOBAL_INTERNAL_DISKFULL_EVENTS

Short description

Global Internal disk full events

Structure

Column name Data type Unit Description

SNAPSHOT_ID TIMESTAMP Datetime ID of the snapshot

INDEX NVARCHAR(1024) Specifies an index on the rows of the result set that a particular snapshot of a data collection represents

SERVER_TIMESTAMP TIMESTAMP Datetime Server timestamp

ACKNOWLEDGED VARCHAR(6) Event acknowledged: 'TRUE', 'FALSE'

384P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 385: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

CREATE_TIME TIMESTAMP Time event was created

DATA_SEQ (deprecated) INTEGER Data sequence ID of the statistics

FAILED_HANDLES BIGINT Number of failed handle attempts

HANDLE_TIME TIMESTAMP Time event was handled

HOST VARCHAR(64) Host name

ID BIGINT ID of event

INFO VARCHAR(2000) Additional information

PORT INTEGER Internal port

STATE VARCHAR(256) State of event

TYPE VARCHAR(256) Type of event

GLOBAL_INTERNAL_EVENTS

Short description

Global internal events

Structure

Column name Data type Unit Description

SNAPSHOT_ID TIMESTAMP Datetime ID of the snapshot

INDEX NVARCHAR(1024) Specifies an index on the rows of the result set that a particular snapshot of a data collection represents

SERVER_TIMESTAMP TIMESTAMP Datetime Server timestamp

ACKNOWLEDGED VARCHAR(6) Event acknowledged: 'TRUE', 'FALSE'

CREATE_TIME TIMESTAMP Time event was created

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 385

Page 386: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

DATA_SEQ (deprecated) INTEGER Data sequence ID of the statistics

FAILED_HANDLES BIGINT Number of failed handle attempts

HANDLE_TIME TIMESTAMP Time event was handled

HOST VARCHAR(64) Host name

ID BIGINT ID of event

INFO VARCHAR(2000) Additional information

PORT INTEGER Internal port

STATE VARCHAR(256) State of event

TYPE VARCHAR(256) Type of event

GLOBAL_MEMORY_STATISTICS (Deprecated)

This table is deprecated. Instead, use HOST_RESOURCE_UTILIZATION_STATISTICS, HOST_SERVICE_MEMORY.

GLOBAL_PERSISTENCE_STATISTICS

Short description

Information on all available persistence. The table contains information only for the last 30 days.

Structure

Column name Data type Unit Description

SNAPSHOT_ID TIMESTAMP Datetime ID of the snapshot

INDEX NVARCHAR(1024) Specifies an index on the rows of the result set that a particular snapshot of a data collection represents

SERVER_TIMESTAMP TIMESTAMP Datetime Server timestamp

386P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 387: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

DATA_SEQ (deprecated) INTEGER Data sequence ID of the statistics

TOTAL_DISKS_SIZE BIGINT Byte Total disk size available

TOTAL_DISKS_USED_SIZE

BIGINT Byte Total disk size used

TOTAL_VOLUMES_DATA_SIZE

BIGINT Byte Total log area size

TOTAL_VOLUMES_LOG_SIZE

BIGINT Byte Total data area size

GLOBAL_ROWSTORE_TABLES_SIZE

Short description

Information on row tables: detailed table sizes and record count.

Only row tables where ALLOCATED_FIXED_PART_SIZE + ALLOCATED_VARIABLE_PART_SIZE > 1,000,000 bytes are listed.

The table contains information only for the last 30 days.

Structure

Column name Data type Unit Description

SNAPSHOT_ID TIMESTAMP Datetime ID of the snapshot

INDEX NVARCHAR(1024) Specifies an index on the rows of the result set that a particular snapshot of a data collection represents

SERVER_TIMESTAMP TIMESTAMP Datetime Server time of snapshot

ALLOCATED_FIXED_PART_SIZE

BIGINT Byte Allocated memory size for fixed-size part

ALLOCATED_VARIABLE_PART_SIZE

BIGINT Byte Allocated memory size for variable-size part

DATA_SEQ (deprecated) INTEGER Data sequence ID of the statistics

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 387

Page 388: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

FIXED_PAGE_FRAGMENT_SIZE

BIGINT Byte Fragmented memory size of fixed-size part

FIXED_PAGE_HEADER_SIZE

BIGINT Byte Allocated and used memory size for page headers of fixed-size part

FIXED_PART_ FRAGMENT_SIZE

BIGINT Byte Fragmented memory size of used fixed-size part

FIXED_PART_FREE_SIZE BIGINT Byte Free memory size in the pages of fixed-size part

HOST VARCHAR(64) Host name

LOAD_STATUS NVARCHAR(256) Loading state of table: 'LOADED', 'NOW_LOADING', 'PREPARING_UNLOAD', 'NOW_UNLOADING', 'UNLOADED', 'NOT_SUPPORTED'

PORT INTEGER Internal port

RECORD_COUNT BIGINT Number of records in this table

SCHEMA_NAME NVARCHAR(256) Schema name

TABLES_NAME NVARCHAR(256) Table name

USED_FIXED_PART_SIZE BIGINT Byte Used memory size for fixed-size part

USED_VARIABLE_PART_SIZE

BIGINT Byte Used memory size for variable-size part

VARIABLE_PART_FRAGMENT_SIZE

BIGINT Byte Fragmented memory size of used variable-size part

GLOBAL_TABLE_PERSISTENCE_STATISTICS

Short description

Persistence virtual file summary statistics for tables.

Only tables where DISK_SIZE > 10,000,000 bytes are listed.

388P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 389: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

The table contains information only for the last 30 days.

Structure

Column name Data type Unit Description

SNAPSHOT_ID TIMESTAMP Datetime ID of the snapshot

INDEX NVARCHAR(1024) Specifies an index on the rows of the result set that a particular snapshot of a data collection represents

SERVER_TIMESTAMP TIMESTAMP Datetime Server time of snapshot

APPEND_COUNT BIGINT Number of times the table was appended to

BYTES_APPENDED BIGINT Number of bytes appended to the table

BYTES_READ BIGINT Number of bytes read from the table

BYTES_WRITTEN BIGINT Number of bytes written to the table

BYTESTREAM_WRITTEN BIGINT Number of bytes written to the table via streaming interface

COPY_COUNT BIGINT Number of times the table was copied

DATA_SEQ (deprecated) INTEGER Data sequence ID of the statistics

DISK_SIZE BIGINT Total disk size of all table parts

OPTIMIZE_COUNT BIGINT Number of times the table was written to optimized

PAGE_COUNT BIGINT Total number of pages of all table parts

READ_COUNT BIGINT Number of times the table was read from

SCHEMA_NAME NVARCHAR(256) Schema Name

TABLE_NAME NVARCHAR(256) Table Name

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 389

Page 390: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

TRUNCATE_COUNT BIGINT Number of times the table was truncated

WRITE_COUNT BIGINT Number of times the table was written to

GLOBAL_TABLES_SIZE (Deprecated)

This table is deprecated. Instead, use GLOBAL_ROWSTORE_TABLES_SIZE, HOST_COLUMN_TABLES_PART_SIZE.

HOST_BLOCKED_TRANSACTIONS

Short description

Information on currently blocked transactions per host. The table contains information only for the last 7 days.

Structure

Column name Data type Unit Description

SNAPSHOT_ID TIMESTAMP Datetime ID of the snapshot

INDEX NVARCHAR(1024) Specifies an index on the rows of the result set that a particular snapshot of a data collection represents

SERVER_TIMESTAMP TIMESTAMP Datetime Server timestamp

BLOCKED_TIME TIMESTAMP Blocked timestamp

BLOCKED_TRANSACTION_ID

INTEGER Transaction ID of the transaction waiting for a lock

BLOCKED_UPDATE_TRANSACTION_ID

BIGINT Transaction ID of the blocked update transaction

DATA_SEQ (deprecated) INTEGER Data sequence ID of the statistics

HOST VARCHAR(64) Host name

390P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 391: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

LOCK_MODE VARCHAR(32) Lock mode: 'SHARED'/'EXCLUSIVE'/'INTENTIONAL EXCLUSIVE'

LOCK_OWNER_TRANSACTION_ID

INTEGER Transaction ID of the transaction holding the lock

LOCK_OWNER_UPDATE_TRANSACTION_ID

BIGINT Transaction ID of the update transaction holding the lock

LOCK_TYPE VARCHAR(32) Lock type: 'RECORD'/'TABLE'/'METADATA'

PORT INTEGER Internal port

WAITING_RECORD_ID VARCHAR(256) ID of the record on which the lock is currently placed

WAITING_SCHEMA_NAME

NVARCHAR(256) Name of the schema on which the lock is currently placed

WAITING_TABLE_NAME NVARCHAR(256) Name of the table on which the lock is currently placed

HOST_COLUMN_TABLES_PART_SIZE

Short description

Information on column tables partition size per host.

Only tables where MEMORY_SIZE_IN_TOTAL (the amount of space the table uses in a specific partition) > 1,000,000 bytes are listed.

The table contains information only for the last 30 days.

Structure

Column name Data type Unit Description

SNAPSHOT_ID TIMESTAMP Datetime ID of the snapshot

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 391

Page 392: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

INDEX NVARCHAR(1024) Specifies an index on the rows of the result set that a particular snapshot of a data collection represents

SERVER_TIMESTAMP TIMESTAMP Datetime Server timestamp

CREATE_TIME TIMESTAMP Created time

DATA_SEQ (deprecated) INTEGER Data sequence ID of the statistics

ESTIMATED_MAX_MEMORY_SIZE_IN_TOTAL

BIGINT Byte Estimated maximum memory consumption in total for table fully loaded

HOST VARCHAR(64) Host name

IS_DELTA_LOADED VARCHAR(6) Boolean Flag to indicate that delta part of table is loaded

IS_LOG_DELTA VARCHAR(6) Boolean Flag to indicate that currently delta log is being written.

LAST_COMPRESSED_RECORD_COUNT

BIGINT The number of entries in main during last compression run

LAST_MERGE_TIME TIMESTAMP Point in time, Unix time format, last time the table delta part was merged into main part

LAST_REPLAY_LOG_TIME TIMESTAMP Point in time, Unix time format, last time the table log was replayed

LOADED VARCHAR(10) Flag to show how many columns of table are loaded in memory (NO, PARTIALLY, and FULL); see M_CS_COLUMNS for each column

MEMORY_SIZE_IN_DELTA BIGINT Byte Current memory consumption in delta

392P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 393: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

MEMORY_SIZE_IN_HISTORY_DELTA

BIGINT Byte Current memory consumption in history-delta; 0 for normal non-history tables

MEMORY_SIZE_IN_HISTORY_MAIN

BIGINT Byte Current memory consumption in history-main; 0 for normal non-history tables

MEMORY_SIZE_IN_MAIN BIGINT Byte Current memory consumption in main; this value varies depending on the number of attributes actually loaded

MEMORY_SIZE_IN_TOTAL

BIGINT Byte Total memory size is the sum of memory size in main, delta, and history parts

MERGE_COUNT BIGINT Number of delta merges done on the table or partition

MODIFY_TIME TIMESTAMP Modified time

PART_ID INTEGER Partition ID. 0 for non-partitioned tables and 1 through number of partitions for partitioned tables

PERSISTENT_MERGE VARCHAR(6) Boolean Flag to indicate that new main part will be written to disk during table delta merge unless requested differently: 'TRUE', 'FALSE'

PORT INTEGER Internal port

RAW_RECORD_COUNT_IN_DELTA

BIGINT Current number of entries in table delta part, this value differs from number of visible table delta rows because there are additional entries such as

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 393

Page 394: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

deleted rows or updated rows; can contain deleted records

RAW_RECORD_COUNT_IN_HISTORY_DELTA

BIGINT Raw record count in history-delta

RAW_RECORD_COUNT_IN_HISTORY_MAIN

BIGINT Raw record count in history-main

RAW_RECORD_COUNT_IN_MAIN

BIGINT Current number of entries in table main part, this value differs from number of visible table main rows because there are entries of modified rows marked as invalidated

READ_COUNT BIGINT Number of read accesses on the table or partition

RECORD_COUNT BIGINT Byte Record count

SCHEMA_NAME NVARCHAR(256) Schema name

TABLE_NAME NVARCHAR(256) Table name

WRITE_COUNT BIGINT Number of write accesses on the table or partition

HOST_CONNECTIONS

Short description

Detailed information on connections between the client to the database. The information includes connection status, client information, connection type, resource utilization. The table contains information only for the last 30 days.

Structure

Column name Data type Unit Description

SNAPSHOT_ID TIMESTAMP Datetime ID of the snapshot

INDEX NVARCHAR(1024) Specifies an index on the rows of the result set that

394P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 395: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

a particular snapshot of a data collection represents

SERVER_TIMESTAMP TIMESTAMP Datetime Server time of snapshot

AUTO_COMMIT VARCHAR(6) Commit mode of the current transaction: TRUE if the current connection is in auto-commit mode, FALSE otherwise

CLIENT_DISTRIBUTION_MODE

VARCHAR(128) Client distribution mode of the current connection (i.e. [distribution] client_distribution_mode)

CLIENT_HOST VARCHAR(64) Host name of client machine

CLIENT_IP VARCHAR(16) IP of client machine

CLIENT_PID BIGINT Client Process ID

CONNECTION_ID INTEGER Connection ID

CONNECTION_STATUS VARCHAR(128) Connection Status: RUNNING or IDLE

CONNECTION_TYPE VARCHAR(128) Connection type: Remote, Local, History (remote), History (local)

CREATED_BY VARCHAR(256) Engine component that created the connections: Session, Planning, Repository, CalcEngine, Authentication, Table Exporter, Loader, LLVM, JSVM, IMS Search API, OLAP Engine, Mergedog, Ping Status, Name Server, Queue Server, SQL Stored Procedure, Authorization, TrexViaDbsl from ABAP, HybridTable Reorganizer, Session external

CREATOR_THREAD_ID BIGINT Thread ID who created the current connection

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 395

Page 396: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

CURRENT_OPERATOR_NAME

VARCHAR(64) Current operator name

CURRENT_STATEMENT_ID

VARCHAR(256) Current statement ID

DATA_SEQ (deprecated) INTEGER Data sequence ID of the statistics

END_TIME TIMESTAMP The time when the connection is closed for history connections

FETCHED_RECORD_COUNT

BIGINT Sum of the record count fetched by select statements

HOST VARCHAR(64) Host name

IDLE_TIME BIGINT Millisecond Time that the connection is unused and idle

IS_ENCRYPTED VARCHAR(6) Encrypted: TRUE if the secure communication is enabled (SSL enabled), FALSE, otherwise

IS_HISTORY_SAVED VARCHAR(6) Field is no longer valid - will be deprecated soon

LAST_ACTION VARCHAR(128) The last action done by the current connection: ExecuteGroup, CommitTrans, AbortTrans, PrepareStatement, CloseStatement, ExecutePrepared, ExecuteStatement, FetchCursor, CloseCursor, LobGetPiece, LogPutPiece, LobFind, Authenticate, Connect, Disconnect, ExecQidItab, CursorFetchItab, InsertIncompleteItab, AbapStream, TxStartXA, TxJoinXA

396P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 397: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

LOGICAL_CONNECTION_ID

INTEGER Logical connection ID in statement routing

MEMORY_SIZE_PER_CONNECTION

BIGINT Byte Allocated memory size per connection

OWN VARCHAR(6) Own connection: TRUE if own connection, FALSE if not

PARENT_CONNECTION_ID

INTEGER Parent connection ID

PORT INTEGER Internal port

RECEIVED_MESSAGE_COUNT

BIGINT Total message count received by the current connection

RECEIVED_MESSAGE_SIZE

BIGINT Total size of messages received by the current connection

SENT_MESSAGE_COUNT BIGINT Total message count sent by the current connection

SENT_MESSAGE_SIZE BIGINT Total size of messages sent by the current connection

START_TIME TIMESTAMP Connected Time

TRANSACTION_ID INTEGER Transaction object ID

USER_NAME NVARCHAR(256) User name

HOST_CONNECTION_STATISTICS

Short description

Detailed statistics on each connection between an application and database. The table contains information only for the last 30 days.

Structure

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 397

Page 398: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

SNAPSHOT_ID TIMESTAMP Datetime ID of the snapshot

INDEX NVARCHAR(1024) Specifies an index on the rows of the result set that a particular snapshot of a data collection represents

SERVER_TIMESTAMP TIMESTAMP Datetime Server time of snapshot

AVG_EXECUTION_MEMORY_SIZE

BIGINT Average memory size used during each execution

AVG_PREPARATION_TIME

BIGINT Average time of statement preparation

CONNECTION_ID INTEGER Connection ID

DATA_SEQ (deprecated) INTEGER Data sequence ID of the statistics

END_TIME TIMESTAMP The time when the connection is closed for history connections

EXECUTION_COUNT_BY_ROUTING

BIGINT Execution count by the client routed connection in statement routing

HOST VARCHAR(64) Host name

LAST_EXECUTED_TIME TIMESTAMP Last execution timestamp with this connection

MAX_EXECUTION_MEMORY_SIZE

BIGINT Maximum memory size used during each execution

MAX_PREPARATION_TIME

BIGINT Maximum time of statement preparation

MIN_EXECUTION_MEMORY_SIZE

BIGINT Minimum memory size used during each execution

MIN_PREPARATION_TIME BIGINT Minimum time of statement preparation

398P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 399: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

OTHERS_AVG_EXECUTION_TIME

DECIMAL Microsecond Average execution time of other statements

OTHERS_AVG_LOCK_WAIT_TIME

DECIMAL Microsecond Average lock wait time of other statements

OTHERS_COUNT BIGINT Number of other statement executions including data definition statements and data control statements

OTHERS_LOCK_WAIT_COUNT

BIGINT Total lock wait count of other statements

OTHERS_MAX_EXECUTION_TIME

BIGINT Microsecond Maximum execution time of other statements

OTHERS_MAX_LOCK_WAIT_TIME

BIGINT Microsecond Maximum lock wait time of other statements

OTHERS_TOTAL_EXECUTION_TIME

BIGINT Microsecond Total execution time of other statements

OTHERS_TOTAL_LOCK_WAIT_TIME

BIGINT Microsecond Total lock wait time of other statements

PORT INTEGER Internal port

READ_ONLY_TRANSACTION_AVG_EXECUTION_TIME

DECIMAL Microsecond Average execution time of read only transactions

READ_ONLY_TRANSACTION_COUNT

BIGINT Number of read only transactions

READ_ONLY_TRANSACTION_MAX_EXECUTION_TIME

BIGINT Microsecond Maximum execution time of read only transactions

READ_ONLY_TRANSACTION_TOTAL_EXECUTION_TIME

BIGINT Microsecond Total execution time of read only transactions

ROLLBACK_AVG_EXECUTION_TIME

DECIMAL Microsecond Average execution time of rollbacks

ROLLBACK_COUNT BIGINT Number of rollbacked transactions

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 399

Page 400: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

ROLLBACK_MAX_EXECUTION_TIME

BIGINT Microsecond Maximum execution time of rollbacks

ROLLBACK_TOTAL_EXECUTION_TIME

BIGINT Microsecond Total execution time of rollbacks

SELECT_AVG_EXECUTION_TIME

DECIMAL Microsecond Average execution time of select statement execution

SELECT_EXECUTION_COUNT

BIGINT Total number of select statement executions

SELECT_FOR_UPDATE_AVG_EXECUTION_TIME

DECIMAL Microsecond Average execution time of select for update execution

SELECT_FOR_UPDATE_AVG_LOCK_WAIT_TIME

DECIMAL Microsecond Average lock wait time during select for update

SELECT_FOR_UPDATE_COUNT

BIGITN Total number of select for update execution

SELECT_FOR_UPDATE_LOCK_WAIT_COUNT

BIGINT Number of lock waits during select for update

SELECT_FOR_UPDATE_MAX_EXECUTION_TIME

BIGINT Microsecond Maximum execution time of select for update execution

SELECT_FOR_UPDATE_MAX_LOCK_WAIT_TIME

BIGINT Microsecond Maximum lock wait time uring select for update

SELECT_FOR_UPDATE_TOTAL_EXECUTION_TIME

BIGINT Microsecond Total execution time of select for update execution

SELECT_FOR_UPDATE_TOTAL_LOCK_WAIT_TIME

BIGINT Microsecond Total lock wait time during select for update

SELECT_MAX_EXECUTION_TIME

BIGINT Microsecond Maximum execution time of select statement execution

SELECT_TOTAL_EXECUTION_TIME

BIGINT Microsecond Total execution time of select statement execution

400P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 401: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

TOTAL_EXECUTION_MEMORY_SIZE

BIGINT Sum of memory size used during each execution

TOTAL_PREPARATION_COUNT

BIGINT Total count of statement preparation

TOTAL_PREPARATION_TIME

BIGINT Total time of statement preparation

UPDATE_AVG_EXECUTION_TIME

DECIMAL Microsecond Average execution time of update statement executions

UPDATE_AVG_LOCK_WAIT_TIME

DECIMAL Microsecond Average lock wait time during update statement executions

UPDATE_COUNT BIGINT Total number of update statement and insert statement executions

UPDATE_LOCK_WAIT_COUNT

BIGINT Number of lock waits during update statement executions

UPDATE_MAX_EXECUTION_TIME

BIGINT Microsecond Maximum execution time of update statement executions

UPDATE_MAX_LOCK_WAIT_TIME

BIGINT Microsecond Maximum lock wait time during update statement executions

UPDATE_TOTAL_EXECUTION_TIME

BIGINT Microsecond Total execution time of update statement executions

UPDATE_TOTAL_LOCK_WAIT_TIME

BIGINT Microsecond Total lock wait execution time during update statement executions

UPDATE_TRANSACTION_AVG_EXECUTION_TIME

DECIMAL Microsecond Average execution time of update transactions

UPDATE_TRANSACTION_COUNT

BIGINT Number of update transactions

UPDATE_TRANSACTION_MAX_EXECUTION_TIME

BIGINT Microsecond Maximum execution time of update transactions

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 401

Page 402: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

UPDATE_TRANSACTION_TOTAL_EXECUTION_TIME

BIGINT Microsecond Total execution time of update transactions

HOST_CS_UNLOADS

Short description

A history of column unloads. The table contains information only for the last day.

Structure

Column name Data type Unit Description

SNAPSHOT_ID TIMESTAMP Datetime ID of the snapshot

INDEX NVARCHAR(1024) Specifies an index on the rows of the result set that a particular snapshot of a data collection represents

SERVER_TIMESTAMP TIMESTAMP Datetime Server time of snapshot

COLUMN_NAME NVARCHAR(256) Column name. Empty if the whole table is unloaded.

DATA_SEQ (deprecated) INTEGER Data sequence ID of the statistics

HOST VARCHAR(64) Host name

IS_HISTORY VARCHAR(5) Flag to indicate whether the history part is unloaded (only relevant for history tables). Empty if the whole table is unloaded.

PART_ID INTEGER Partition ID. 0 for non-partitioned tables, 1 through number of partitions for partitioned tables. -1 if the whole table is unloaded.

PORT INTEGER Internal port

402P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 403: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

REASON NVARCHAR(16) Unload reason (LOW MEMORY or EXPLICIT)

SCHEMA_NAME NVARCHAR(256) Schema name

TABLE_NAME NVARCHAR(256) Table name

TABLE_OID BIGINT Object ID of the table

UNLOAD_TIME TIMESTAMP Timestamp of unload event

HOST_DATA_VOLUME_PAGE_STATISTICS

Short description

Data volume page information per host. The table contains information only for the last 30 days.

Structure

Column name Data type Unit Description

SNAPSHOT_ID TIMESTAMP Datetime ID of the snapshot

INDEX NVARCHAR(1024) Specifies an index on the rows of the result set that a particular snapshot of a data collection represents

SERVER_TIMESTAMP TIMESTAMP Datetime Server timestamp

DATA_SEQ (deprecated) INTEGER Data sequence ID of the statistics

FILE_NAME VARCHAR(256) File Name

FILL_RATIO DECIMAL Percent Fill ratio

HOST VARCHAR(64) Host name

INITIAL_BLOCK_COUNT BIGINT Counter Count of init pages

PAGE_SIZE INTEGER Byte Page size

PAGE_SIZE_CLASS VARCHAR(32) Page size class

PORT INTEGER Internal port

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 403

Page 404: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

SHADOW_BLOCK_COUNT

BIGINT Counter Count of shadow blocks

SUPERBLOCK_COUNT BIGINT Counter Number of used Superblocks

SUPERBLOCK_SIZE INTEGER Byte Superblock size

TOTAL_ALLOCATE_BLOCK_COUNT

BIGINT Counter Number of single and group allocated blocks

TOTAL_SET_BLOCK_FREE_AFTER_SAVEPOINT_COUNT

BIGINT Counter Number of single and group freed-after-savepoint blocks

TOTAL_SET_BLOCK_FREE_COUNT

BIGINT Counter Number of single and group freed blocks

USED_BLOCK_COUNT BIGINT Counter Count of used blocks

VOLUME_ID INTEGER Persistence Volume ID

HOST_DATA_VOLUME_SUPERBLOCK_STATISTICS

Short description

Data volume superblock information per host. The table contains information only for the last 30 days.

Structure

Column name Data type Unit Description

SNAPSHOT_ID TIMESTAMP Datetime ID of the snapshot

INDEX NVARCHAR(1024) Specifies an index on the rows of the result set that a particular snapshot of a data collection represents

SERVER_TIMESTAMP TIMESTAMP Datetime Server timestamp

DATA_SEQ (deprecated) INTEGER Data sequence ID of the statistics

DATA_VOLUME_NAME VARCHAR(256) DataVolume name

FILL_RATIO DECIMAL Percent Fill ratio

404P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 405: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

SUPERBLOCK_COUNT BIGINT Counter Count of Superblocks

SUPERBLOCK_SIZE BIGINT Byte Superblock size

USED_SUPERBLOCK_COUNT

BIGINT Counter Count of used Superblocks

VOLUME_ID INTEGER Persistence Volume ID

HOST_DELTA_MERGE_STATISTICS

Short description

Table delta merge statistics per host. The table contains information only for the last 30 days.

Structure

Column name Data type Unit Description

SNAPSHOT_ID TIMESTAMP Datetime ID of the snapshot

INDEX NVARCHAR(1024) Specifies an index on the rows of the result set that a particular snapshot of a data collection represents

SERVER_TIMESTAMP TIMESTAMP Datetime Server timestamp

DATA_SEQ (deprecated) INTEGER Data sequence ID of the statistics

EXECUTION_TIME BIGINT Millisecond Execution duration

HOST VARCHAR(64) Host name

LAST_ERROR INTEGER Error code of the last error that occurred. Can be used to explain why a merge did not succeed

MEMORY_MERGE VARCHAR(6) Boolean Flag to indicate table was merged in memory only

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 405

Page 406: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

MERGED_DELTA_RECORDS

INTEGER Counter Number of documents in delta

MOTIVATION VARCHAR(8) HARD, SMART, AUTO, FORCE

PART_ID INTEGER Partition number (0 for non-partitioned tables and 1 through number of partitions for partitioned tables

PASSPORT VARCHAR(256) External identifier for table merge called by an application

PORT INTEGER Internal port

SCHEMA_NAME VARCHAR(256) Schema name

START_TIME TIMESTAMP Execution start time

SUCCESS VARCHAR(6) Boolean Call success flag; depends on field TYPE; HINT: application merge hint was accepted/rejected; MERGE/SPARSE: delta merge/optimize compression was completed with or without success

TABLE_NAME VARCHAR(256) Table name

TYPE VARCHAR(7) MERGE (table delta merge), HINT (application merge hint), SPARSE (optimize compression)

HOST_HEAP_ALLOCATORS

Short description

Memory allocator statistics per host. Only allocators where INCLUSIVE_SIZE_IN_USE > 1,000,000,000 bytes are listed.

Structure

406P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 407: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

SNAPSHOT_ID TIMESTAMP Datetime ID of the snapshot

INDEX NVARCHAR(1024) Specifies an index on the rows of the result set that a particular snapshot of a data collection represents

SERVER_TIMESTAMP TIMESTAMP Datetime Server timestamp

CATEGORY VARCHAR(128) Allocator name

DATA_SEQ (deprecated) INTEGER Data sequence ID of the statistics

DEPTH BIGINT Depth

EXCLUSIVE_ALLOC_ERRORS

BIGINT Counter Count of allocation errors

EXCLUSIVE_ALLOCATED_COUNT

BIGINT Counter Count of allocations

EXCLUSIVE_ALLOCATED_SIZE

BIGINT Byte Total allocated size in this allocator

EXCLUSIVE_COUNT_IN_USE

BIGINT Counter Number of blocks currently in use

EXCLUSIVE_DEALLOCATED_COUNT

BIGINT Counter Count of deallocations

EXCLUSIVE_DEALLOCATED_SIZE

BIGINT Byte Total deallocated size in this allocator

EXCLUSIVE_MAX_SINGLE_ALLOCATION_SIZE

BIGINT Byte Maximum ever allocated block size in this allocator

EXCLUSIVE_PEAK_ALLOCATION_SIZE

BIGINT Byte Maximum size of this allocator (estimate)

EXCLUSIVE_SIZE_IN_USE BIGINT Byte Current size of this allocator

FLAGS VARCHAR(64) Allocator flags

HOST VARCHAR(64) Host name

INCLUSIVE_ALLOCATED_COUNT

BIGINT Counter Count of allocations, including suballocators

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 407

Page 408: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

INCLUSIVE_ALLOCATED_SIZE

BIGINT Byte Total allocated size in this allocator and suballocators

INCLUSIVE_COUNT_IN_USE

BIGINT Counter Number of blocks currently in use, including suballocators

INCLUSIVE_DEALLOCATED_COUNT

BIGINT Counter Count of deallocations, including suballocators

INCLUSIVE_DEALLOCATED_SIZE

BIGINT Byte Total deallocated size in this allocator and suballocators

INCLUSIVE_MAX_SINGLE_ALLOCATION_SIZE

BIGINT Byte Maximum ever allocated block size in this allocator and suballocators

INCLUSIVE_PEAK_ALLOCATION_SIZE

BIGINT Byte Maximum size of this allocator and suballocators (estimate)

INCLUSIVE_SIZE_IN_USE BIGINT Byte Current size of this allocator, including suballocators

MALLOC_PROXY_CACHE_MISSES

BIGINT Counter Count of malloc proxy cache misses

PORT INTEGER Internal port

STATISTICS_ID BIGINT Statistics object unique ID

VOLUME_ID INTEGER Persistence Volume ID

HOST_LONG_IDLE_CURSOR

Short description

Long idle cursor on SQL statement. The table contains information only for the last 30 days.

Structure

Column name Data type Unit Description

SNAPSHOT_ID TIMESTAMP Datetime ID of the snapshot

408P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 409: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

INDEX NVARCHAR(1024) Specifies an index on the rows of the result set that a particular snapshot of a data collection represents

SERVER_TIMESTAMP TIMESTAMP Datetime Server time of snapshot

CLIENT_HOST VARCHAR(64) Host name of client machine

CLIENT_PID BIGINT Client Process ID

DATA_SEQ (deprecated) INTEGER Data sequence ID of the statistics

HOST VARCHAR(64) Host name

IDLE_TIME BIGINT Millisecond Time that the connection is unused and idle

INDEX_COL VARCHAR(64) The values of the index column define the dimension names of the vector, that a particular snapshot of a data collection represents

LOGICAL_CONNECTION_ID

INTEGER Logical connection ID in statement routing

PORT INTEGER Internal port

START_MVCC_TIMESTAMP

BIGINT Internal MVCC timestamp of the transaction start time

STATEMENT_STRING NVARCHAR(5000) SQL statement

APPLICATION VARCHAR(512) Application which executes the cursor

APPLICATIONSOURCE VARCHAR(512) Application source which executes the cursor

APPLICATIONUSER VARCHAR(512) Application user which executes the cursor

APPLICATIONVERSION VARCHAR(512) Application version which executes the cursor

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 409

Page 410: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

CONNECTION_STATUS VARCHAR(128) Connection Status: IDLE, RECEIVING, RUNNING or SUSPENDING

STATEMENT_STATUS VARCHAR(128) Status of SQL statement: NONE, ACTIVE, or SUSPENDED

HOST_LONG_RUNNING_STATEMENTS

Short description

Information on long running system operations per host. The table contains information only for the last 7 days.

Structure

Column name Data type Unit Description

SNAPSHOT_ID TIMESTAMP Datetime ID of the snapshot

INDEX NVARCHAR(1024) Specifies an index on the rows of the result set that a particular snapshot of a data collection represents

SERVER_TIMESTAMP TIMESTAMP Datetime Server timestamp

APPLICATION_USER_NAME

NVARCHAR(256) Application user

AUTO_COMMIT VARCHAR(6) Commit mode of the current transaction: TRUE if the current connection is in auto-commit mode, FALSE otherwise

CLIENT_HOST VARCHAR(64) Host name of client machine

CLIENT_IP VARCHAR(16) IP of client machine

CLIENT_PID BIGINT Client Process ID

CONNECTION_ID INTEGER Connection ID

CONNECTION_START_TIME

TIMESTAMP Datetime Connection start timestamp

410P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 411: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

DATA_SEQ (deprecated) INTEGER Data sequence ID of the statistics

DURATION BIGINT Millisecond Connection duration

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

THREAD_DETAIL NVARCHAR(5000) Method detail, e.g. SQL statement

THREAD_ID BIGINT Thread ID

TRANSACTION_ID INTEGER Transaction ID

UPDATE_TRANSACTION_ID

BIGINT Number Update transaction ID

USER_NAME NVARCHAR(256) Name of user who triggered the statement

HOST_LONG_SERIALIZABLE_TRANSACTION

Short description

Transactions created by users that are started and running. The table contains information only for the last 30 days.

Structure

Column name Data type Unit Description

SNAPSHOT_ID TIMESTAMP Datetime ID of the snapshot

INDEX NVARCHAR(1024) Specifies an index on the rows of the result set that a particular snapshot of a data collection represents

SERVER_TIMESTAMP TIMESTAMP Datetime Server time of snapshot

CLIENT_HOST VARCHAR(64) Host name of client machine

CLIENT_PID BIGINT Client Process ID

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 411

Page 412: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

CONNECTION_STATUS VARCHAR(128) Connection Status: 'RUNNING'/'IDLE'

DATA_SEQ (deprecated) INTEGER Data sequence ID of the statistics

HOST VARCHAR(64) Host name

INDEX_COL(deprecated) VARCHAR(64) Index column

LOGICAL_CONNECTION_ID

INTEGER Logical connection ID in statement routing

MIN_MVCC_SNAPSHOT_TIMESTAMP

BIGINT Logical timestamp of the first executed statement in the transaction

PORT INTEGER Internal port

TOTAL_TIME BIGINT Millisecond Duration from start time to snapshot

TRANSACTION_ID INTEGER Transaction object ID

UPDATE_TRANSACTION_ID

BIGINT Write transaction ID (this number automatically increments)

HOST_MEMORY_STATISTICS (Deprecated)

This table is deprecated. Instead, use HOST_RESOURCE_UTILIZATION_STATISTICS, HOST_SERVICE_MEMORY.

HOST_ONE_DAY_FILE_COUNT

Short description

Information on trace files accumulated per host

Structure

Column name Data type Unit Description

SNAPSHOT_ID TIMESTAMP Datetime ID of the snapshot

412P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 413: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

INDEX NVARCHAR(1024) Specifies an index on the rows of the result set that a particular snapshot of a data collection represents

SERVER_TIMESTAMP TIMESTAMP Datetime Server timestamp

DATA_SEQ (deprecated) INTEGER Data sequence ID of the statistics

FILE_TYPE VARCHAR(128) String File type

HOST VARCHAR(64) Host name

NUM_FILES BIGINT Number Number of trace files

SUM_SIZE BIGINT Number Total size of trace files

HOST_RESOURCE_UTILIZATION_STATISTICS

Short description

Host resource utilization

Structure

Column name Data type Unit Description

SNAPSHOT_ID TIMESTAMP Datetime ID of the snapshot

INDEX NVARCHAR(1024) Specifies an index on the rows of the result set that a particular snapshot of a data collection represents

SERVER_TIMESTAMP TIMESTAMP Datetime Server timestamp

ALLOCATION_LIMIT BIGINT Byte Allocation limit for all processes

DATA_SEQ (deprecated) INTEGER Data sequence ID of the statistics

FREE_PHYSICAL_MEMORY

BIGINT Byte Free physical memory on the host

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 413

Page 414: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

FREE_SWAP_SPACE BIGINT Byte Free swap memory on the host

HOST VARCHAR(64) Host name

SNAPSHOT_DELTA BIGINT Millisecond Time difference to previous snapshot

TOTAL_CPU_IDLE_TIME (deprecated)

BIGINT Millisecond CPU idle time

TOTAL_CPU_IDLE_TIME_DELTA

BIGINT Millisecond CPU idle time difference to previous snapshot

TOTAL_CPU_SYSTEM_TIME (deprecated)

BIGINT Millisecond CPU time spent in kernel mode

TOTAL_CPU_SYSTEM_TIME_DELTA

BIGINT Millisecond CPU time spent in kernel mode difference to previous snapshot

TOTAL_CPU_USER_TIME (deprecated)

BIGINT Millisecond CPU time spent in user mode

TOTAL_CPU_USER_TIME_DELTA

BIGINT Millisecond CPU time spent in user mode difference to previous snapshot

TOTAL_CPU_WIO_TIME (deprecated)

BIGINT Millisecond CPU time spent in wait IO (Linux only, Windows always 0)

TOTAL_CPU_WIO_TIME_DELTA

BIGINT Millisecond CPU time difference to previous snapshot spent in wait IO( Linux only, Windows always 0)

USED_PHYSICAL_MEMORY

BIGINT Byte Used physical memory on the host

USED_SWAP_SPACE BIGINT Byte Used swap memory on the host

HOST_SAVEPOINTS

Short description

Current and historical savepoint statistics. The table contains information only for the last 7 days.

414P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 415: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Structure

Column name Data type Unit Description

SNAPSHOT_ID TIMESTAMP Datetime ID of the snapshot

INDEX NVARCHAR(1024) Specifies an index on the rows of the result set that a particular snapshot of a data collection represents

SERVER_TIMESTAMP TIMESTAMP Datetime Server time of snapshot

DATA_SEQ (deprecated) INTEGER Data sequence ID of the statistics

CRITICAL_PHASE_DURATION

BIGINT Microsecond Time spent in critical phase (updates are blocked during this)

DURATION BIGINT Microsecond Total time spent for creating savepoint

FLUSHED_PAGES BIGINT Counter Count of asynchronously flushed pages

FLUSHED_PAGES_IN_CRITICAL_PHASE

BIGINT Counter Count of pages flushed in critical phase

FLUSHED_ROWSTORE_PAGES

BIGINT Counter Count of asynchronously flushed row store pages

FLUSHED_ROWSTORE_PAGES_IN_CRITICAL_PHASE

BIGINT Counter Count of row store pages flushed in critical phase

FLUSHED_ROWSTORE_SIZE

BIGINT Byte Size of asynchronously flushed row store pages

FLUSHED_ROWSTORE_SIZE_IN_CRITICAL_PHASE

BIGINT Byte Size of row store pages flushed in critical phase

FLUSHED_SIZE BIGINT Byte Size of asynchronously flushed pages

FLUSHED_SIZE_IN_CRITICAL_PHASE

BIGINT Byte Size of pages flushed in critical phase

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 415

Page 416: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

REQUESTED_FREQUENCY

BIGINT Second Configured savepoint frequency

RTT_SIZE BIGINT Counter Total size of rollback transaction table at this savepoint

START_TIME TIMESTAMP Savepoint start time

STATE VARCHAR(16) Savepoint state

TIME_SINCE_PREVIOUS BIGINT Second Time between previous and this savepoint

TOTAL_SIZE BIGINT Byte Total amount of bytes written for this savepoint

VERSION INTEGER Counter Savepoint version

VOLUME_ID INTEGER Persistence Volume ID

HOST_SAVEPOINT_STATISTICS (Deprecated)

This table is deprecated. Instead, use HOST_SAVEPOINTS.

HOST_SERVICE_COMPONENT_MEMORY

Short description

Memory usage of each service component. The table contains information only for the last 30 days.

Structure

Column name Data type Unit Description

SNAPSHOT_ID TIMESTAMP Datetime ID of the snapshot

INDEX NVARCHAR(1024) Specifies an index on the rows of the result set that a particular snapshot of a data collection represents

SERVER_TIMESTAMP TIMESTAMP Datetime Server time of snapshot

416P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 417: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

COMPONENT VARCHAR(5000) The logical component for which memory usage is reported

DATA_SEQ (deprecated) INTEGER Data sequence ID of the statistics

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

USED_MEMORY_SIZE BIGINT Amount of memory which is currently actually used for the logical component

HOST_SERVICE_MEMORY

Short description

Service memory usage per host. The table contains information only for the last 30 days.

Structure

Column name Data type Unit Description

SNAPSHOT_ID TIMESTAMP Datetime ID of the snapshot

INDEX NVARCHAR(1024) Specifies an index on the rows of the result set that a particular snapshot of a data collection represents

SERVER_TIMESTAMP TIMESTAMP Datetime Server timestamp

ALLOCATION_LIMIT BIGINT Byte Maximum memory pool size (configurable value)

CODE_SIZE BIGINT Byte Process code size

COMPACTORS_ALLOCATED_SIZE

BIGINT Byte Total memory allocated by compactors

COMPACTORS_FREEABLE_SIZE

BIGINT Byte Memory which can be freed on demand

DATA_SEQ (deprecated) INTEGER Data sequence ID of the statistics

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 417

Page 418: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

EFFECTIVE_ALLOCATION_LIMIT

BIGINT Byte Effective maximum memory pool size, considering pool sizes of other processes (computed value)

HEAP_MEMORY_ALLOCATED_SIZE

BIGINT Byte Process heap memory allocated size

HEAP_MEMORY_USED_SIZE

BIGINT Byte Process heap memory used

HOST VARCHAR(64) Host name

LOGICAL_MEMORY_SIZE BIGINT Byte Process virtual memory size

PHYSICAL_MEMORY_SIZE

BIGINT Byte Process physical memory size

PORT INTEGER Internal port

PROCESS_ID BIGINT Process ID

SERVICE_NAME VARCHAR(256) Service name

SHARED_MEMORY_ALLOCATED_SIZE

BIGINT Byte Process shared memory allocated (row store only)

SHARED_MEMORY_USED_SIZE

BIGINT Byte Process shared memory used (row store only)

STACK_SIZE BIGINT Byte Process stack size

TOTAL_MEMORY_USED_SIZE

BIGINT Amount of memory from the memory pool that is currently actually in use

HOST_SERVICE_STATISTICS

Short description

Memory utilization by services per host

Structure

418P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 419: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

SNAPSHOT_ID TIMESTAMP Datetime ID of the snapshot

INDEX NVARCHAR(1024) Specifies an index on the rows of the result set that a particular snapshot of a data collection represents

SERVER_TIMESTAMP TIMESTAMP Datetime Server timestamp

ACTIVE_REQUEST_COUNT

INTEGER Number of active requests

ACTIVE_STATUS VARCHAR(128) NO, YES, UNKNOWN, STARTING, STOPPING

ACTIVE_THREAD_COUNT INTEGER Number of active threads

ALL_FINISHED_REQUEST_COUNT

BIGINT Counter Finished requests including internal requests

AVAILABLE_MEMORY BIGINT Host physical+swap memory size

DATA_SEQ (deprecated) INTEGER Data sequence ID of the statistics

DETAIL VARCHAR(128) Detail information, similar to COORDINATOR_TYPE in M_SERVICES

FINISHED_NON_INTERNAL_REQUEST_COUNT

BIGINT Counter Finished requests

HOST VARCHAR(64) Host name

OPEN_FILE_COUNT INTEGER Number of open files

PENDING_REQUEST_COUNT

INTEGER Number of pending requests

PHYSICAL_MEMORY BIGINT Host physical memory size

PORT INTEGER Internal port

PROCESS_CPU_TIME BIGINT Millisecond CPU usage of current process since start

PROCESS_ID BIGINT Process ID

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 419

Page 420: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

PROCESS_MEMORY BIGINT Process logical memory usage

PROCESS_PHYSICAL_MEMORY

BIGINT Process physical memory usage

REQUESTS_PER_SEC DECIMAL Requests per second. Average over last 1000 requests

RESPONSE_TIME INTEGER Millisecond Request response time. Average over last 1000 requests

SERVICE_NAME VARCHAR(256) Service name

START_TIME TIMESTANP Process start time

THREAD_COUNT INTEGER Number of total threads

TOTAL_CPU_TIME BIGINT Millisecond CPU usage of all processes since start

TOTAL_MEMORY BIGINT CPU usage of all threads

HOST_SQL_PLAN_CACHE

Short description

Statistics of an individual execution plan. The table contains information only for the last 30 days.

Structure

Column name Data type Unit Description

SNAPSHOT_ID TIMESTAMP Datetime ID of the snapshot

INDEX NVARCHAR(1024) Specifies an index on the rows of the result set that a particular snapshot of a data collection represents

SERVER_TIMESTAMP TIMESTAMP Datetime Server time of snapshot

ABAP_VARCHAR_MODE VARCHAR(6) TRUE if ABAP VARCHAR mode enabled, FALSE otherwise. ABAP

420P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 421: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

application developers concern this mode, which indicates null terminated string or not

ACCESSED_OBJECTS VARCHAR(2000) Relevant table object ID list for the plan

AVG_CURSOR_DURATION

BIGINT Microsecond Average time of plan execution including communicate time with clients

AVG_EXECUTION_CLOSE_TIME

BIGINT Microsecond Average time for cursor close

AVG_EXECUTION_FETCH_TIME

BIGINT Microsecond Average time for cursor fetch

AVG_EXECUTION_OPEN_TIME

BIGINT Microsecond Average time for cursor open

AVG_EXECUTION_TIME BIGINT Microsecond Average time of plan execution

AVG_PREPARATION_TIME

BIGINT Microsecond Average time of plan preparation

AVG_TABLE_LOAD_TIME_DURING_PREPARATION

BIGINT Microsecond Average table loading time during plan preparation

DATA_SEQ (deprecated) INTEGER Data sequence ID of the statistics

EXECUTION_COUNT BIGINT Counter Accumulated count of plan execution

EXECUTION_COUNT_BY_ROUTING

BIGINT Counter Accumulated count of plan execution by client-routed connection in statement routing. This column shows how many times the statement is executed in routed connection. The routed connection means a physical connection in a part of the logical session

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 421

Page 422: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

HOST VARCHAR(64) Host name

IS_DISTRIBUTED_EXECUTION

VARCHAR(6) TRUE if tables are located in multi nodes, FALSE otherwise

IS_INTERNAL VARCHAR(6) TRUE if the plan is executed from a database internal connection. FALSE if it is executed from a remote connection

IS_VALID VARCHAR(6) TRUE if the plan is currently valid. A plan is invalidated whenever its corresponding schema objects, such as table and view, are changed. Invalidated plans are recompiled if the same statement is executed, otherwise they are evicted by another plan when newly compiled

LAST_CONNECTION_ID INTEGER The last connection ID that executed the plan

LAST_EXECUTION_TIMESTAMP

TIMESTAMP Last execution timestamp

LAST_PREPARATION_TIMESTAMP

TIMESTAMP Last preparation timestamp

MAX_CURSOR_DURATION

BIGINT Microsecond Maximum time of plan execution including communicate time with clients

MAX_EXECUTION_CLOSE_TIME

BIGINT Microsecond Maximum time for cursor close

MAX_EXECUTION_FETCH_TIME

BIGINT Microsecond Maximum time for cursor fetch

MAX_EXECUTION_OPEN_TIME

BIGINT Microsecond Minimum time for cursor close

422P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 423: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

MAX_EXECUTION_TIME BIGINT Microsecond Maximum time of plan execution

MAX_PREPARATION_TIME

BIGINT Microsecond Maximum time of plan preparation

MAX_TABLE_LOAD_TIME_DURING_PREPARATION

BIGINT Microsecond Maximum table loading time during plan preparation

MIN_CURSOR_DURATION BIGINT Microsecond Maximum time of plan execution including communicate time with clients

MIN_EXECUTION_CLOSE_TIME

BIGINT Microsecond Minimum time for cursor close

MIN_EXECUTION_FETCH_TIME

BIGINT Microsecond Minimum time for cursor fetch

MIN_EXECUTION_OPEN_TIME

BIGINT Microsecond Minimum time for cursor close

MIN_EXECUTION_TIME BIGINT Microsecond Minimum time of plan execution

MIN_PREPARATION_TIME BIGINT Microsecond Minimum time of plan preparation

MIN_TABLE_LOAD_TIME_DURING_PREPARATION

BIGINT Microsecond Minimum table loading time during plan preparation

OWNER_CONNECTION_ID

BIGINT A connection owning the plan

PARAMETER_COUNT BIGINT Counter Number of parameters to be assigned for the execution

PLAN_ID BIGINT Logical plan ID which is a non-negative value

PLAN_MEMORY_SIZE BIGINT Byte Memory size used by the plan

PLAN_SHARING_TYPE VARCHAR(128) The Plan sharing type: 'GLOBAL', 'SESSION

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 423

Page 424: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

EXCLUSIVE GLOBAL', 'SESSION LOCAL'

PORT INTEGER Internal port

PREPARATION_COUNT BIGINT Counter Number of plan preparations

REFERENCE_COUNT BIGINT Counter Number of statements using the plan. When the count reaches zero, it can be evicted by the victim selection policy of plan cache

SCHEMA_NAME NVARCHAR(256) Schema name that the SQL plan belongs to. SQL plans are generated in each schema even though the statement string is the same since the query optimizer statistics might be different

STATEMENT_STRING NVARCHAR(5000) Statement string

TABLE_LOCATIONS VARCHAR(2000) Relevant table locations for the plan

TABLE_TYPES VARCHAR(128) Specification whether the plan refers Column store only, Row store only or mixed, displayed as one of three possible values 'ROW', 'COLUMN', 'ROW, COLUMN'

TOTAL_CURSOR_DURATION

BIGINT Microsecond Sum of time of plan execution including communication time with clients

TOTAL_EXECUTION_CLOSE_TIME

BIGINT Microsecond Sum of time for cleanup of result sets

TOTAL_EXECUTION_FETCH_TIME

BIGINT Microsecond Sum of time for transferring rows

424P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 425: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

TOTAL_EXECUTION_OPEN_TIME

BIGINT Microsecond Sum of time of establishing result sets

TOTAL_EXECUTION_TIME BIGINT Microsecond Sum of time of plan executions

TOTAL_LOCK_WAIT_COUNT

BIGINT Counter Accumulated lock wait count for the plan

TOTAL_LOCK_WAIT_DURATION

BIGINT Counter Accumulated lock wait duration for the plan

TOTAL_METADATA_CACHE_MISS_COUNT

BIGINT Counter Accumulated count of metadata cache misses during plan preparation and plan execution. When a metadata object is first requested to be accessed in a slave server instance, it gets the object from a master server instance via network communication, if the object does not exist or is out of date.

TOTAL_PREPARATION_TIME

BIGINT Microsecond Sum of time of plan preparation

TOTAL_RESULT_RECORD_COUNT

BIGINT Counter Accumulated number of records during plan execution.

TOTAL_TABLE_LOAD_TIME_DURING_PREPARATION

BIGINT Microsecond Sum of table loading time during plan preparation

UPDATED_TABLE_OID BIGINT Object ID of the updated table for the plan

USER_NAME NVARCHAR(256) User name who prepared the plan

VOLUME_ID INTEGER Persistence Volume ID

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 425

Page 426: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

HOST_TABLE_VIRTUAL_FILES (Deprecated)

HOST_UNCOMMITTED_WRITE_TRANSACTION

Short description

Write transactions created by users that are not committed. The table contains information only for the last 30 days.

Structure

Column name Data type Unit Description

SNAPSHOT_ID TIMESTAMP Datetime ID of the snapshot

INDEX NVARCHAR(1024) Specifies an index on the rows of the result set that a particular snapshot of a data collection represents

SERVER_TIMESTAMP TIMESTAMP Datetime Server time of snapshot

CLIENT_PID BIGINT Client Process ID

CLIENT_HOST VARCHAR(64) Host name of client machine

PRIMARY_TRANSACTION INTEGER Primary transaction object ID for the external transaction

VOLUME_ID INTEGER Volume ID where the transaction has started

CONNECTION_STATUS VARCHAR(128) Connection Status: 'RUNNING' or 'IDLE'

DATA_SEQ (deprecated) INTEGER Data sequence ID of the statistics

HOST VARCHAR(64) Host name

INDEX_COL VARCHAR(64) Index column

LOGICAL_CONNECTION_ID

INTEGER Logical connection ID in statement routing

MIN_MVCC_SNAPSHOT_TIMESTAMP

BIGINT Logical timestamp of the first executed statement in the transaction

426P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 427: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

PORT INTEGER Internal port

TOTAL_TIME BIGINT Millisecond Duration from start time to snapshot

TRANSACTION_ID INTEGER Transaction object ID (this number is reused after a transaction is closed)

UPDATE_TRANSACTION_ID

BIGINT Write transaction ID (this number always increments)

HOST_VIRTUAL_FILES (Deprecated)

HOST_VOLUME_FILES

Short description

Information about volume files per host. The table contains information only for the last 30 days.

Structure

Column name Data type Unit Description

SNAPSHOT_ID TIMESTAMP Datetime ID of the snapshot

INDEX NVARCHAR(1024) Specifies an index on the rows of the result set that a particular snapshot of a data collection represents

SERVER_TIMESTAMP TIMESTAMP Datetime Server timestamp

DATA_SEQ (deprecated) INTEGER Data sequence ID of the statistics

FILE_NAME VARCHAR(256) File name

FILE_TYPE VARCHAR(128) Type of file (DATA, LOG, TRACER, ...)

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 427

Page 428: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

TOTAL_SIZE BIGINT Total file size

USED_SIZE BIGINT Size of used data within file

VOLUME_ID INTEGER Volume ID

HOST_VOLUME_IO_DETAILED_STATISTICS

Short description

File access detailed statistics, collected periodically

Full description

This table shows detailed I/O statistics (collected periodically) for various buffer sizes. Each buffer size is a max. value. That is, buffer size 4k actually means <= 4k and buffer size 16k means 4k < buffer size <= 16k. The I/O time is the total time from starting a request until it finishes, including enqueue time. All measured times are periods of time between enqueueing and finishing a request. This means they contain wait times if the request cannot be started immediately. Enqueue time is measured separately to see how many requests are executed asynchronously and how many are synchronous or blocking. For overall I/O performance, see TOTAL_READ/WRITE_SIZE and TOTAL_IO_TIME in the monitoring view M_VOLUME_IO_TOTAL_STATISTICS.

Structure

Column name Data type Unit Description

SNAPSHOT_ID TIMESTAMP Datetime ID of the snapshot

INDEX NVARCHAR(1024) Specifies an index on the rows of the result set that a particular snapshot of a data collection represents

SERVER_TIMESTAMP TIMESTAMP Datetime Server time of snapshot

ACTIVE_APPEND_COUNT BIGINT Count of active appends

ACTIVE_READ_COUNT BIGINT Count of active reads

ACTIVE_TRIGGER_ASYNC_READ_COUNT

BIGINT Count of active trigger asynchronous reads

ACTIVE_TRIGGER_ASYNC_WRITE_COUNT

BIGINT Count of active trigger asynchronous writes

ACTIVE_WRITE_COUNT BIGINT Count of active writes

428P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 429: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

APPEND_COUNT BIGINT Count of appends

AVG_APPEND_SIZE BIGINT Size of appended data (avg)

AVG_APPEND_TIME BIGINT Time for appends (avg)

AVG_READ_SIZE BIGINT Size of read data (avg)

AVG_READ_TIME BIGINT Time for reads (avg)

AVG_TRIGGER_ASYNC_READ_SIZE

BIGINT Size of trigger asynchronous read data (avg)

AVG _TRIGGER_ASYNC_READ_TIME

BIGINT Time for trigger asynchronous reads (avg)

AVG _TRIGGER_ASYNC_WRITE_SIZE

BIGINT Size of trigger asynchronous write data (avg)

AVG _TRIGGER_ASYNC_WRITE_TIME

BIGINT Time for trigger asynchronous writes (avg)

AVG_WRITE_SIZE BIGINT Size of written data (avg)

AVG_WRITE_TIME BIGINT Time for writes (avg)

CONFIGURATION VARCHAR(128) Configuration parameters

DATA_SEQ (Deprecated) INTEGER Data sequence ID of the statistics

FILESYSTEM_TYPE VARCHAR(16) File system type

HOST VARCHAR(64) Host name

MAX_APPEND_SIZE BIGINT Size of appended data (max)

MAX_APPEND_TIME BIGINT Time for appends (max)

MAX_IO_BUFFER_SIZE BIGINT Max. IO buffer size

MAX_READ_SIZE BIGINT Size of read data (max)

MAX_READ_TIME BIGINT Time for reads (max)

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 429

Page 430: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

MAX_TRIGGER_ASYNC_READ_SIZE

BIGINT Size of trigger asynchronous read data (max)

MAX_TRIGGER_ASYNC_READ_TIME

BIGINT Time for trigger asynchronous reads (max)

MAX_TRIGGER_ASYNC_WRITE_SIZE

BIGINT Size of trigger asynchronous write data (max)

MAX_TRIGGER_ASYNC_WRITE_TIME

BIGINT Time for trigger asynchronous writes (max)

MAX_WRITE_SIZE BIGINT Size of written data (max)

MAX_WRITE_TIME BIGINT Time for writes (max)

MIN_APPEND_SIZE BIGINT Size of appended data (min)

MIN_APPEND_TIME BIGINT Time for appends (min)

MIN_READ_SIZE BIGINT Size of read data (min)

MIN_READ_TIME BIGINT Time for reads (min)

MIN_TRIGGER_ASYNC_READ_SIZE

BIGINT Size of trigger asynchronous read data (min)

MIN_TRIGGER_ASYNC_READ_TIME

BIGINT Time for trigger asynchronous reads (min)

MIN_TRIGGER_ASYNC_WRITE_SIZE

BIGINT Size of trigger asynchronous write data (min)

MIN_TRIGGER_ASYNC_WRITE_TIME

BIGINT Time for trigger asynchronous writes (min)

MIN_WRITE_SIZE BIGINT Size of written data (min)

MIN_WRITE_TIME BIGINT Time for writes (min)

PATH VARCHAR(512) File system path

430P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 431: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

PORT INTEGER Internal port

READ_COUNT BIGINT Count of reads

TRIGGER_ASYNC_READ_COUNT

BIGINT Count of trigger asynchronous reads

TRIGGER_ASYNC_WRITE_COUNT

BIGINT Count of trigger asynchronous writes

TYPE VARCHAR(16) Type of contained files

VOLUME_ID INTEGER Persistence Volume ID

WRITE_COUNT BIGINT Count of writes

HOST_VOLUME_IO_PERFORMANCE_STATISTICS (Deprecated)

HOST_VOLUME_IO_RETRY_STATISTICS

Short description

File access retry statistics, collected periodically

Full description

This table shows retry and error I/O statistics (collected periodically) for various buffer sizes. Each buffer size is a max. value. That is, buffer size 4k actually means <= 4k and buffer size 16k means 4k < buffer size <= 16k. For overall I/O performance, see TOTAL_READ/WRITE_SIZE and TOTAL_IO_TIME in the monitoring view M_VOLUME_IO_TOTAL_STATISTICS.

Structure

Column name Data type Unit Description

SNAPSHOT_ID TIMESTAMP Datetime ID of the snapshot

INDEX NVARCHAR(1024) Specifies an index on the rows of the result set that a particular snapshot of a data collection represents

SERVER_TIMESTAMP TIMESTAMP Datetime Server time of snapshot

AVG_FULL_RETRY_READS_PER_REQUEST_COUNT

BIGINT Count of full retry reads per request with full retry reads (avg)

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 431

Page 432: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

AVG_FULL_RETRY_WRITES_PER_REQUEST_COUNT

BIGINT Count of full retry writes per request with full retry writes (avg)

AVG_SHORT_READS_PER_REQUEST_COUNT

BIGINT Count of short reads per request with short reads (avg)

AVG_SHORT_WRITES_PER_REQUEST_COUNT

BIGINT Count of short writes per request with short writes (avg)

CONFIGURATION VARCHAR (128) Configuration parameters

DATA_SEQ (Deprecated) INTEGER Data sequence ID of the statistics

FAILED_APPEND_COUNT BIGINT Count of failed appends

FAILED_READ_COUNT BIGINT Count of failed reads

FAILED_WRITE_COUNT BIGINT Count of failed writes

FILESYSTEM_TYPE VARCHAR(16) File system type

FULL_RETRY_READ_COUNT

BIGINT Count of full retry reads

FULL_RETRY_WRITE_COUNT

BIGINT Count of full retry writes

HOST VARCHAR(64) Host name

MAX_FULL_RETRY_READS_PER_REQUEST_COUNT

BIGINT Count of full retry reads per request (max)

MAX_FULL_RETRY_WRITES_PER_REQUEST_COUNT

BIGINT Count of full retry writes per request (max)

MAX_IO_BUFFER_SIZE BIGINT Max. IO buffer size

MAX_SHORT_READS_PER_REQUEST_COUNT

BIGINT Count of short reads per request (max)

MAX_SHORT_WRITES_PER_REQUEST_COUNT

BIGINT Count of short writes per request (max)

PATH VARCHAR(512) File system path

432P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 433: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

PORT INTEGER Internal port

REQUESTS_WITH_FULL_RETRY_READS_COUNT

BIGINT Count of requests with full retry reads

REQUESTS_WITH_FULL_RETRY_WRITES_COUNT

BIGINT Count of requests with full retry writes

REQUESTS_WITH_SHORT_READS_COUNT

BIGINT Count of requests with short reads

REQUESTS_WITH_SHORT_WRITES_COUNT

BIGINT Count of requests with short writes

SHORT_READ_COUNT BIGINT Count of short reads

SHORT_WRITE_COUNT BIGINT Count of short writes

TOTAL_APPEND_COUNT BIGINT Count of all appends

TOTAL_READ_COUNT BIGINT Count of all reads

TOTAL_WRITE_COUNT BIGINT Count of all writes

TYPE VARCHAR(16) Type of contained files

VOLUME_ID INTEGER Persistence Volume ID

HOST_VOLUME_IO_STATISTICS

Short description

File access statistics per host. The table contains information only for the last 30 days.

Structure

Column name Data type Unit Description

SNAPSHOT_ID TIMESTAMP Datetime ID of the snapshot

INDEX NVARCHAR(1024) Specifies an index on the rows of the result set that a particular snapshot of a data collection represents

SERVER_TIMESTAMP TIMESTAMP Datetime Server timestamp

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 433

Page 434: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

BLOCKED_WRITE_REQUESTS

BIGINT Count of blocked write requests

CLOSE_CALL_COUNT BIGINT Count of close calls

CONFIGURATION VARCHAR(128) Configuration parameters

DATA_SEQ (deprecated) INTEGER Data sequence ID of the statistics

ENQUEUED_WRITE_REQUESTS

BIGINT Count of enqueued write requests

EOF_READS BIGINT Count of EOF reads

EXISTS_CALL_COUNT BIGINT Count of exists calls

FILESYSTEM_TYPE VARCHAR(16) Filesystem type

GETDEVICEID_CALL_COUNT

BIGINT Count of get DeviceID calls

GETSIZE_CALL_COUNT BIGINT Count of get size calls

GETMODIFICATIONTIME_CALL_COUNT

BIGINT Count of get modification time calls

HOST VARCHAR(64) Host name

MAX_BLOCKED_WRITE_REQUESTS

BIGINT Max count of blocked write requests

OPEN_CALL_COUNT BIGINT Count of open calls

PATH VARCHAR(256) File system path

PORT INTEGER Internal port

REMOVE_CALL_COUNT BIGINT Count of remove calls

RESIZE_CALL_COUNT BIGINT Count of resize calls

SYNC_CALL_COUNT BIGINT Count of sync calls

TOTAL_APPENDS BIGINT Count of appends

TOTAL_ASYNC_READS BIGINT Count of asynchronous reads with waiting

434P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 435: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

TOTAL_ASYNC_WRITES BIGINT Count of asynchronous writes with waiting

TOTAL_FAILED_READS BIGINT Count of failed reads

TOTAL_FULL_RETRY_READS

BIGINT Count of full retry reads

TOTAL_FULL_RETRY_WRITES

BIGINT Count of full retry writes

TOTAL_IO_TIME BIGINT Total I/O time

TOTAL_IO_TIME_DELTA BIGINT Millisecond Total IO time difference to previous snapshot

TOTAL_READ_SIZE BIGINT Size of read data

TOTAL_READ_SIZE_DELTA

BIGINT Byte Size of read data difference to previous snapshot

TOTAL_READ_TIME BIGINT Total read time

TOTAL_READ_TIME_DELTA

BIGINT Millisecond Total read time difference to previous snapshot

TOTAL_SHORT_READS BIGINT Count of short reads

TOTAL_SHORT_WRITES BIGINT Count of short writes

TOTAL_SYNC_READS BIGINT Count of synchronous reads

TOTAL_SYNC_WRITES BIGINT Count of synchronous writes

TOTAL_TRIGGER_ASYNC_READS

BIGINT Count of triggered asynchronous reads

TOTAL_TRIGGER_ASYNC_WRITES

BIGINT Count of triggered asynchronous writes

TOTAL_WRITE_SIZE BIGINT Size of written data

TOTAL_WRITE_SIZE_DELTA

BIGINT Byte Size of written data difference to previous snapshot

TOTAL_WRITE_TIME BIGINT Size of written data

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 435

Page 436: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

TOTAL_WRITE_TIME_DELTA

BIGINT Millisecond Total write time difference to previous snapshot

TYPE VARCHAR(16) Type of contained files

VOLUME_ID INTEGER Persistence Volume ID

HOST_VOLUME_IO_TOTAL_STATISTICS

Short description

File access statistics, collected periodically

Structure

Column name Data type Unit Description

SNAPSHOT_ID TIMESTAMP Datetime ID of the snapshot

INDEX NVARCHAR(1024) Specifies an index on the rows of the result set that a particular snapshot of a data collection represents

SERVER_TIMESTAMP TIMESTAMP Datetime Server time of snapshot

BLOCKED_WRITE_REQUESTS

BIGINT Counter Count of blocked write requests

CONFIGURATION VARCHAR (128) Configuration parameters

DATA_SEQ (Deprecated) INTEGER Data sequence ID of the statistics

FILESYSTEM_TYPE VARCHAR(16) File system type

HOST VARCHAR(64) Host name

MAX_BLOCKED_WRITE_REQUESTS

BIGINT Counter Max. count of blocked write requests

PATH VARCHAR(512) File system path

PORT INTEGER Internal port

TOTAL_APPENDS BIGINT Counter Count of appends

436P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 437: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

TOTAL_FAILED_READS BIGINT Counter Count of failed reads

TOTAL_FAILED_WRITES BIGINT Counter Count of failed writes

TOTAL_FULL_RETRY_READS

BIGINT Counter Count of full retry reads

TOTAL_FULL_RETRY_WRITES

BIGINT Counter Count of full retry writes

TOTAL_IO_TIME BIGINT Microsecond Total IO time

TOTAL_READ_SIZE BIGINT Byte Size of read data

TOTAL_READ_TIME BIGINT Microsecond Total read time

TOTAL_READS BIGINT Counter Count of synchronous reads

TOTAL_SHORT_READS BIGINT Counter Count of reads that read less bytes than requested

TOTAL_SHORT_WRITES BIGINT Counter Count of writes that wrote less bytes than requested

TOTAL_TRIGGER_ASYNC_READS

BIGINT Counter Count of triggered asynchronous reads

TOTAL_TRIGGER_ASYNC_WRITES

BIGINT Counter Count of triggered asynchronous writes

TOTAL_WRITE_SIZE BIGINT Byte Size of written data

TOTAL_WRITE_TIME BIGINT Microsecond Total write time

TOTAL_WRITES BIGINT Counter Count of synchronous writes

TRIGGER_READ_RATIO DOUBLE Percent Trigger-Ratio of asynchronous reads

TRIGGER_WRITE_RATIO DOUBLE Percent Trigger-Ratio of asynchronous writes

TYPE VARCHAR(16) Type of contained files

VOLUME_ID INTEGER Persistence Volume ID

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 437

Page 438: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

INDEX_SERVER_HEAP_MEMORY_STATISTICS (Deprecated)

STATISTICS_ALERTS

Short description

Information on alerts and their status

Structure

Column name Data type Unit Description

SNAPSHOT_ID TIMESTAMP Datetime ID of the snapshot

INDEX NVARCHAR(1024) Specifies an index on the rows of the result set that a particular snapshot of a data collection represents

HOST VARCHAR(64) Host name

SQL_PORT INTEGER SQL port

ALERT_ID INTEGER Alert ID

ALERT_SEQ INTEGER Alert Sequence

ALERT_TIMESTAMP TIMESTAMP Timestamp of alert

ALERT_RATING TINYINT(3) Alert rating (1-5)

ALERT_DETAILS NVARCHAR(1024) Information on the alert

EMAIL_STATE TINYINT(3) Email sent or not; values 1 or 0

PROCESS_STATE TINYINT(3) State of the process

PROCESS_TIME TIMESTAMP Timestamp of the process

PROCESS_AGENT NVARCHAR(256) User owing the process

STATISTICS_ALERT_INFORMATION

Short description

Information on alerts, possible resolutions and polling intervals

Structure

438P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 439: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Description

ALERT_ID INTEGER Alert ID

ALERT_NAME NVARCHAR(64) Name of the Alert

ALERT_DESCRIPTION NVARCHAR(1024) Description of the alert

ALERT_USERACTION NVARCHAR(1024) Hint to user on actions to take in response to the alert

INTERVAL NVARCHAR(128) Interval between polling

STATISTICS_ALERT_LAST_CHECK_INFORMATION

Short description

Information from the last alert poll

Structure

Column name Data type Unit Description

SNAPSHOT_ID TIMESTAMP Datetime ID of the snapshot

HOST VARCHAR(64) Host name

SQL_PORT INTEGER SQL port

ALERT_ID INTEGER Alert ID

ALERT_SEQ INTEGER Alert Sequence

INDEX NVARCHAR(128) Specifies an index on the rows of the result set that a particular snapshot of a data collection represents

ALERT_LAST_CHECK_TIMESTAMP

TIMESTAMP Timestamp of last alert check

ALERT_LAST_CHECK_RATING

TINYINT(3) Rating of last alert check

ALERT_LAST_CHECK_EMAIL

TINYINT(3) Email sent on last alert check

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 439

Page 440: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

STATICTICS_CURRENT_ALERTS

Short description

Current alerts of Statistics Sever

Structure

Column name Data type Description

ALERT_SEQ INTEGER Alert Sequence

ALERT_ID INTEGER Alert ID

INDEX NVARCHAR(1024) Dimension name of the array element that causes the alert

SNAPSHOT_ID TIMESTAMP ID of the snapshot

HOST VARCHAR(64) Host name

SQL_PORT INTEGER SQL port

ALERT_DESCRIPTION NVARCHAR(1024) Description of the alert

ALERT_DETAILS NVARCHAR(1024) Information on the alert

ALERT_NAME NVARCHAR(64) Name of the Alert

ALERT_RATING TINYINT Alert rating (1-5)

ALERT_TIMESTAMP TIMESTAMP Timestamp of alert

ALERT_USERACTION NVARCHAR(1024) Hint to user on actions to take in response to the alert

STATISTICS_INTERVAL_INFORMATION

Short description

Information on polling interval durations and last start times

Structure

Column name Data type Description

NAME NVARCHAR(128) Name of interval

DURATION INTEGER Duration of internal in seconds

440P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 441: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Description

START_TIME TIMESTAMP Start time of interval

STATISTICS_LAST_CHECKS

Short description

Last check information for Statistics Server alerts

Structure

Column name Data type Unit Description

ALERT_ID INTEGER Alert ID

MIN_ALERT_SEQ(deprecated)

INTEGER Minimum alert sequence number

SNAPSHOT_ID TIMESTAMP ID of the snapshot

ALERT_DESCRIPTION NVARCHAR(1024) Description of the alert

ALERT_NAME NVARCHAR(64) Name of the Alert

ALERT_LAST_CHECK_TIMESTAMP

TIMESTAMP Timestamp of last alert check

ALERT_NEXT_CHECK_TIMESTAMP

TIMESTAMP Timestamp of next point in time that the alert is checked

ALERT_LAST_CHECK_RATING

BIGINT Rating of last alert check

ALERT_USERACTION NVARCHAR(1024) Hint to user on actions to take in response to the alert

INTERVAL INTEGER Seconds Interval between polling

INTERVAL_START_TIME TIMESTAMP The point in time that the alert was first checked

ID_COUNT BIGINT Aggregation of checks for this alert

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 441

Page 442: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

STATISTICS_LASTVALUES

Short description

Information on the last recorded status per process

Structure

Column name Data type Description

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

NAME NVARCHAR(128) Process name

INDEX NVARCHAR(1024) Specifies an index on the rows of the result set that a particular snapshot of a data collection represents

REACHED_AT TIMESTAMP Timestamp of last value

VALUE NVARCHAR(5000) The value of the parameter NAME

STATISTICS_STATE

Short description

Information on current state of statistics process

Structure

Column name Data type Description

STATE NVARCHAR(64) State of the process (Starting, Stopping, Running, Stopped)

REACHED_AT TIMESTAMP Time the state was reached

STATISTICS_VERSION

Short description

Information on version of the statistics

Structure

442P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 443: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Description

VERSION TINYINT(3) Statistics version

SINCE TIMESTAMP Active since, timestamp

2.2 AFL_AREAS

Available AFL areas

Structure

Column name Data type Description

AREA_OID BIGINT Object ID of the AFL area

SCHEMA_NAME NVARCHAR(256) Schema name of the AFL area

AREA_NAME NVARCHAR(256) Name of the AFL area

CREATE_TIMESTAMP TIMESTAMP Create timestamp of the AFL area

2.3 AFL_FUNCTIONS

Available AFL functions

Structure

Column name Data type Description

FUNCTION_OID BIGINT Object ID of the AFL function

SCHEMA_NAME NVARCHAR(256) Schema name of the AFL function

AREA_NAME NVARCHAR(256) Name of the AFL area that the AFL function belong to

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 443

Page 444: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Description

PACKAGE_NAME NVARCHAR(256) Name of the AFL package that the AFL function belong to

FUNCTION_NAME NVARCHAR(256) Name of the AFL function

CREATE_TIMESTAMP TIMESTAMP Create timestamp of the AFL function

INPUT_PARAMETER_COUNT INTEGER Number of the input parameters of the AFL function

RETURN_VALUE_COUNT INTEGER Number of the out parameters of the AFL function

FUNCTION_TYPE VARCHAR(7) Type of the AFL function

TECHNICAL_CATEGORY VARCHAR(11) Technical category of the AFL function

2.4 AFL_FUNCTION_PROPERTIES

Available AFL function properties

Structure

Column name Data type Description

SCHEMA_NAME NVARCHAR(256) SCHEMA of the AFL function properties

AREA_NAME NVARCHAR(256) AREA NAME of the AFL function properties

FUNCTION_NAME NVARCHAR(256) FUNCTION NAME of the AFL function properties

KEY NVARCHAR(256) Key of the AFL function properties

VALUE NVARCHAR(1024) Value of the AFL function properties

444P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 445: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

2.5 AFL_PACKAGES

Available AFL packages

Structure

Column name Data type Description

PACKAGE_OID BIGINT Object ID of the AFL package

SCHEMA_NAME NVARCHAR(256) Schema name of the AFL package

AREA_NAME NVARCHAR(256) Name of the AFL area that the AFL package belong to

PACKAGE_NAME NVARCHAR(256) Name of the AFL package

CREATE_TIMESTAMP TIMESTAMP Create timestamp of the AFL package

2.6 AUDIT_POLICIES

Defined audit policies

Structure

Column name Data type Description

AUDIT_POLICY_NAME NVARCHAR(256) Audit policy name

AUDIT_POLICY_OID BIGINT Object ID of the audit policy

EVENT_STATUS VARCHAR(32) Status of events to be audited: 'SUCCESSFUL EVENTS', 'UNSUCCESSFUL EVENTS', 'ALL EVENTS'

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 445

Page 446: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Description

EVENT_LEVEL VARCHAR(16) Level of events to be audited: 'EMERGENCY', 'CRITICAL', 'ALERT', 'WARNING', 'INFO'

IS_AUDIT_POLICY_ACTIVE VARCHAR(5) Audit policy is active: 'TRUE', 'FALSE'

EVENT_ACTION VARCHAR(32) Action to be audited, for example: 'SELECT', 'GRANT PRIVILEGE', ...

USER_NAME NVARCHAR(256) User whose actions are to be audited

OBJECT_TYPE VARCHAR(32) Type of object to be audited, 'INVALID' in case of change of object type after creation of audit policy

OBJECT_SCHEMA NVARCHAR(256) Schema of object to be audited

OBJECT_NAME NVARCHAR(256) Name of object to be audited

2.7 AUTHORIZATION_GRAPH

Represents authorization dependencies of complex database objects

Structure

Column name Data type Description

ROOT_DEPENDENT_TYPE_ID SMALLINT Object type ID of the root object to show as a graph

ROOT_DEPENDENT_OBJECT_ID BIGINT Object ID of the root object to show as a graph

DEPENDENT_TYPE_ID SMALLINT Object type ID of the dependent object

DEPENDENT_TYPE_ID_NAME NVARCHAR(256) Object type name of the dependent object

446P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 447: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Description

DEPENDENT_SUBTYPE_ID SMALLINT Object subtype ID of the dependent object

DEPENDENT_SUBTYPE_ID_NAME NVARCHAR(256) Object subtype name of the dependent object

DEPENDENT_OBJECT_ID BIGINT Object ID of the dependent object

DEPENDENT_SCHEMA_NAME NVARCHAR(256) Schema name the dependent object belongs to

DEPENDENT_OBJECT_NAME NVARCHAR(256) Object name of the dependent object

DEPENDENT_OWNER_OID BIGINT ID of the user owning the dependent object

DEPENDENT_OWNER_NAME NVARCHAR(256) Name of the user owning the dependent object

DEPENDENT_READONLY INTEGER Readonly property of the dependent object

UNDERLYING_TYPE_ID SMALLINT Object type ID of the underlying object

UNDERLYING_TYPE_ID_NAME NVARCHAR(256) Object type name of the underlying object

UNDERLYING_SUBTYPE_ID SMALLINT Object subtype ID of the underlying object

UNDERLYING_SUBTYPE_ID_NAME NVARCHAR(256) Object subtype name of the underlying object

UNDERLYING_OBJECT_ID BIGINT Object ID of the underlying object

UNDERLYING_SCHEMA_NAME NVARCHAR(256) Schema name the underlying object belongs to

UNDERLYING_OBJECT_NAME NVARCHAR(256) Object name of the underlying object

UNDERLYING_OWNER_OID BIGINT ID of the user owning the underlying object

UNDERLYING_OWNER_NAME NVARCHAR(256) Name of the user owning the underlying object

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 447

Page 448: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Description

UNDERLYING_READONLY INTEGER Readonly property of the underlying object

DEPENDENCY_USER_OID BIGINT ID of the user required to have a certain privilege on the underlying object in order to validate the dependent object

DEPENDENCY_USER_NAME NVARCHAR(256) Name of the user required to have a certain privilege on the underlying object in order to validate the dependent object

DEPENDENCY_TYPE SMALLINT Type of dependency determines the validation semantics for dependencies sharing the same dependent objects

PRIVILEGE_ID BIGINT ID of the privilege the dependency user is required to have on the underlying object

PRIVILEGE_NAME NVARCHAR(256) Name of the privilege the dependency user is required to have on the underlying object

IS_VALID TINYINT Current state of the dependency (as integer). It is set by the object validation logic and reflects missing privileges or invalidated objects: 0 .. 3

DEPENDENCY_STATUS VARCHAR(40) Current state of a privilege for the dependent object: 'INVALID', 'NOT AUTHORIZED', 'AUTHORIZED NON GRANTABLE', 'AUTHORIZED GRANTABLE'

AVAILABLE_PRIVILEGES VARCHAR(256) Current state of a privilege on upper node (dependent object): 'INVALID', 'NOT GRANTABLE', 'GRANTABLE'

2.8 CONSTRAINTS

Constraints defined for tables

448P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 449: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Structure

Column name Data type Description

SCHEMA_NAME NVARCHAR(256) Schema name

TABLE_NAME NVARCHAR(256) Table name

COLUMN_NAME NVARCHAR(256) Column name

POSITION SMALLINT Column position in this constraint

CONSTRAINT_NAME NVARCHAR(256) Constraint name

IS_PRIMARY_KEY VARCHAR(5) Constraint is primary key constraint: 'TRUE', 'FALSE'

IS_UNIQUE_KEY VARCHAR(5) Constraint is unique constraint: 'TRUE', 'FALSE'

2.9 CREDENTIALS

Credentials defined for users and components

Structure

Column name Data type Description

USER_NAME NVARCHAR(256) Name of the user the credential belongs to

COMPONENT NVARCHAR(256) Name of the component the credential is valid for

PURPOSE NVARCHAR(256) Purpose, for example remote machine, the credential is valid for

CREDENTIAL_TYPE NVARCHAR(64) Type of the credential, e.g. password or X509

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 449

Page 450: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

2.10 CS_BO_VIEWS

Business object views for column store join views

Structure

Column name Data type Description

SCHEMA_NAME NVARCHAR(256) Schema name

VIEW_NAME NVARCHAR(256) Join view name

BO_VIEW_NAME NVARCHAR(256) Business object view name

ANCHOR_SCHEMA_NAME NVARCHAR(256) Anchor schema name

ANCHOR_TABLE_NAME NVARCHAR(256) Anchor table name

2.11 CS_FREESTYLE_COLUMNS

Freestyle search columns for column store join views

Structure

Column name Data type Description

SCHEMA_NAME NVARCHAR(256) Schema name

VIEW_NAME NVARCHAR(256) Join view name

COLUMN_NAME NVARCHAR(256) Freestyle column name

2.12 CS_JOIN_CONDITIONS

Join conditions defined for column store join views

450P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 451: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Structure

Column name Data type Description

SCHEMA_NAME NVARCHAR(256) Schema name

VIEW_NAME NVARCHAR(256) Join view name

JOIN_CONDITION_NAME NVARCHAR(256) Join condition name

JOIN_ORDER BIGINT Join order number

TABLE_SCHEMA_NAME1 NVARCHAR(256) Schema name of column 1

TABLE_NAME1 NVARCHAR(256) Table name of column 1

COLUMN_NAME1 NVARCHAR(256) Name of column 1

ALIAS_NUMBER1 INTEGER Alias Number of table name 1

TABLE_SCHEMA_NAME2 NVARCHAR(256) Schema name of column 2

TABLE_NAME2 NVARCHAR(256) Table name of column 2

COLUMN_NAME2 NVARCHAR(256) Name of column 2

ALIAS_NUMBER2 INTEGER Alias Number of table name 2

CONSTRAINTS NVARCHAR(256) Join constraint name

JOIN_TYPE VARCHAR(5) Join type: 'inner', 'left', 'right', 'full'

CARDINALITY VARCHAR(3) Join cardinality: '1:1', '1:n', 'n:1', 'n:n'

2.13 CS_JOIN_CONSTRAINTS

Join constraints defined for column store join views

Structure

Column name Data type Description

SCHEMA_NAME NVARCHAR(256) Schema name

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 451

Page 452: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Description

VIEW_NAME NVARCHAR(256) Join view name

JOIN_CONSTRAINT_NAME NVARCHAR(256) Join constraint name

CONSTRAINT_TYPE VARCHAR(32) Type of constraint owner

LOCATION NVARCHAR(256) Name of constraint owner

TABLE_SCHEMA_NAME NVARCHAR(256) Schema name of table

TABLE_NAME NVARCHAR(256) Table name of column

COLUMN_NAME NVARCHAR(256) Column name

OPERATOR NVARCHAR(256) Operator

VALUE NVARCHAR(5000) Value

2.14 CS_JOIN_PATHS

Join paths defined for column store join views

Structure

Column name Data type Description

SCHEMA_NAME NVARCHAR(256) Schema name

VIEW_NAME NVARCHAR(256) Join view name

JOIN_PATH_NAME NVARCHAR(256) Join path name

JOIN_CONDITIONS NVARCHAR(5000) Comma separated list of join conditions

JOIN_CONSTRAINTS NVARCHAR(5000) Comma separated list of join constraints

452P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 453: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

2.15 CS_JOIN_TABLES

Physical tables referred by column store join views

Structure

Column name Data type Description

SCHEMA_NAME NVARCHAR(256) Schema name

VIEW_NAME NVARCHAR(256) Join view name

TABLE_SCHEMA_NAME NVARCHAR(256) Schema name of physical table name

TABLE_NAME NVARCHAR(256) Physical table name

TABLE_TYPE VARCHAR(32) Type of table: 'FACT_TABLE', 'D_TABLE', 'X_TABLE', 'Y_TABLE', 'TEMP_TABLE', 'S_TABLE', 'EXTERNAL_OBJECT', 'CONVERSION_TABLE', 'OLAP_TEXT_TABLE', 'AUTHORIZATION_TABLE', 'HIERARCHY'

2.16 CS_KEY_FIGURES

Key figures defined for column store join views

Structure

Column name Data type Description

SCHEMA_NAME NVARCHAR(256) Schema name

VIEW_NAME NVARCHAR(256) Join view name

KEY_FIGURE_NAME NVARCHAR(256) Key figure name

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 453

Page 454: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Description

DEFAULT_AGGREGATION_TYPE VARCHAR(32) Aggregation type like: 'sum', 'count', 'min', ...

DESCRIPTION NVARCHAR(5000) Description

UNIT_CONVERSION_NAME NVARCHAR(256) Name of unit conversion

TABLE_SCHEMA_NAME NVARCHAR(256) Schema name of table

TABLE_NAME NVARCHAR(256) Table name of column

COLUMN_NAME NVARCHAR(256) Column name

EXPRESSION_FLAGS VARCHAR(32) Expression flags

EXPRESSION NVARCHAR(256) Expression

2.17 CS_VIEW_COLUMNS

Columns defined for column store join views

Structure

Column name Data type Description

SCHEMA_NAME NVARCHAR(256) Schema name

VIEW_NAME NVARCHAR(256) Join view name

VIEW_COLUMN_NAME NVARCHAR(256) View column name

TABLE_SCHEMA_NAME NVARCHAR(256) Schema name of table

TABLE_NAME NVARCHAR(256) Table name of column

ALIAS_NUMBER INTEGER Alias number

COLUMN_NAME NVARCHAR(256) Column name

JOIN_PATH NVARCHAR(256) Join path name

CS_TYPE VARCHAR(16) Column store data type

454P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 455: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Description

EXPRESSION_FLAGS VARCHAR(32) Expression flags

EXPRESSION NVARCHAR(256) Expression

2.18 DATA_STATISTICS

Overview of data statistics objects

Structure

Column name Data type Description

DATA_STATISTICS_OID BIGINT Data statistics object ID

DATA_STATISTICS_TYPE VARCHAR(9) Specifies the data statistics type: 'HISTOGRAM', 'SIMPLE'

DATA_STATISTICS_NAME NVARCHAR(256) Specifies the data statistics name

DATA_SOURCE_OBJECT_TYPE VARCHAR(5) Specifies the data source object type: 'TABLE', 'VIEW'

DATA_SOURCE_SCHEMA_NAME NVARCHAR(256) Specifies the schema name of the data source

DATA_SOURCE_OBJECT_NAME NVARCHAR(256) Specifies the object name of the data source

DATA_SOURCE_COLUMN_NAME NVARCHAR(256) Specifies the column name of the data source

CREATE_TIME TIMESTAMP Specifies the time when the data statistics object was created

LAST_REFRESH_TIME TIMESTAMP Specifies the time when the data statistics object was last refreshed

MINVALUE_NUMERIC DOUBLE Specifies the minimum numeric value of the data source

MINVALUE_STRING NVARCHAR(256) Specifies the minimum string value of the data source

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 455

Page 456: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Description

MAXVALUE_NUMERIC DOUBLE Specifies the maximum numeric value of the data source

MAXVALUE_STRING NVARCHAR(256) Specifies the maximum string value of the data source

COUNT BIGINT Specifies the number of values of the data source

DISTINCT_COUNT BIGINT Specifies the number of unique values of the data source

NULL_COUNT BIGINT Specifies the number of NULL values of the data source

CREATE_BUCKETS BIGINT Specifies the number of buckets specified in the CREATE STATISTICS statement

LAST_REFRESH_BUCKETS BIGINT Specifies the number of buckets used when the data statistics object was last refreshed

CREATE_MEMORY BIGINT Specifies the memory size to be used by the data statistics object specified in the CREATE STATISTICS statement

LAST_REFRESH_MEMORY BIGINT Specifies the memory size used by the data statistics object when the object was last refreshed

CREATE_MEMORY_PERCENT INTEGER Specifies the memory size, as a percentage of the data source size, to be used by the data statistics object specified in the CREATE STATISTICS statement

LAST_REFRESH_MEMORY_PERCENT

INTEGER Specifies the memory size, as a percentage of the data source size, used by the data statistics object when the object was last refreshed

CONSTRAINT VARCHAR(8) Specifies the constraint for the build algorithm for the data statistics object: 'MAXDIFF', 'QOPTIMAL'

456P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 457: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Description

IS_PERSISTENT VARCHAR(5) Specifies if the content of the data statistics object is persistent or not: 'FALSE', 'TRUE'

CREATE_QERROR DECIMAL(34,-1) Specifies the parameter qerror for the data statistics object of type 'HISTOGRAM' as specified in the CREATE STATISTICS statement

LAST_REFRESH_QERROR DECIMAL(34,-1) Specifies the parameter qerror for the data statistics object of type 'HISTOGRAM' as computed at the last refresh

CREATE_QTHETA INTEGER Specifies the parameter qtheta for the data statistics object of type 'HISTOGRAM' as specified at the CREATE STATISTICS statement

LAST_REFRESH_QTHETA INTEGER Specifies the parameter qtheta for the data statistics object of type 'HISTOGRAM' as computed at the last refresh

2.19 DATA_TYPES

Available SQL data types

Structure

Column name Data type Description

TYPE_ID SMALLINT Data type ID

TYPE_NAME VARCHAR(16) Data type name

COLUMN_SIZE INTEGER Maximum size of the data type that this system can support

LITERAL_PREFIX CHAR(1) ODBC 2.0 SQLGetTypeInfo Varchar. Character or characters used to

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 457

Page 458: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Description

prefix a literal, for example, a single quotation mark (') for character data types or 0x for binary data types; NULL is returned for data types where a literal prefix is not applicable

LITERAL_SUFFIX CHAR(1) ODBC 2.0 SQLGetTypeInfo Varchar. Character or characters used to terminate a literal, for example, a single quotation mark (') for character data types; NULL is returned for data types where a literal suffix is not applicable

CREATE_PARAMS VARCHAR(16) ODBC 2.0 SQLGetTypeInfo Varchar. A list of keywords, separated by commas, corresponding to each parameter that the application may specify in parentheses when using the name that is returned in the TYPE_NAME field

NULLABLE TINYINT Specifies whether the data type can accept null or not

CASE_SENSITIVE TINYINT ODBC 2.0 SQLGetTypeInfo smallint. Whether a character data type is case-sensitive in collations and comparisons

SEARCHABLE TINYINT How the data type can be used in the WHERE clause

UNSIGNED_ATTRIBUTE TINYINT Signed or unsigned

FIXED_PREC_SCALE TINYINT Whether the data type has predefined fixed precision and scale (ODBC)

AUTO_UNIQUE_VALUE TINYINT Whether the data type is autoincrementing (ODBC)

LOCAL_TYPE_NAME VARCHAR(16) ODBC 2.0 SQLGetTypeInfo varchar. Localized version of the data source-dependent name of the data type

458P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 459: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Description

MINIMUM_SCALE SMALLINT ODBC 2.0 SQLGetTypeInfo smallint. The minimum scale of the data type on the data source

MAXIMUM_SCALE SMALLINT ODBC 2.0 SQLGetTypeInfo smallint. The maximum scale of the data type on the data source

SQL_DATA_TYPE SMALLINT ODBC 3.0 SQLGetTypeInfo smallint. The value of the SQL data type as it appears in the SQL_DESC_TYPE field of the descriptor. This column is the same as the DATATYPE column, except for interval and datetime data types

SQL_DATETIME_SUB SMALLINT ODBC 3.0 SQLGetTypeInfo smallint. When the value of SQL_DATATYPE is SQL_DATETIME or SQL_INTERVAL, this column contains the datetime/interval subcode

NUM_PREC_RADIX INTEGER ODBC 3.0 SQLGetTypeInfo integer. In case of an approximate numeric data type, value is 2 to indicate that COLUMN_SIZE specifies the number of bits. For exact numeric data types value 10 indicates that COLUMN_SIZE specifies the number of decimal digits

INTERVAL_PRECISION SMALLINT ODBC 3.0 SQLGetTypeInfo smallint. If the data type is an interval data type, then this column contains the value of the interval leading precision. Otherwise, this column is NULL

2.20 EFFECTIVE_PRIVILEGES

Privileges of the current user

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 459

Page 460: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Structure

Column name Data type Description

USER_NAME NVARCHAR(256) Name of the user for whom effective privileges are shown

GRANTEE NVARCHAR(256) User or role that has the privilege

GRANTEE_TYPE VARCHAR(4) 'USER' or 'ROLE'

GRANTOR NVARCHAR(256) User or role that provided the privilege

GRANTOR_TYPE VARCHAR(4) 'USER' or 'ROLE'

OBJECT_TYPE VARCHAR(32) Type of the granted object like: 'TABLE', 'SCHEMA', ...

SCHEMA_NAME NVARCHAR(256) Schema name the object belongs to

OBJECT_NAME NVARCHAR(256) Object name of granted object

COLUMN_NAME NVARCHAR(256) Column name

PRIVILEGE NVARCHAR(256) Privilege granted

IS_GRANTABLE VARCHAR(5) Privilege was granted 'WITH GRANT OPTION', 'WITH ADMIN OPTION': 'TRUE', 'FALSE'

IS_VALID VARCHAR(5) Privilege is valid or it became invalid because of implicit revoking: 'TRUE', 'FALSE'

2.21 EFFECTIVE_ROLES

Roles of the current user

460P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 461: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Structure

Column name Data type Description

USER_NAME NVARCHAR(256) Name of the user for whom effective roles are shown

GRANTEE NVARCHAR(256) User or role that has the role

GRANTEE_TYPE VARCHAR(4) 'USER' or 'ROLE'

GRANTOR NVARCHAR(256) User that granted the role

ROLE_NAME NVARCHAR(256) Role granted

IS_GRANTABLE VARCHAR(5) Role was granted 'WITH ADMIN OPTION': 'TRUE', 'FALSE'

2.22 EXPLAIN_PLAN_TABLE

SQL query plan explanation result

Full description

OPERATOR_NAME column in EXPLAIN_PLAN_TABLE view:

List of column engine operators shown in the OPERATOR_NAME column.

Operator Name Description

COLUMN SEARCH Starting position of column engine operators. OPERATOR_DETAILS lists projected columns.

LIMIT Operator for limiting the number of output rows

ORDER BY Operator for sorting output rows

HAVING Operator for filtering with predicates on top of grouping and aggregation

GROUP BY Operator for grouping and aggregation

DISTINCT Operator for duplicate elimination

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 461

Page 462: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Operator Name Description

FILTER Operator for filtering with predicates

JOIN Operator for joining input relations

COLUMN TABLE Information about accessed column table

MULTIPROVIDER Operator for producing union-all of multiple results having the same grouping and aggregation

List of row engine operators shown in the OPERATOR_NAME column.

Operator Name Description

ROW SEARCH Starting position of row engine operators. OPERATOR_DETAILS lists projected columns.

LIMIT Operator for limiting number of output rows

ORDER BY Operator for sorting output rows

HAVING Operator for filtering with predicates on top of grouping and aggregation

GROUP BY Operator for grouping and aggregation

MERGE AGGREGATION Operator for merging the results of multiple parallel grouping and aggregations

DISTINCT Operator for duplicate elimination

FILTER Operator for filtering with predicates

UNION ALL Operator for producing union-all of input relations

MATERIALIZED UNION ALL Operator for producing union-all of input relations with intermediate result materialization

BTREE INDEX JOIN Operator for joining input relations through B-tree index searches. Join type suffix can be added. For example, B-tree index join for left outer join is shown as BTREE INDEX JOIN (LEFT OUTER). Join without join type suffix means inner join.

CPBTREE INDEX JOIN Operator for joining input relations through CPB-tree index searches. Join type suffix can be added.

HASH JOIN Operator for joining input relations through probing hash table built on the fly. Join type suffix can be added.

462P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 463: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Operator Name Description

NESTED LOOP JOIN Operator for joining input relations through nested looping. Join type suffix can be added.

MIXED INVERTED INDEX JOIN Operator for joining an input relation of row store format with a column table without format conversion using an inverted index of the column table. Join type suffix can be added.

BTREE INDEX SEARCH Table access through B-tree index search

CPBTREE INDEX SEARCH Table access through CPB-tree index search

TABLE SCAN Table access through scanning

AGGR TABLE Operator for aggregating base table directly

MONITOR SEARCH Monitoring view access through search

MONITOR SCAN Monitoring view access through scanning

Structure

Column name Data type Description

STATEMENT_NAME VARCHAR(256) The string specified as STATEMENT_NAME on executing EXPLAIN PLAN command. This is used to distinguish plans from each other when there are multiple plans in EXPLAIN_PLAN_TABLE view

OPERATOR_NAME VARCHAR(5000) Name of an operator

OPERATOR_DETAILS NCLOB Details of an operator. Predicates and expressions used by the operator are shown here

EXECUTION_ENGINE VARCHAR(256) Execution engine where the plan operator is executed: COLUMN or ROW

SCHEMA_NAME NVARCHAR(256) Schema name the dependent object belongs to

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 463

Page 464: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Description

TABLE_NAME NVARCHAR(256) Name of database tables and views accessed by an operator

TABLE_TYPE VARCHAR(5000) Table stored type: COLUMN or ROW

TABLE_SIZE DOUBLE Estimated input row count of an operator. This is available only for operators accessing tables and views directly

OUTPUT_SIZE DOUBLE Estimated output row count of an operator

SUBTREE_COST DOUBLE Estimated cost of executing the subtree starting from an operator

OPERATOR_ID INTEGER Unique ID of an operator. IDs are integers starting from 1

PARENT_OPERATOR_ID INTEGER OPERATOR_ID of the parent of an operator. The shape of a query plan is a tree and the topology of the tree can be reconstructed using OPERATOR_ID and PARENT_OPERATOR_ID. PARENT_OPERATOR_ID of the root operator is shown as NULL

LEVEL INTEGER Level from the root operator. Level of the root operator is 1, level of a child of the root operator is 2 and so on. This can be utilized for output indentation

POSITION INTEGER Position in the parent operator. Position of the first child is 1, position of the second child is 2 and so on

HOST VARCHAR(256) Host where the plan operator is generated

PORT INTEGER Port where the plan operator is generated

TIMESTAMP TIMESTAMP Date and time when the EXPLAIN PLAN command was executed

464P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 465: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Description

CONNECTION_ID INTEGER Connection ID

2.23 FULLTEXT_INDEXES

Fulltext indexes on table columns

Structure

Column name Data type Description

SCHEMA_NAME NVARCHAR(256) Schema name

TABLE_NAME NVARCHAR(256) Table name

TABLE_OID BIGINT Object ID of the table

INDEX_NAME NVARCHAR(256) Name of the fulltext index

INDEX_OID BIGINT Object ID of the fulltext index

LANGUAGE_COLUMN NVARCHAR(256) Column name of the indexed table containing language indicators for the indexed documents

MIME_TYPE_COLUMN NVARCHAR(256) Column name of the indexed table containing MIME type indicators for the indexed documents

LANGUAGE_DETECTION NVARCHAR(256) Set of languages to be considered for automatic language detection

FAST_PREPROCESS VARCHAR(5) If set to true, preprocessing will be done with reduced functionality (e.g. linguistic search is not available), which will speed up the indexing

FUZZY_SEARCH_INDEX VARCHAR(5) If set to true, fuzzy search is performed with an additional index (faster search, but higher memory consumption)

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 465

Page 466: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Description

SEARCH_ONLY VARCHAR(5) If set to true, the text-attributes will not store any DAFs, i.e. it is not possible to retrieve the HTML-converted or original data from the text-attribute. If the text-attribute is a shadow attribute (i.e. created via CREATE FULLTEXT INDEX), the source-attribute (containing the original data) is not affected by this flag

IS_EXPLICIT VARCHAR(5) If set to true, the index is an explicit fulltext index, i.e. created by CREATE FULLTEXT INDEX

FLUSH_AFTER_DOCUMENTS INTEGER Used to store change-tracking behavior of the fulltext index

FLUSH_EVERY_MINUTES INTEGER Used to store change-tracking behavior of the fulltext index

CONFIGURATION NVARCHAR(256) An explicit config-file can be specified, for example, to enable named entity extraction

INTERNAL_COLUMN_NAME NVARCHAR(512) Name of the internal text-attribute, only set if the fulltext index was not created using TEXT-datatype

PHRASE_INDEX_RATIO REAL Float between 0.0 and 1.0 which specifies how much memory the phrase index may use (as a percentage of the memory size of the fulltext index)

TEXT_MINING VARCHAR(5) If set to true, text mining capabilities will be enabled on the indexed column

TEXT_ANALYSIS VARCHAR(5) If set to true, an additional table is created that stores text analysis results, normally this parameter should be set to false

MIME_TYPE NVARCHAR(256) MIME type indicator for the indexed documents

466P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 467: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

2.24 FUNCTIONS

Available functions

Structure

Column name Data type Description

SCHEMA_NAME NVARCHAR(256) Schema name of the function

FUNCTION_NAME NVARCHAR(256) Name of the function

FUNCTION_OID BIGINT Object ID of the function

INPUT_PARAMETER_COUNT INTEGER Input type parameter count

RETURN_VALUE_COUNT INTEGER Return value type parameter count

IS_UNICODE VARCHAR(5) Specifies whether the function contains Unicode or not: 'TRUE', 'FALSE'

DEFINITION NCLOB Query string of the function

FUNCTION_TYPE VARCHAR(10) Type of the function

IS_VALID VARCHAR(5) Specifies whether the function is valid or not. This becomes 'FALSE' when its base objects are changed or dropped: 'TRUE', 'FALSE'

2.25 FUNCTION_PARAMETERS

Parameters of functions

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 467

Page 468: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Structure

Column name Data type Description

SCHEMA_NAME NVARCHAR(256) Schema name of the function

FUNCTION_NAME NVARCHAR(256) Name of the function

FUNCTION_OID BIGINT Object ID of the function

PARAMETER_NAME NVARCHAR(256) Parameter name

DATA_TYPE_ID INTEGER Data type ID

DATA_TYPE_NAME VARCHAR(16) Data type name

LENGTH INTEGER Parameter length

SCALE INTEGER Scale of the parameter

POSITION INTEGER Ordinal position of the parameter

TABLE_TYPE_SCHEMA NVARCHAR(256) Schema name of table type if DATA_TYPE_NAME is TABLE_TYPE

TABLE_TYPE_NAME NVARCHAR(256) Name of table type if DATA_TYPE_NAME is TABLE_TYPE

PARAMETER_TYPE VARCHAR(7) Parameter mode: IN, OUT, INOUT

HAS_DEFAULT_VALUE VARCHAR(5) Specifies whether the parameter has a default value or not: 'TRUE', 'FALSE'

IS_NULLABLE VARCHAR(5) Specifies whether the parameter accepts a null value: 'TRUE', 'FALSE'

2.26 GEOCODE_INDEXES

Geocode indexes on tables

468P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 469: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Structure

Column name Data type Description

SCHEMA_NAME NVARCHAR(256) Schema name

TABLE_NAME NVARCHAR(256) Table name

TABLE_OID BIGINT Object ID of the table

INDEX_NAME NVARCHAR(256) Index name

INDEX_OID BIGINT Object ID of the index

FLUSH_AFTER_DOCUMENTS INTEGER Used to store change-tracking behaviour of the index

FLUSH_EVERY_MINUTES INTEGER Used to store change-tracking behaviour of the index

2.27 GRANTED_PRIVILEGES

Privileges granted to users and roles

Structure

Column name Data type Description

GRANTEE NVARCHAR(256) User or role the privilege is granted to

GRANTEE_TYPE VARCHAR(4) 'USER' or 'ROLE'

GRANTOR NVARCHAR(256) User who granted the privilege

OBJECT_TYPE VARCHAR(32) Type of the granted object like: 'TABLE', 'SCHEMA', ...

SCHEMA_NAME NVARCHAR(256) Schema name the object belongs to

OBJECT_NAME NVARCHAR(256) Object name of granted object

COLUMN_NAME NVARCHAR(256) Column name

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 469

Page 470: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Description

PRIVILEGE NVARCHAR(256) Privilege granted

IS_GRANTABLE VARCHAR(5) Privilege was granted 'WITH GRANT OPTION', 'WITH ADMIN OPTION': 'TRUE', 'FALSE'

IS_VALID VARCHAR(5) Privilege is valid or it became invalid because of implicit revoking: 'TRUE', 'FALSE'

2.28 GRANTED_ROLES

Roles granted to users or other roles

Structure

Column name Data type Description

GRANTEE NVARCHAR(256) User or role the role is granted to

GRANTEE_TYPE VARCHAR(4) 'USER' or 'ROLE'

ROLE_NAME NVARCHAR(256) Name of the granted role

GRANTOR NVARCHAR(256) User who granted the role

IS_GRANTABLE VARCHAR(5) Role was granted 'WITH ADMIN OPTION': 'TRUE', 'FALSE'

2.29 INDEXES

Indexes on tables

470P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 471: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Structure

Column name Data type Description

SCHEMA_NAME NVARCHAR(256) Schema name

TABLE_NAME NVARCHAR(256) Table name

TABLE_OID BIGINT Object ID of the table

INDEX_NAME NVARCHAR(256) Index name

INDEX_OID BIGINT Object ID of the index

INDEX_TYPE VARCHAR(32) Type of RS-index: 'BTREE', 'BTREE_UNIQUE', 'CPBTREE', 'CPBTREE_UNIQUE'; Type of CS-index: 'INVERTED VALUE', 'INVERTED VALUE UNIQUE'

CONSTRAINT VARCHAR(32) Constraint type of the index: 'UNIQUE', 'NOT_NULL_UNIQUE', 'PRIMARY_KEY'

KEY_LENGTH SMALLINT Length of the key

BTREE_FILL_FACTOR SMALLINT B-tree fill factor (50~100)

BTREE_SPLIT_TYPE TINYINT B-tree split type: 'SPLIT_PERCENT', 'SPLIT_INVOKER'

BTREE_SPLIT_POSITION TINYINT B-tree split position (0~100)

2.30 INDEX_COLUMNS

Columns of indexes

Structure

Column name Data type Description

SCHEMA_NAME NVARCHAR(256) Schema name

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 471

Page 472: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Description

TABLE_NAME NVARCHAR(256) Table name

TABLE_OID BIGINT Object ID of the table

INDEX_NAME NVARCHAR(256) Index name

INDEX_OID BIGINT Object ID of the index

CONSTRAINT VARCHAR(32) Constraint type of the index: UNIQUE, NOT_NULL_UNIQUE, PRIMARY_KEY; Geocode type of the column: GEOCODE COUNTRY, GEOCODE STATE, GEOCODE COUNTY, GEOCODE CITY, GEOCODE POSTAL_CODE, GEOCODE DISTRICT, GEOCODE STREET, GEOCODE HOUSE_NUMBER, GEOCODE ADDRESS_LINE, GEOCODE

COLUMN_NAME NVARCHAR(256) Name of the indexed column

POSITION SMALLINT Ordinal position of the indexed column

ASCENDING_ORDER VARCHAR(5) Specifies whether the indexed column is ascending order or not: 'TRUE', 'FALSE'

2.31 INVALID_CONNECT_ATTEMPTS

Number of invalid connect attempts for a user between two successful connects

Structure

Column name Data type Description

USER_NAME NVARCHAR(256) Name of the user

SUCCESSFUL_CONNECT_TIME TIMESTAMP Time of the valid connect attempt

472P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 473: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Description

INVALID_CONNECT_ATTEMPTS BIGINT Number of invalid connect attempts for this user between last successful connect and given time

2.32 M_ATTACHED_STORAGES

Information about currently attached devices

Structure

Column name Data type Description

HOST VARCHAR(64) Host

STORAGE_ID INTEGER Storage ID

PATH VARCHAR(512) Path

KEY VARCHAR(256) Key (from storage provider)

VALUE VARCHAR(2000) Value (from storage provider)

2.33 M_BACKUP_CATALOG

Common data for all backup catalog entries

Structure

Column name Data type Unit Description

ENTRY_ID BIGINT Counter Unique ID of a backup catalog entry

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 473

Page 474: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

ENTRY_TYPE_NAME VARCHAR(64) Classification of backup catalog entries. The following types are supported: 'complete data backup', 'log backup', 'log missing'

BACKUP_ID BIGINT Counter Unique ID of a data backup or a log backup respectively. All backup files of a single data backup share the same BACKUP_ID

SYS_START_TIME TIMESTAMP Start time given in server local time

UTC_START_TIME TIMESTAMP Start time given in UTC

SYS_END_TIME TIMESTAMP Stop time given in server local time

UTC_END_TIME TIMESTAMP Stop time given in UTC

STATE_NAME VARCHAR(64) Result of corresponding action: 'successful', 'failed', 'running', 'cancel pending', 'canceled'

COMMENT VARCHAR(256) Additional information

MESSAGE VARCHAR(512) Additional information

2.34 M_BACKUP_CATALOG_FILES

Location information of all backup catalog entries

474P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 475: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Structure

Column name Data type Description

ENTRY_ID BIGINT Unique ID of a backup catalog entry

BACKUP_ID BIGINT Unique ID of a data backup and log backup respectively. All backup files of a single data backup share the same BACKUP_ID

SOURCE_ID BIGINT Persistence volume ID

SOURCE_TYPE_NAME VARCHAR(64) Type of persistence to be backed up: 'volume', 'topology'

HOST VARCHAR(64) Host name

SERVICE_TYPE_NAME VARCHAR(64) Type of database service: 'indexserver', 'nameserver', 'statisticsserver'

REDO_LOG_POSITION BIGINT In case of a data backup this value specifies the log position that must be processed next when a log recovery is requested after restoring the data backup

FIRST_REDO_LOG_POSITION BIGINT In case of a log backup this value specifies the log position of the oldest log entry contained in the backup

LAST_REDO_LOG_POSITION BIGINT In case of a log backup this value specifies the log position of the newest log entry contained in the backup

BACKUP_SIZE BIGINT Specifies the size of the backup

DESTINATION_PATH VARCHAR(512) Data or log backup was written to this location

DESTINATION_TYPE_NAME VARCHAR(16) Type of location: 'file', 'backint'

EXTERNAL_BACKUP_ID VARCHAR(64) Identifier of backup received from a backup tool

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 475

Page 476: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

2.35 M_BACKUP_CONFIGURATION

Backup configuration statistics

Structure

Column name Data type Unit Description

MAX_RECOVERY_FILE_AGE

BIGINT Second Max recovery file age

LOG_REPLAY_STEP_SIZE BIGINT Byte Log replay step size in bytes

MAX_RECOVERY_BACKINT_CHANNELS

BIGINT Max number of parallel backint channels per request during recovery

BACKINT_EXECUTABLE_LINK

VARCHAR(256) Linkname of the backint executable

BACKINT_EXECUTABLE VARCHAR(256) Real filename of the backint executable

BACKINT_DATA_BACKUP_PATH

VARCHAR(256) Data backup directory for backint

BACKINT_LOG_BACKUP_PATH

VARCHAR(256) Log backup directory for backint

2.36 M_BLOCKED_TRANSACTIONS

Transaction list waiting for locks

Structure

Column name Data type Description

HOST VARCHAR(64) Host name

476P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 477: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Description

PORT INTEGER Internal port

BLOCKED_TRANSACTION_ID INTEGER Transaction object ID of the transaction waiting for a lock

BLOCKED_UPDATE_TRANSACTION_ID

BIGINT Write transaction ID of the blocked write transaction

LOCK_OWNER_TRANSACTION_ID INTEGER Transaction object ID of the transaction holding the lock

LOCK_OWNER_UPDATE_TRANSACTION_ID

BIGINT Write transaction ID of the write transaction holding the lock

BLOCKED_TIME TIMESTAMP Blocked timestamp

WAITING_RECORD_ID VARCHAR(256) ID of the record on which the lock is currently placed

WAITING_SCHEMA_NAME NVARCHAR(256) Name of the schema on which the lock is currently placed

WAITING_TABLE_NAME NVARCHAR(256) Deprecated: use WAITING_OBJECT_NAME instead

WAITING_OBJECT_NAME NVARCHAR(256) Name of the object on which the lock is currently placed

WAITING_OBJECT_TYPE VARCHAR(32) Object type

LOCK_TYPE VARCHAR(32) Lock type: 'RECORD', 'TABLE', 'METADATA'

LOCK_MODE VARCHAR(32) Lock mode: 'SHARED', 'EXCLUSIVE', 'INTENTIONAL EXCLUSIVE'

2.37 M_CACHES

Shows aggregated information on cachesThis view has a resettable counterpart. This means, you can also see the values since the last reset in the dependent view M_CACHES_RESET. To reset the values, use the SQL command: ALTER SYSTEM RESET MONITORING VIEW SYS.M_CACHES_RESET or the management console command: monitor reset -n M_CACHES_RESET

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 477

Page 478: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Structure

Column name Data type Unit Description

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

VOLUME_ID INTEGER Persistence Volume ID

CACHE_ID VARCHAR(128) The unique identifier for the cache

TOTAL_SIZE BIGINT Byte The maximum available memory budget in bytes available for the cache instance

USED_SIZE BIGINT Byte The memory in bytes used by the cache instance

ENTRY_COUNT BIGINT Counter The number of entries in the cache instance

INSERT_COUNT BIGINT Counter The number of insertions into the cache instance

INVALIDATE_COUNT BIGINT Counter The number of invalidations in the cache instance

HIT_COUNT BIGINT Counter The number of cache hits for the cache instance

MISS_COUNT BIGINT Counter The number of cache misses for the cache instance

2.38 M_CACHES_RESET

Shows aggregated information on caches (since last reset)This view contains values accumulated since the last reset of the main view M_CACHES. Please refer to M_CACHES for information about the structure and use of this view.In addition to the members mentioned in M_CACHES, this view also contains a timestamp field RESET_TIME, which indicates the last time the data was reset.

478P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 479: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

2.39 M_CACHE_ENTRIES

Cache entry information

Structure

Column name Data type Description

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

VOLUME_ID INTEGER Persistence Volume ID

CACHE_ID VARCHAR(128) ID of the cache that created the entry

ENTRY_ID VARCHAR(128) ID of the cached entry

ENTRY_DESCRIPTION NVARCHAR(5000) Description of the cached entry

COMPONENT VARCHAR(128) Information about the component that created the cached entry

USER_NAME NVARCHAR(256) Information about the user that created the cached entry

MEMORY_SIZE BIGINT Used memory to store the cached entry in the cache

CREATE_TIME TIMESTAMP Point in time when the cache entry was inserted into the cache

READ_COUNT BIGINT Determines how often the cache entry was read successfully from the cache

2.40 M_CATALOG_MEMORY

Memory usage information by catalog manager

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 479

Page 480: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Structure

Column name Data type Unit Description

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

CATEGORY VARCHAR(128) Category of catalog data

ALLOCATION_COUNT BIGINT The number of allocated entries

ALLOCATED_FIXED_PART_SIZE

BIGINT Byte Allocated memory size for fixed-size part

USED_FIXED_PART_SIZE BIGINT Byte Used memory size for fixed-size part

ALLOCATED_VARIABLE_PART_SIZE

BIGINT Byte Allocated memory size for variable-size part

USED_VARIABLE_PART_SIZE

BIGINT Byte Used memory size for variable-size part

2.41 M_CE_CALCSCENARIOS

All available CalculationScenarios

Structure

Column name Data type Unit Description

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

SCENARIO_NAME NVARCHAR(256) Scenario name

IS_PERSISTENT VARCHAR(5) Boolean Indicates if calculation scenario is persistent or transient: 'TRUE', 'FALSE'

480P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 481: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

FLAGS BIGINT Calculation scenario flags

CREATE_TIME TIMESTAMP Creation time

MEMORY_SIZE BIGINT Byte Memory size of loaded calculation scenario model

COMPONENT NVARCHAR(256) Component that create the calculation scenario

SCENARIO_VERSION NVARCHAR(256) Scenario version of the calculation scenario

JSON NCLOB JSON string representing the calculation scenario

2.42 M_CE_CALCVIEW_DEPENDENCIES

All views that are referencing a CalculationScenario

Structure

Column name Data type Description

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

SCHEMA_NAME NVARCHAR(256) Schema name of column view

VIEW_NAME NVARCHAR(256) Column view name

CALCNODE_NAME NVARCHAR(256) Referenced calculation node name

SCENARIO_NAME NVARCHAR(256) Scenario name

2.43 M_CE_DEBUG_INFOS

Debug information after execution of a CalculationScenario

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 481

Page 482: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Structure

Column name Data type Unit Description

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

SCENARIO_NAME NVARCHAR(256) Scenario name

NODE_NAME NVARCHAR(256) Calculation node name

STATEMENT_ID BIGINT Statement ID

DEBUG_TYPE_MASK BIGINT Bit mask indicating type of debug information

TABLE_NAME NVARCHAR(256) Table name (temporay intermediate result table)

COLUMN_NAMES CLOB Column names

TABLE_SIZE BIGINT Byte Table size (temporay intermediate result table)

EXECUTION_TIMESTAMP TIMESTAMP Execution timestamp

APPLICATION_QUERY_ID NVARCHAR(256) Application Query ID

2.44 M_CE_DEBUG_JSONS

All available JSONS (original, instantiated, optimized) of a scenario for a concrete query

Structure

Column name Data type Description

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

SCENARIO_NAME NVARCHAR(256) Scenario name

482P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 483: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Description

STATEMENT_ID BIGINT Statement ID

TYPE VARCHAR(16) JSON type (original, instantiated, optimized, extrace)

MODEL_JSON NCLOB JSON string representing the calculation scenario

EXECUTION_TIMESTAMP TIMESTAMP Execution timestamp

2.45 M_CE_DEBUG_NODE_MAPPING

Node mapping between CalculationNodes and RuntimeNodes after execution

Structure

Column name Data type Description

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

STATEMENT_ID BIGINT Statement ID

SCENARIO_NAME NVARCHAR(256) Scenario name

NODE_NAME NVARCHAR(256) Calculation node name

NODE_TYPE VARCHAR(16) Calculation node type (ROOT, TEMPLATE, CALC_DS)

SUCC_SCENARIO_NAME NVARCHAR(256) Successor scenario name

SUCC_NODE_NAME NVARCHAR(256) Successor calculation node name

RUNTIME_NODE_NAME NVARCHAR(256) Runtime calculation node name

RUNTIME_NODE_JSON NCLOB JSON string representing the calculation node

EXECUTION_TIMESTAMP TIMESTAMP Execution timestamp

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 483

Page 484: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

2.46 M_CE_PLE_CALCSCENARIOS

All available CalculationScenarios created by the PlanningEngine

Structure

Column name Data type Description

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

SCHEMA_NAME NVARCHAR(256) Schema name of calculation scenario

SCENARIO_NAME NVARCHAR(256) Calculation scenario name

2.47 M_CLIENT_VERSIONS

Versions of all supported client applications

Full description

This view shows versions of all supported client applications.

Structure

Column name Data type Description

CLIENT_TYPE VARCHAR(256) Client, e.g. 'ABAP_FDA', 'BI Modeler'

CLIENT_RELEASE_ID SMALLINT Technical release ID

CLIENT_RELEASE_DESC VARCHAR(256) Human readable release description

MIN_VERSION SMALLINT Lowest supported protocol version

484P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 485: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Description

MAX_VERSION SMALLINT Highest supported protocol version

2.48 M_COMPACTION_THREAD

Compaction thread statistics

Full description

The compaction thread automatically calls compaction of memory (including resource container shrink) in case memory gets low, but is not already exhausted. It also executes the compaction requests triggered by other processes (inter-process memory management). Some information about the compaction requests and the compacted sizes is shown in this view.

Structure

Column name Data type Unit Description

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

VOLUME_ID INTEGER Persistence Volume ID

NUM_COMPACTION_COLLISIONS

BIGINT Counter Count of memory compaction collisions (other thread currently in compaction and compaction was not forced)

NUM_COMPACTIONS BIGINT Counter Count number of compaction requests

LAST_SIZE_COMPACTION_REQUESTS

BIGINT Byte Compaction request in bytes (last)

MAX_SIZE_COMPACTION_REQUESTS

BIGINT Byte Compaction request in bytes (max)

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 485

Page 486: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

MIN_SIZE_COMPACTION_REQUESTS

BIGINT Byte Compaction request in bytes (min)

SUM_SIZE_COMPACTION_REQUESTS

BIGINT Byte Compaction request in bytes (total)

AVG_SIZE_COMPACTION_REQUESTS

BIGINT Byte Compaction request in bytes (avg)

LAST_SIZE_FREEABLE BIGINT Byte Bytes compactible at compaction call (last)

MAX_SIZE_FREEABLE BIGINT Byte Bytes compactible at compaction call (max)

MIN_SIZE_FREEABLE BIGINT Byte Bytes compactible at compaction call (min)

SUM_SIZE_FREEABLE BIGINT Byte Bytes compactible at compaction call (total)

AVG_SIZE_FREEABLE BIGINT Byte Bytes compactible at compaction call (avg)

LAST_SIZE_FREED_BY_GARBAGE_COLLECTION

BIGINT Byte Bytes compacted by memory garbage collection (defragmentation) (last)

MAX_SIZE_FREED_BY_GARBAGE_COLLECTION

BIGINT Byte Bytes compacted by memory garbage collection (defragmentation) (max)

MIN_SIZE_FREED_BY_GARBAGE_COLLECTION

BIGINT Byte Bytes compacted by memory garbage collection (defragmentation) (min)

SUM_SIZE_FREED_BY_GARBAGE_COLLECTION

BIGINT Byte Bytes compacted by memory garbage collection (defragmentation) (total)

AVG_SIZE_FREED_BY_GARBAGE_COLLECTION

BIGINT Byte Bytes compacted by memory garbage collection (defragmentation) (avg)

486P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 487: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

LAST_COMPACTION_RESULT

BIGINT Byte Compaction result in bytes (difference of allocated bytes before and after compaction, difference may be influenced by other factors than compaction) (last)

MAX_COMPACTION_RESULT

BIGINT Byte Compaction result in bytes (difference of allocated bytes before and after compaction, difference may be influenced by other factors than compaction) (max)

MIN_COMPACTION_RESULT

BIGINT Byte Compaction result in bytes (difference of allocated bytes before and after compaction, difference may be influenced by other factors than compaction) (min)

SUM_COMPACTION_RESULT

BIGINT Byte Compaction result in bytes (difference of allocated bytes before and after compaction, difference may be influenced by other factors than compaction) (total)

AVG_COMPACTION_RESULT

BIGINT Byte Compaction result in bytes (difference of allocated bytes before and after compaction, difference may be influenced by other factors than compaction) (avg)

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 487

Page 488: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

2.49 M_CONDITIONAL_VARIABLES

Semaphore statisticsThis view has a resettable counterpart. This means, you can also see the values since the last reset in the dependent view M_CONDITIONAL_VARIABLES_RESET. To reset the values, use the SQL command: ALTER SYSTEM RESET MONITORING VIEW SYS.M_CONDITIONAL_VARIABLES_RESET or the management console command: monitor reset -n M_CONDITIONAL_VARIABLES_RESET

Full description

This view contains information about single conditional variable objects or groups of conditional variable objects. It does not contain information about all conditional variables.

Structure

Column name Data type Unit Description

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

VOLUME_ID INTEGER Persistence Volume ID

STATISTICS_NAME VARCHAR(128) Statistics object name

STATISTICS_ID BIGINT Statistics object unique ID

WAIT_COUNT BIGINT Counter Count of wait calls

BLOCKING_COUNT BIGINT Counter Count of blocking wait calls

TIMEOUT_COUNT BIGINT Counter Count of timeouts

WAIT_RATE DOUBLE Percent Wait rate

LAST_BLOCKING_TIME BIGINT Microsecond Time of blocking wait calls (last)

MAX_BLOCKING_TIME BIGINT Microsecond Time of blocking wait calls (max)

MIN_BLOCKING_TIME BIGINT Microsecond Time of blocking wait calls (min)

488P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 489: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

SUM_BLOCKING_TIME BIGINT Microsecond Time of blocking wait calls (total)

AVG_BLOCKING_TIME BIGINT Microsecond Time of blocking wait calls (avg)

CREATE_COUNT BIGINT Counter Count of semaphore creation (for shared statistics only)

DESTROY_COUNT BIGINT Counter Count of semaphore destruction (for shared statistics only)

2.50 M_CONDITIONAL_VARIABLES_RESET

Semaphore statistics (since last reset)This view contains values accumulated since the last reset of the main view M_CONDITIONAL_VARIABLES. Please refer to M_CONDITIONAL_VARIABLES for information about the structure and use of this view.In addition to the members mentioned in M_CONDITIONAL_VARIABLES, this view also contains a timestamp field RESET_TIME, which indicates the last time the data was reset.

2.51 M_CONNECTIONS

Detailed information on connections between a client and database. Information includes connection status, client information, connection type, resource utilization

Structure

Column name Data type Unit Description

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

CONNECTION_ID INTEGER Connection ID

TRANSACTION_ID INTEGER Transaction object ID

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 489

Page 490: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

START_TIME TIMESTAMP Connected Time

IDLE_TIME BIGINT Millisecond Time that the connection is unused and idle

CONNECTION_STATUS VARCHAR(128) Connection Status: 'RUNNING', 'IDLE'

CLIENT_HOST VARCHAR(64) Host name of client machine

CLIENT_IP VARCHAR(16) IP of client machine

CLIENT_PID BIGINT Client Process ID

USER_NAME NVARCHAR(256) User name

CONNECTION_TYPE VARCHAR(128) Connection type: Remote, Local, History (remote), History (local)

OWN VARCHAR(5) Own connection: TRUE if own connection, FALSE if not

IS_HISTORY_SAVED VARCHAR(5) Field is no longer valid - will be deprecated soon

MEMORY_SIZE_PER_CONNECTION

BIGINT Byte Allocated memory size per connection

AUTO_COMMIT VARCHAR(5) Commit mode of the current transaction: TRUE if the current connection is in auto-commit mode, FALSE otherwise

LAST_ACTION VARCHAR(128) The last action done by the current connection: ExecuteGroup, CommitTrans, AbortTrans, PrepareStatement, CloseStatement, ExecutePrepared, ExecuteStatement, FetchCursor, CloseCursor, LobGetPiece, LogPutPiece, LobFind,

490P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 491: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

Authenticate, Connect, Disconnect, ExecQidItab, CursorFetchItab, InsertIncompleteItab, AbapStream, TxStartXA, TxJoinXA

CURRENT_STATEMENT_ID

VARCHAR(256) Current statement ID

CURRENT_OPERATOR_NAME

VARCHAR(64) Current operator name

FETCHED_RECORD_COUNT

BIGINT Sum of the record count fetched by select statements

AFFECTED_RECORD_COUNT

BIGINT Sum of the record count affected by DML/DDL statements (e.g. INSERT/UPDATE/DELETE/REPLACE/CREATE TABLE .. LIKE .. WITH DATA/CREATE TABLE .. AS (SELECT ..)/IMPORT/EXPORT)

SENT_MESSAGE_SIZE BIGINT Total size of messages sent by the current connection

SENT_MESSAGE_COUNT BIGINT Total message count sent by the current connection

RECEIVED_MESSAGE_SIZE

BIGINT Total size of messages received by the current connection

RECEIVED_MESSAGE_COUNT

BIGINT Total message count received by the current connection

CREATOR_THREAD_ID BIGINT Thread ID who created the current connection

CREATED_BY VARCHAR(256) Engine component that created the connections: Session, Planning,

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 491

Page 492: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

Repository, CalcEngine, Authentication, Table Exporter, Loader, LLVM, JSVM, IMS Search API, OLAP Engine, Mergedog, Ping Status, Name Server, Queue Server, SQL Stored Procedure, Authorization, TrexViaDbsl from ABAP, HybridTable Reorganizer, Session external

IS_ENCRYPTED VARCHAR(5) Encrypted: TRUE if the secure communication is enabled (SSL enabled), FALSE, otherwise

END_TIME TIMESTAMP The time when the connection is closed for history connections

PARENT_CONNECTION_ID

INTEGER Parent connection ID

CLIENT_DISTRIBUTION_MODE

VARCHAR(128) Client distribution mode of the current connection (i.e. [distribution] client_distribution_mode)

LOGICAL_CONNECTION_ID

INTEGER Logical connection ID in statement routing

CURRENT_SCHEMA_NAME

NVARCHAR(256) Current schema name

CURRENT_THREAD_ID BIGINT Current executing thread ID

2.52 M_CONNECTION_STATISTICS

Detailed statistics on each connection between an application and database

492P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 493: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Structure

Column name Data type Unit Description

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

CONNECTION_ID INTEGER Connection ID

SELECT_EXECUTION_COUNT

BIGINT Total number of select statement executions

SELECT_TOTAL_EXECUTION_TIME

BIGINT Microsecond Total execution time of select statement execution

SELECT_AVG_EXECUTION_TIME

REAL Microsecond Average execution time of select statement execution

SELECT_MAX_EXECUTION_TIME

BIGINT Microsecond Maximum execution time of select statement execution

SELECT_FOR_UPDATE_COUNT

BIGINT Total number of select for update exeution

SELECT_FOR_UPDATE_TOTAL_EXECUTION_TIME

BIGINT Microsecond Total execution time of select for update execution

SELECT_FOR_UPDATE_AVG_EXECUTION_TIME

REAL Microsecond Average execution time of select for update execution

SELECT_FOR_UPDATE_MAX_EXECUTION_TIME

BIGINT Microsecond Maximum execution time of select for update execution

SELECT_FOR_UPDATE_LOCK_WAIT_COUNT

BIGINT Number of lock waits during select for update

SELECT_FOR_UPDATE_TOTAL_LOCK_WAIT_TIME

BIGINT Microsecond Total lock wait time during select for update

SELECT_FOR_UPDATE_AVG_LOCK_WAIT_TIME

REAL Microsecond Average lock wait time during select for update

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 493

Page 494: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

SELECT_FOR_UPDATE_MAX_LOCK_WAIT_TIME

BIGINT Microsecond Maximum lock wait time uring select for update

UPDATE_COUNT BIGINT Total number of update statement and insert statement executions

UPDATE_TOTAL_EXECUTION_TIME

BIGINT Microsecond Total execution time of update statement executions

UPDATE_AVG_EXECUTION_TIME

REAL Microsecond Average execution time of update statement executions

UPDATE_MAX_EXECUTION_TIME

BIGINT Microsecond Maximum execution time of update statement executions

UPDATE_LOCK_WAIT_COUNT

BIGINT Number of lock waits during update statement executions

UPDATE_TOTAL_LOCK_WAIT_TIME

BIGINT Microsecond Total lock wait execution time during update statement executions

UPDATE_AVG_LOCK_WAIT_TIME

REAL Microsecond Average lock wait time during update statement exectuions

UPDATE_MAX_LOCK_WAIT_TIME

BIGINT Microsecond Maximum lock wait time during update statement executions

READ_ONLY_TRANSACTION_COUNT

BIGINT Number of read only transactions

READ_ONLY_TRANSACTION_TOTAL_EXECUTION_TIME

BIGINT Microsecond Total execution time of read only transactions

READ_ONLY_TRANSACTION_AVG_EXECUTION_TIME

REAL Microsecond Average execution time of read only transactions

READ_ONLY_TRANSACTION_MAX_EXECUTION_TIME

BIGINT Microsecond Maximum execution time of read only transactions

494P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 495: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

UPDATE_TRANSACTION_COUNT

BIGINT Number of update transactions

UPDATE_TRANSACTION_TOTAL_EXECUTION_TIME

BIGINT Microsecond Total execution time of update transactions

UPDATE_TRANSACTION_AVG_EXECUTION_TIME

REAL Microsecond Average execution time of update transactions

UPDATE_TRANSACTION_MAX_EXECUTION_TIME

BIGINT Microsecond Maximum execution time of update transactions

ROLLBACK_COUNT BIGINT Number of rollbacked transactions

ROLLBACK_TOTAL_EXECUTION_TIME

BIGINT Microsecond Total execution time of rollbacks

ROLLBACK_AVG_EXECUTION_TIME

REAL Microsecond Average execution time of rollbacks

ROLLBACK_MAX_EXECUTION_TIME

BIGINT Microsecond Maximum execution time of rollbacks

OTHERS_COUNT BIGINT Number of other statement executions including data definition statements and data control statements

OTHERS_TOTAL_EXECUTION_TIME

BIGINT Microsecond Total execution time of other statements

OTHERS_AVG_EXECUTION_TIME

REAL Microsecond Average execution time of other statements

OTHERS_MAX_EXECUTION_TIME

BIGINT Microsecond Maximum execution time of other statements

OTHERS_LOCK_WAIT_COUNT

BIGINT Total lock wait count of other statements

OTHERS_TOTAL_LOCK_WAIT_TIME

BIGINT Microsecond Total lock wait time of other statements

OTHERS_AVG_LOCK_WAIT_TIME

REAL Microsecond Average lock wait time of other statements

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 495

Page 496: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

OTHERS_MAX_LOCK_WAIT_TIME

BIGINT Microsecond Maximum lock wait time of other statements

LAST_EXECUTED_TIME TIMESTAMP Last execution timestamp with this connection

AVG_EXECUTION_MEMORY_SIZE

BIGINT Average memory size used during each execution

MAX_EXECUTION_MEMORY_SIZE

BIGINT Maximum memory size used during each execution

MIN_EXECUTION_MEMORY_SIZE

BIGINT Minimum memory size used during each execution

TOTAL_EXECUTION_MEMORY_SIZE

BIGINT Sum of memory size used during each execution

AVG_PREPARATION_TIME

BIGINT Average time of statement preparation

MAX_PREPARATION_TIME

BIGINT Maximum time of statement preparation

MIN_PREPARATION_TIME BIGINT Minimim time of statement preparation

TOTAL_PREPARATION_TIME

BIGINT Total time of statement preparation

TOTAL_PREPARATION_COUNT

BIGINT Total count of statement preparation

EXECUTION_COUNT_BY_ROUTING

BIGINT Execution count by the client routed connection in statement routing

END_TIME TIMESTAMP The time when the connection is closed for history connections

496P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 497: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

2.53 M_CONTAINER_DIRECTORY

ContainerDirectory statistics

Structure

Column name Data type Unit Description

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

VOLUME_ID INTEGER Persistence Volume ID

CNT_CREATE BIGINT Counter Count of creates

CNT_CREATE_ROLLBACK BIGINT Counter Count of rolled back creates

CNT_REMOVE BIGINT Counter Count of removes

CNT_REMOVE_FAIL BIGINT Counter Count of failed removes

CNT_REMOVE_ROLLBACK

BIGINT Counter Count of rolled back removes

CNT_MOVE BIGINT Counter Count of moves

CNT_GET_PHYSICALSIZE BIGINT Counter Count of getPhysicalSize

CNT_GET BIGINT Counter Count of retrieved containers

CNT_GET_FAIL BIGINT Counter Count of failed gets

CNT_BEGIN BIGINT Counter Count of used iterators

CNT_ITERATED BIGINT Counter Count of iterated containers

CNT_CACHEHIT BIGINT Counter Count of cache hits

CNT_CACHEMISS BIGINT Counter Count of cache misses

CNT_CONTAINERS BIGINT Counter Count of existing containers

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 497

Page 498: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

2.54 M_CONTAINER_NAME_DIRECTORY

ContainerNameDirectory statistics

Structure

Column name Data type Unit Description

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

VOLUME_ID INTEGER Persistence Volume ID

CNT_CREATE BIGINT Counter Count of creates

CNT_CREATE_FAIL BIGINT Counter Count of failed creates

CNT_INITIAL_CREATE BIGINT Counter Count of creates on load

CNT_INITIAL_SKIP BIGINT Counter Count of skips on load

CNT_REMOVE BIGINT Counter Count of removes

CNT_REMOVE_FAIL BIGINT Counter Count of failed removes

CNT_REMOVE_ALL BIGINT Counter Count of removeAll

CNT_RENAME BIGINT Counter Count of renames

CNT_RENAME_FAIL BIGINT Counter Count of failed renames

CNT_EXISTS BIGINT Counter Count of checked containers

CNT_GET BIGINT Counter Count of retrieved containers

CNT_GET_FAIL BIGINT Counter Count of failed gets

CNT_BEGIN BIGINT Counter Count of used iterators

CNT_ITERATE BIGINT Counter Count of iterated containers

CNT_CONTAINERS BIGINT Counter Count of existing containers

498P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 499: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

2.55 M_CONTEXT_MEMORY

Memory allocator statisticsThis view has a resettable counterpart. This means, you can also see the values since the last reset in the dependent view M_CONTEXT_MEMORY_RESET. To reset the values, use the SQL command: ALTER SYSTEM RESET MONITORING VIEW SYS.M_CONTEXT_MEMORY_RESET or the management console command: monitor reset -n M_CONTEXT_MEMORY_RESET

Full description

This view contains information about memory consumption grouped by connections and/or users. It does not contain information about all memory, only on memory, which can be uniquely associated with either a connection, a statement or a user.

To see information about allocated memory by component, use M_HEAP_MEMORY.

M_HEAP_MEMORY

Structure

Column name Data type Unit Description

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

VOLUME_ID INTEGER Persistence Volume ID

STATISTICS_ID BIGINT Statistics object unique ID

CATEGORY VARCHAR(128) Allocator name

DEPTH BIGINT Depth

INCLUSIVE_SIZE_IN_USE BIGINT Byte Current size of this allocator, including suballocators

INCLUSIVE_COUNT_IN_USE

BIGINT Counter Number of blocks currently in use, including suballocators

INCLUSIVE_ALLOCATED_SIZE

BIGINT Byte Total allocated size in this allocator and suballocators

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 499

Page 500: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

INCLUSIVE_DEALLOCATED_SIZE

BIGINT Byte Total deallocated size in this allocator and suballocators

INCLUSIVE_ALLOCATED_COUNT

BIGINT Counter Count of allocations, including suballocators

INCLUSIVE_DEALLOCATED_COUNT

BIGINT Counter Count of deallocations, including suballocators

INCLUSIVE_MAX_SINGLE_ALLOCATION_SIZE

BIGINT Byte Maximum ever allocated block size in this allocator and suballocators

INCLUSIVE_PEAK_ALLOCATION_SIZE

BIGINT Byte Maximum size of this allocator and suballocators (estimate)

INCLUSIVE_IN_USE_INTEGRAL

BIGINT Average allocated memory by this allocator and its suballocators, multiplied by time since start of measurement (sample based rough estimate), this is usually deactivated, only activate in case this is requested by SAP support. Unit is 1 byte times 1 second (may change in future).

EXCLUSIVE_SIZE_IN_USE BIGINT Byte Current size of this allocator

EXCLUSIVE_COUNT_IN_USE

BIGINT Counter Number of blocks currently in use

EXCLUSIVE_ALLOCATED_SIZE

BIGINT Byte Total allocated size in this allocator

EXCLUSIVE_DEALLOCATED_SIZE

BIGINT Byte Total deallocated size in this allocator

EXCLUSIVE_ALLOCATED_COUNT

BIGINT Counter Count of allocations

EXCLUSIVE_DEALLOCATED_COUNT

BIGINT Counter Count of deallocations

500P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 501: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

EXCLUSIVE_MAX_SINGLE_ALLOCATION_SIZE

BIGINT Byte Maximum ever allocated block size in this allocator

EXCLUSIVE_PEAK_ALLOCATION_SIZE

BIGINT Byte Maximum size of this allocator (estimate)

EXCLUSIVE_ALLOC_ERRORS

BIGINT Counter Count of allocation errors

EXCLUSIVE_IN_USE_INTEGRAL

BIGINT Average allocated memory by this allocator, multiplied by time since start of measurement (sample based rough estimate), this is usually deactivated, only activate in case this is requested by SAP support. Unit is 1 byte times 1 second (may change in future).

MALLOC_PROXY_CACHE_MISSES

BIGINT Counter Count of malloc proxy cache misses

FLAGS VARCHAR(64) Allocator flags

2.56 M_CONTEXT_MEMORY_RESET

Memory allocator statistics (since last reset)This view contains values accumulated since the last reset of the main view M_CONTEXT_MEMORY. Please refer to M_CONTEXT_MEMORY for information about the structure and use of this view.In addition to the members mentioned in M_CONTEXT_MEMORY, this view also contains a timestamp field RESET_TIME, which indicates the last time the data was reset.

2.57 M_CONVERTER_STATISTICS

Converter statisticsThis view has a resettable counterpart. This means, you can also see the values since the last reset in the dependent view M_CONVERTER_STATISTICS_RESET. To reset the values, use the SQL command: ALTER SYSTEM RESET MONITORING VIEW SYS.M_CONVERTER_STATISTICS_RESET or the management console command: monitor reset -n M_CONVERTER_STATISTICS_RESET

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 501

Page 502: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Full description

This view contains information about the converter, which administers logical page numbers and maps them to physical pages within the DataVolume(s).

M_PAGEACCESS_STATISTICS, M_DATA_VOLUME_PAGE_STATISTICS

Structure

Column name Data type Unit Description

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

VOLUME_ID INTEGER Persistence Volume ID

TYPE VARCHAR(32) Type of converter

MAX_LEVEL BIGINT Counter Maximum level, e.g. level of root page

MAX_PAGENUMBER BIGINT HEXID Maximum page number

ALLOCATED_PAGE_COUNT

BIGINT Counter Number of currently allocated pages

ALLOCATED_PAGE_SIZE BIGINT Byte Total size [bytes] of currently allocated pages

MAX_ALLOCATED_PAGE_COUNT

BIGINT Counter Maximum number of allocated pages

MAX_ALLOCATED_PAGE_SIZE

BIGINT Byte Maximum size [bytes] of allocated pages

ALLOCATE_PAGE_COUNT

BIGINT Counter Number of page allocations

ALLOCATE_OR_GET_STATIC_PAGE_COUNT

BIGINT Counter Number of page allocations or retrievals during static phase

DEALLOCATE_PAGE_COUNT

BIGINT Counter Number of page deallocations

ASSIGN_PHYSICAL_PAGE_COUNT

BIGINT Counter Number of physical page assignments

502P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 503: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

UNASSIGN_PHYSICAL_PAGE_COUNT

BIGINT Counter Number of physical page unassignments

UNASSIGN_PHYSICAL_PAGE_COUNT_DURING_DROP_SNAPSHOT

BIGINT Counter Number of physical page unassignments during drop snapshot

CREATE_SNAPSHOT_COUNT

BIGINT Counter Number of snapshots created

DROP_SNAPSHOT_COUNT

BIGINT Counter Number of snapshots dropped

WRITE_CONVERTERPAGE_LEVEL0_COUNT

BIGINT Counter Number of level 0 converter pages written to disk

WRITE_CONVERTERPAGE_LEVEL1_COUNT

BIGINT Counter Number of level 1 converter pages written to disk

WRITE_CONVERTERPAGE_LEVEL2_COUNT

BIGINT Counter Number of level 2 converter pages written to disk

WRITE_CONVERTERPAGE_LEVEL3_COUNT

BIGINT Counter Number of level 3 converter pages written to disk

WRITE_CONVERTERPAGE_LEVEL4_COUNT

BIGINT Counter Number of level 4 converter pages written to disk

2.58 M_CONVERTER_STATISTICS_RESET

Converter statistics (since last reset)This view contains values accumulated since the last reset of the main view M_CONVERTER_STATISTICS. Please refer to M_CONVERTER_STATISTICS for information about the structure and use of this view.In addition to the members mentioned in M_CONVERTER_STATISTICS, this view also contains a timestamp field RESET_TIME, which indicates the last time the data was reset.

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 503

Page 504: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

2.59 M_CS_ALL_COLUMNS

Runtime information from all columns of column tables, including internal ones

Structure

Column name Data type Description

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

SCHEMA_NAME NVARCHAR(256) Schema name

TABLE_NAME NVARCHAR(256) Table name

COLUMN_NAME NVARCHAR(256) Column name

PART_ID INTEGER Partition ID. 0 for non-partitioned tables, 1 through number of partitions for partitioned tables, and -1 during table schema change temporarily

MEMORY_SIZE_IN_TOTAL BIGINT Sum of MEMORY_SIZE_IN_MAIN and MEMORY_SIZE_IN_DELTA columns

MEMORY_SIZE_IN_MAIN BIGINT Current memory consumption in main; 0 if not loaded

MEMORY_SIZE_IN_DELTA BIGINT Current memory consumption in delta; 0 if not loaded

UNCOMPRESSED_SIZE BIGINT Estimated size assuming that column is not compressed

COMPRESSION_RATIO_IN_PERCENTAGE

DOUBLE MEMORY_SIZE_IN_TOTAL / UNCOMPRESSED_SIZE * 100

COUNT BIGINT Record count; 0 if not loaded

DISTINCT_COUNT BIGINT Distinct count of values; 0 if not loaded

504P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 505: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Description

COMPRESSION_TYPE VARCHAR(16) Type of column compression: can be SPARSE, PREFIXED, CLUSTERED, INDIRECT, RLE or DEFAULT if column is only dictionary coded. Columns in M_CS_COLUMNS show the runtime value, which can be changed during the runtime

INDEX_TYPE VARCHAR(16) Type of inverted index; can be FULL or NONE for no index

INDEX_LOADED VARCHAR(16) Load status of inverted index; can be NOT APPLICABLE, UNLOADED or LOADED

IMPLEMENTATION_FLAGS BIGINT Column internal implementation spec summary

LAST_ACCESS_TIME TIMESTAMP Last time the column was read or there was an insert to, update of or delete from the column; Undefined for unloaded columns

LOADED VARCHAR(5) Flag to indicate that column is loaded into memory: 'TRUE', 'FALSE'

TABLE_OID BIGINT Object ID of table

MAIN_MEMORY_SIZE_IN_DATA BIGINT Current memory consumption in data

MAIN_MEMORY_SIZE_IN_DICT BIGINT Current memory consumption in dict

MAIN_MEMORY_SIZE_IN_INDEX BIGINT Current memory consumption in index

MAIN_MEMORY_SIZE_IN_MISC BIGINT Current memory consumption in misc

DELTA_MEMORY_SIZE_IN_DATA BIGINT Current memory consumption in data

DELTA_MEMORY_SIZE_IN_DICT BIGINT Current memory consumption in dict

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 505

Page 506: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Description

DELTA_MEMORY_SIZE_IN_INDEX BIGINT Current memory consumption in index

DELTA_MEMORY_SIZE_IN_MISC BIGINT Current memory consumption in misc

INDEX_CREATE_DURATION BIGINT Time needed for creating inverted index

DELTA_IMPLEMENTATION_FLAGS BIGINT Column internal implementation spec summary

INTERNAL_ATTRIBUTE_TYPE VARCHAR(32) Attribute type for internal columns; NULL for noninternal columns

LAST_LOAD_TIME TIMESTAMP Last time the column was loaded; Undefined for unloaded columns

2.60 M_CS_COLUMNS

Runtime information of columns of column tables

Structure

Column name Data type Unit Description

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

SCHEMA_NAME NVARCHAR(256) Schema name

TABLE_NAME NVARCHAR(256) Table name

COLUMN_NAME NVARCHAR(256) Column name

PART_ID INTEGER Partition ID. 0 for non-partitioned tables, 1 through number of partitions for partitioned tables, and -1 during table

506P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 507: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

schema change temporarily

MEMORY_SIZE_IN_TOTAL

BIGINT Byte Sum of MEMORY_SIZE_IN_MAIN and MEMORY_SIZE_IN_DELTA columns

MEMORY_SIZE_IN_MAIN BIGINT Byte Current memory consumption in main; 0 if not loaded

MEMORY_SIZE_IN_DELTA BIGINT Byte Current memory consumption in delta; 0 if not loaded

UNCOMPRESSED_SIZE BIGINT Byte Estimated size assuming that column is not compressed

COMPRESSION_RATIO_IN_PERCENTAGE

DOUBLE Percent MEMORY_SIZE_IN_TOTAL / UNCOMPRESSED_SIZE * 100

COUNT BIGINT Record count; 0 if not loaded

DISTINCT_COUNT BIGINT Distinct count of values; 0 if not loaded

COMPRESSION_TYPE VARCHAR(16) Type of column compression: can be SPARSE, PREFIXED, CLUSTERED, INDIRECT, RLE or DEFAULT if column is only dictionary coded. Columns in M_CS_COLUMNS show the runtime value, which can be changed during the runtime

INDEX_TYPE VARCHAR(16) Type of inverted index; can be FULL or NONE for no index

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 507

Page 508: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

INDEX_LOADED VARCHAR(16) Load status of inverted index; can be NOT APPLICABLE, UNLOADED or LOADED

IMPLEMENTATION_FLAGS

BIGINT Column internal implementation spec summary

LAST_ACCESS_TIME TIMESTAMP Last time the column was read or there was an insert to, update of or delete from the column; Undefined for unloaded columns

LOADED VARCHAR(5) Boolean Flag to indicate that column is loaded into memory: 'TRUE', 'FALSE'

LAST_LOAD_TIME TIMESTAMP Last time the column was loaded; Undefined for unloaded columns

2.61 M_CS_PARTITIONS

Partition information of column tables

Structure

Column name Data type Description

SCHEMA_NAME NVARCHAR(256) Schema Name

TABLE_NAME NVARCHAR(256) Table Name

PART_ID INTEGER Partition ID. 0 for non-partitioned tables, 1 through number of partitions for partitioned tables. -1 if the whole table is unloaded.

508P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 509: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Description

PARTITION INTEGER Partition ID. 0 for non-partitioned tables and 1 through number of partitions for partitioned tables

SUBPARTITION INTEGER Subpartition ID. 0 for non-partitioned tables or tables without multi-level partitioning and 1 through number of subpartitions for partitioned table with multi-level partitioniong

RANGE VARCHAR(64) Range definition of partition/subpartition for range-partitioned tables, empty otherwise

2.62 M_CS_TABLES

Runtime data of column tables

Structure

Column name Data type Unit Description

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

SCHEMA_NAME NVARCHAR(256) Schema name

TABLE_NAME NVARCHAR(256) Table name

PART_ID INTEGER Partition ID. 0 for non-partitioned and non-replicated tables, 1 through number of partitions for partitioned tables, 1 through number of the original table and all its replica for replicated tables, and -1 temporarily

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 509

Page 510: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

during table schema change

MEMORY_SIZE_IN_TOTAL

BIGINT Byte Total memory size is the sum of memory size in main, delta, and history parts

MEMORY_SIZE_IN_MAIN BIGINT Byte Current memory consumption in main; this value varies depending on the number of attributes actually loaded

MEMORY_SIZE_IN_DELTA BIGINT Byte Current memory consumption in delta

MEMORY_SIZE_IN_HISTORY_MAIN

BIGINT Byte Current memory consumption in history-main; 0 for normal non-history tables

MEMORY_SIZE_IN_HISTORY_DELTA

BIGINT Byte Current memory consumption in history-delta; 0 for normal non-history tables

ESTIMATED_MAX_MEMORY_SIZE_IN_TOTAL

BIGINT Byte Estimated maximum memory consumption in total for table fully loaded

RECORD_COUNT BIGINT Byte Record count

RAW_RECORD_COUNT_IN_MAIN

BIGINT Current number of entries in table main part, this value differs from number of visible table main rows because there are entries of modified rows marked as invalidated

RAW_RECORD_COUNT_IN_DELTA

BIGINT Current number of entries in table delta part, this value differs from number of visible table delta rows because there are additional entries such as deleted rows or updated

510P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 511: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

rows; can contain deleted records

RAW_RECORD_COUNT_IN_HISTORY_MAIN

BIGINT Raw record count in history-main

RAW_RECORD_COUNT_IN_HISTORY_DELTA

BIGINT Raw record count in history-delta

LAST_COMPRESSED_RECORD_COUNT

BIGINT The number of entries in main during last optimize compression run

MAX_UDIV BIGINT Maximum table row number, this number is pure technical and only internally used

MAX_MERGE_CID BIGINT Maximum commit-ID of transactions for which changes were already merged to table main part

MAX_ROWID BIGINT Maximum rowid, this number is pure technical and only internally used

IS_DELTA2_ACTIVE VARCHAR(5) Boolean Flag to indicate that a second delta is used: 'TRUE', 'FALSE'. During a table delta merge updates and inserts are stored to a second delta because the delta one is locked

IS_DELTA_LOADED VARCHAR(5) Boolean Flag to indicate that delta part of table is loaded: 'TRUE', 'FALSE'

IS_LOG_DELTA VARCHAR(5) Boolean Flag to indicate that currently delta log is written: 'TRUE', 'FALSE'

PERSISTENT_MERGE VARCHAR(5) Boolean Flag to indicate that new main part will be written to disk during table delta merge unless requested

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 511

Page 512: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

differently: 'TRUE', 'FALSE'

CREATE_TIME TIMESTAMP Created time

MODIFY_TIME TIMESTAMP Modified time

LAST_MERGE_TIME TIMESTAMP Point in time, Unix time format, last time the table delta part was merged into main part

LAST_REPLAY_LOG_TIME TIMESTAMP Point in time, Unix time format, last time the table log was replayed

LOADED VARCHAR(10) Flag to show how many columns of table are loaded in memory (NO, PARTIALLY, and FULL); see M_CS_COLUMNS for each column

READ_COUNT BIGINT Number of read accesses on the table or partition. Note: This is not the number of SELECT statements against this table. A SELECT may involve several read accesses.

WRITE_COUNT BIGINT Number of write accesses on the table or partition. Note: This is not the number of DML & DDL statements against this table. A DML or DDL statement may involve several write accesses.

MERGE_COUNT BIGINT Number of delta merges done on the table or partition

IS_REPLICA VARCHAR(5) Boolean Flag to indicate that the part is a replica

512P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 513: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

2.63 M_CS_UNLOADS

A history of column unloads

Structure

Column name Data type Description

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

UNLOAD_TIME TIMESTAMP Timestamp of unload event

SCHEMA_NAME NVARCHAR(256) Schema name

TABLE_NAME NVARCHAR(256) Table name

COLUMN_NAME NVARCHAR(256) Column name. Empty if the whole table is unloaded.

PART_ID INTEGER Partition ID. 0 for non-partitioned tables, 1 through number of partitions for partitioned tables. -1 if the whole table is unloaded.

TABLE_OID BIGINT Object Id of the table

IS_HISTORY VARCHAR(5) Flag to indicate whether the history part is unloaded (only relevant for history tables). Empty if the whole table is unloaded.

REASON NVARCHAR(16) Unload reason (LOW MEMORY or EXPLICIT)

2.64 M_DATABASE

Database information

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 513

Page 514: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Full description

HOSTequal to: M_LANDSCAPE_HOST_CONFIGURATION.HOST WHERE NAMESERVER_CONFIG_ROLE='MASTER 1'

Structure

Column name Data type Description

DATABASE_NAME VARCHAR(256) System SID

HOST VARCHAR(64) Default master host

START_TIME TIMESTAMP Start time

VERSION VARCHAR(32) Version: major.minor.patch.build

2.65 M_DATABASE_HISTORY

Installation version history

Structure

Column name Data type Description

INSTALL_TIME TIMESTAMP Install/first start time

VERSION VARCHAR(32) Version: major.minor.patch.build

2.66 M_DATA_VOLUMES

DataVolume statistics

514P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 515: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Structure

Column name Data type Unit Description

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

VOLUME_ID INTEGER Persistence Volume ID

FILE_NAME VARCHAR(512) Filename of DataVolume

FILE_ID BIGINT FileID of DataVolume

SIZE BIGINT Byte Size of DataVolume

MAX_SIZE BIGINT Byte Max. size of DataVolume

2.67 M_DATA_VOLUME_PAGE_STATISTICS

Page usage statistics on data volumesThis view has a resettable counterpart. This means, you can also see the values since the last reset in the dependent view M_DATA_VOLUME_PAGE_STATISTICS_RESET. To reset the values, use the SQL command: ALTER SYSTEM RESET MONITORING VIEW SYS.M_DATA_VOLUME_PAGE_STATISTICS_RESET or the management console command: monitor reset -n M_DATA_VOLUME_PAGE_STATISTICS_RESET

Full description

This view contains information about the number and distribution of free, used and shadow pages inside DataVolumes. INITIAL_BLOCK_COUNT is the number of pages the database was started with. TOTAL_*_COUNT give the numbers of blocks allocated, freed or set to status FreeAfterSavepoint since the start of the database. Columns SUPERBLOCK_COUNT, USED_BLOCK_COUNT and SHADOW_BLOCK_COUNT contain the number of (super)blocks currently in use by the database. FILL_RATIO gives the ratio of minimum number of needed superblocks versus the actual number of used superblocks. Note that unused superblocks are not part of this formula (see M_DATA_VOLUME_SUPERBLOCK_STATISTICS).

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 515

Page 516: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Structure

Column name Data type Unit Description

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

VOLUME_ID INTEGER Persistence Volume ID

DATA_VOLUME_NAME VARCHAR(512) DataVolume name

PAGE_SIZECLASS VARCHAR(16) Page size class

PAGE_SIZE BIGINT Byte Page size

SUPERBLOCK_SIZE BIGINT Byte Superblock size

INITIAL_BLOCK_COUNT BIGINT Counter Count of init pages

TOTAL_ALLOCATE_BLOCK_COUNT

BIGINT Counter Number of single and group allocated blocks

TOTAL_SET_BLOCK_FREE_COUNT

BIGINT Counter Number of single and group freed blocks

TOTAL_SET_BLOCK_FREE_AFTER_SAVEPOINT_COUNT

BIGINT Counter Number of single and group freed-after-savepoint blocks

SUPERBLOCK_COUNT BIGINT Counter Number of used Superblocks

USED_BLOCK_COUNT BIGINT Counter Count of used blocks

SHADOW_BLOCK_COUNT

BIGINT Counter Count of shadow blocks

FILL_RATIO DOUBLE Percent Fill ratio

2.68 M_DATA_VOLUME_PAGE_STATISTICS_RESET

FreeBlockManager SizeClass statistics (since last reset)This view contains values accumulated since the last reset of the main view M_DATA_VOLUME_PAGE_STATISTICS. Please refer to M_DATA_VOLUME_PAGE_STATISTICS for information about the structure and use of this view.In addition to the members mentioned in M_DATA_VOLUME_PAGE_STATISTICS, this view also contains a timestamp field RESET_TIME, which indicates the last time the data was reset.

516P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 517: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

2.69 M_DATA_VOLUME_SUPERBLOCK_STATISTICS

FreeBlockManager Superblock statistics

Full description

This view shows information about the number and distribution of Superblocks inside DataVolumes. SUPERBLOCK_COUNT is the total number of Superblocks and USED_SUPERBLOCK_COUNT is the number of Superblocks currently occupied by at least one used or shadow page. FILL_RATIO gives the ratio of the number of used superblocks versus the total number of superblocks. Note that the fill ratio of the superblocks themselves is not part of this formula.

M_DATA_VOLUME_PAGE_STATISTICS

Structure

Column name Data type Unit Description

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

VOLUME_ID INTEGER Persistence Volume ID

DATA_VOLUME_NAME VARCHAR(512) DataVolume name

SUPERBLOCK_SIZE BIGINT Byte Superblock size

USED_SUPERBLOCK_COUNT

BIGINT Counter Count of used Superblocks

SUPERBLOCK_COUNT BIGINT Counter Count of Superblocks

FILL_RATIO DOUBLE Percent Fill ratio

2.70 M_DEBUG_CONNECTIONS

Overview of connections used per debug session

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 517

Page 518: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Structure

Column name Data type Description

DEBUG_SESSION_ID VARCHAR(32) Landscape-wide unique identifier for debug session

CONNECTION_ID INTEGER Connection that is used for communication

CONNECTION_USAGE VARCHAR(16) Specifies whether this connection is used for debugger communication or debugging

OPERATION NVARCHAR(512) Operation that is currently running within this connection

2.71 M_DEBUG_SESSIONS

Overview of debug sessions and their properties

Structure

Column name Data type Unit Description

DEBUG_SESSION_ID VARCHAR(32) Landscape-wide unique identifier for debug session

COMPILE_MODE VARCHAR(20) Compilation handling of nested procedures

TIMEOUT INTEGER Second Seconds after which debug session will time out and destroy itself

ATTACH_COUNT INTEGER Number of debuggees the debugger is currently attached to

ATTACH_FILTER_CONNECTION_ID

INTEGER The debugger is attached to connection with this ID

518P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 519: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

ATTACH_FILTER_USER_NAME

NVARCHAR(256) The debugger is attached to connections where this user name is set

ATTACH_FILTER_APPLICATION_USER_NAME

NVARCHAR(256) The debugger is attached to connections where this application user name is set

2.72 M_DELTA_MERGE_STATISTICS

Table delta merge statistics

Full description

This view shows table delta merge statistics. It lists the table delta merge events since the indexserver was last restarted. Table delta merges, optimize compression runs and application merge hints are listed separately.

Structure

Column name Data type Unit Description

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

TYPE VARCHAR(8) MERGE (table delta merge), HINT (application merge hint), SPARSE (optimize compression), FACT (fact table compression)

SCHEMA_NAME NVARCHAR(256) Schema name

TABLE_NAME NVARCHAR(256) Table name

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 519

Page 520: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

PART_ID INTEGER Partition ID. 0 for non-partitioned tables, 1 through number of partitions for partitioned tables. -1 if the whole table is unloaded.

HISTORY VARCHAR(5) Boolean Flag to indicate history part was merged: 'TRUE', 'FALSE'

MEMORY_MERGE VARCHAR(5) Boolean Flag to indicate table was merged in memory only: 'TRUE', 'FALSE'

PASSPORT VARCHAR(256) External identifier for table merge called by an application

START_TIME TIMESTAMP Execution start time

EXECUTION_TIME BIGINT Millisecond Execution duration

MOTIVATION VARCHAR(8) HARD, SMART, AUTO, FORCE

SUCCESS VARCHAR(5) Boolean Call success flag; depends on field TYPE; HINT: application merge hint was accepted/rejected; MERGE/SPARSE: delta merge/optimize compression was completed with or without success: 'TRUE', 'FALSE'

MERGED_DELTA_RECORDS

INTEGER Counter Number of documents in delta

LAST_ERROR INTEGER Error code of the last error that occurred. Can be used to explain why a merge did not succeed. See M_ERROR_CODES for error code descriptions

520P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 521: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

2.73 M_DISKS

Disk configuration and utilization of the host machine

Structure

Column name Data type Unit Description

DISK_ID INTEGER Disk ID

DEVICE_ID BIGINT Database Internal Device ID

HOST VARCHAR(64) Host name. Will only be set if disk is used by exactly one host.

PATH VARCHAR(512) Path

SUBPATH VARCHAR(512) Subpath

FILESYSTEM_TYPE VARCHAR(16) Filesystem type

USAGE_TYPE VARCHAR(32) Usage Type: LOG, DATA, TRACE, DATA_BACKUP and LOG_BACKUP

TOTAL_SIZE BIGINT Byte Volume Used Space

USED_SIZE BIGINT Byte Volume Size

2.74 M_ERROR_CODES

Error codes with descriptions

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 521

Page 522: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Structure

Column name Data type Description

CODE INTEGER Error Code

CODE_STRING VARCHAR(256) Error Code String

DESCRIPTION VARCHAR(2000) Error Description

2.75 M_EVENTS

Internal events

Full description

Important events (for example, DiskFull) reported by the database are shown in this view. The state of an event can be either NEW or HANDLED. CREATE TIME shows the time the event was created (and reported) and HANDLE time shows the time the event was handled (that is, cleared). Handled events are removed periodically by the StatisticsServer

Structure

Column name Data type Description

HOST VARCHAR(64) Host

PORT INTEGER Port

TYPE VARCHAR(256) Type of event

ID BIGINT ID of event

INFOTEXT VARCHAR(2000) Additional info freetext

CREATE_TIME TIMESTAMP Time event was created

UPDATE_TIME TIMESTAMP Time event was updated

HANDLE_TIME TIMESTAMP Time event was handled

522P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 523: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Description

STATE VARCHAR(256) State of event

ACKNOWLEDGED VARCHAR(5) Event acknowledged: 'TRUE', 'FALSE'

FAILED_HANDLES BIGINT Number of failed handle attempts

2.76 M_EXPENSIVE_STATEMENTS

All statements with duration longer than a threshold

Full description

Allows you to monitor all statements that have an execution time longer than a predefined threshold (configurable using the [expensive_statements] section of the indexserver.ini), and that might therefore be performance bottlenecks.

The M_EXPENSIVE_STATEMENTS view provides convenient access to the most expensive statements that were executed on the system. A statement is considered being expensive if its runtime exceeds a particular threshold.

For example to configure the threshold using the SAP HANA studio note that the expensive statements trace needs to be activated first in the Performance -> Expensive Statements Trace screen in the SAP HANA studio. Click Configure to open the Trace Configuration dialog. There you can activate tracing and also adjust the threshold.

There are the following main types of operations:

● ExecuteStatement: execution of simple exact query string● PrepareStatement: preparation of prepared statement● ExecutePrepared: execution of prepared statement● FetchCursor: fetching resultset● CloseCursor: closing cursor● CloseStatement: closing prepared statement● AggregatedExecuteStatement: calculates overall execution time

For example, if a query has 4 session requests from a client as follows: 1. Prepare: 10 msec 2. Execute: 20 msec 3. Fetch: 15 msec 4. Close: 5 msec

Assuming that all operations were longer than the threshold they will be shown as: OPERATION DURATION PrepareStatement 10 ExecutePrepared 20 FetchCursor 15 Close 5 AggregatedExecuteStatement 50 (10+20+15+5)

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 523

Page 524: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Structure

Column name Data type Unit Description

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

CONNECTION_ID INTEGER Connection ID

TRANSACTION_ID INTEGER Transaction object ID

UPDATE_TRANSACTION_ID

BIGINT Write transaction ID (This number is ever increasing)

STATEMENT_ID NVARCHAR(256) Statement ID

STATEMENT_HASH VARCHAR(32) Unique identifier for an SQL string

DB_USER NVARCHAR(256) User name

APP_USER NVARCHAR(256) Application user name

START_TIME TIMESTAMP Statement start time

DURATION_MICROSEC BIGINT Microsecond Statement duration

OBJECT_NAME NVARCHAR(5000) Related objects

OPERATION NVARCHAR(5000) Type of operation: e.g. prepare, execute, fetch, close

RECORDS BIGINT Number of records

STATEMENT_STRING NCLOB Statement string

PARAMETERS NVARCHAR(5000) Parameters

ERROR_CODE INTEGER Error code

ERROR_TEXT NVARCHAR(5000) Error message

LOCK_WAIT_COUNT INTEGER Accumulated lock wait count

LOCK_WAIT_DURATION BIGINT Accumulated lock wait duration

524P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 525: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

ALLOC_MEM_SIZE_ROWSTORE

BIGINT Byte Allocated memory size for row store

ALLOC_MEM_SIZE_COLSTORE

BIGINT Byte Allocated memory size for column store

MEMORY_SIZE BIGINT Memory required for computing the statement, incl. memory for intermediate results. Kept for cache reasons or released after the statement execution.

REUSED_MEMORY_SIZE BIGINT Memory reused from cached data structures, 0 if caches empty

CPU_TIME BIGINT CPU time (us) consumed to compute the statement

PASSPORT_ROOT_CONTEXT_ID

VARCHAR(32) Guid SAP EPP Passport GUID identifying source of request

PASSPORT_TRANSACTION_ID

VARCHAR(32) Guid SAP EPP Passport GUID identifying business transaction

PASSPORT_CONNECTION_ID

VARCHAR(32) Guid SAP EPP Passport GUID identifying connection

PASSPORT_CONNECTION_COUNTER

BIGINT SAP EPP Passport connection counter

STATEMENT_START_TIME

TIMESTAMP Time when the first OPERATION of a statement execution started. All OPERATIONs of a statement execution share the same STATEMENT_START_TIME.

APPLICATION_SOURCE NVARCHAR(256) Application can define from which source file SAP HANA is called. Usage is up to the application.

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 525

Page 526: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

Value also displayed in M_PREPARED_STATEMENTS.APPLICATION_SOURCE

APPLICATION_NAME NVARCHAR(256) Name of the application

2.77 M_EXPORT_BINARY_STATUS

Export status information for current session

Structure

Column name Data type Description

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

CONNECTION_ID INTEGER Connection ID to distinguish data of each import session (-1 for Python)

SCHEMA_NAME NVARCHAR(256) Schema of table or view being imported

TABLE_NAME NVARCHAR(256) Name of table or view being imported

INDEX_TYPE VARCHAR(16) Index type: 'UNKNOWN', 'PHYSICAL', 'OLAP', 'JOIN', 'HIERARCHY', 'CALCULATION', ...

STATUS VARCHAR(16) Import status. 'queued', 'working', 'skipped', 'done', 'failed'

ERROR VARCHAR(512) Empty if import was successful, error text otherwise

526P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 527: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

2.78 M_EXTRACTORS

Direct extractor connection (DXC) status information

Structure

Column name Data type Description

SCHEMA_NAME NVARCHAR(256) Name of the schema where the DSO tables are generated

TABLE_NAME NVARCHAR(256) Name of the DSO specific status table

CLIENT NVARCHAR(3) The ID of the client

STATUS VARCHAR(5) General status overview saying 'OK' or 'ERROR'

REQUEST_ID INTEGER SID of the request used for activation

ERROR_MESSAGE NVARCHAR(5000) The message in case of an error

PHASE VARCHAR(32) The phase of the last running operation

TIMESTAMP TIMESTAMP Timestamp of the operation phase

2.79 M_FEATURES

All supported features

Structure

Column name Data type Description

COMPONENT_NAME VARCHAR(16) Name of the component owning the feature

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 527

Page 528: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Description

FEATURE_NAME VARCHAR(32) Name of the feature

FEATURE_VERSION BIGINT Version of the feature

2.80 M_FULLTEXT_QUEUES

Fulltext index queue status

Structure

Column name Data type Description

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

INDEX_OID BIGINT OID of the corresponding fulltext index

SCHEMA_NAME NVARCHAR(256) Schema of the data table

TABLE_NAME NVARCHAR(256) Name of the data table

PART_ID INTEGER Partition ID. 0 for non-partitioned tables, 1 through number of partitions for partitioned tables. -1 if the whole table is unloaded.

COLUMN_NAME NVARCHAR(256) Name of the document column

STATUS NVARCHAR(16) Queue status (ACTIVE, SUSPENDED)

TOTAL_DOCUMENT_COUNT BIGINT Total number of documents in the original table

INDEXED_DOCUMENT_COUNT BIGINT Number of successfully indexed documents

QUEUE_DOCUMENT_COUNT BIGINT Number of documents currently in the queue

528P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 529: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Description

ERROR_DOCUMENT_COUNT BIGINT Number of failed documents

2.81 M_FUZZY_SEARCH_INDEXES

Runtime information of fuzzy search indexes of column tables

Full description

This view shows the memory usage of all fuzzy search indexes. A fuzzy search index has no name and is identified by its schema name, table name and column name.

Structure

Column name Data type Unit Description

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

SCHEMA_NAME NVARCHAR(256) Schema name

TABLE_NAME NVARCHAR(256) Table name

COLUMN_NAME NVARCHAR(256) Column name

PART_ID INTEGER Partition ID. 0 for non-partitioned tables, 1 through number of partitions for partitioned tables, -1 during table schema change

FUZZY_SEARCH_MODE NVARCHAR(256) Fuzzy index search mode

MEMORY_SIZE_IN_TOTAL

BIGINT Byte Sum of MEMORY_SIZE_IN_MAIN and MEMORY_SIZE_IN_DELTA

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 529

Page 530: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

MEMORY_SIZE_IN_MAIN BIGINT Byte Current size of the fuzzy search indexes in main; 0 if not loaded

MEMORY_SIZE_IN_DELTA BIGINT Byte Current size of the fuzzy search indexes in delta; 0 if not loaded

LOADED VARCHAR(5) Boolean Flag to indicate that column is loaded into memory: 'TRUE', 'FALSE'

2.82 M_GARBAGE_COLLECTION_STATISTICS

Garbage collection/history manager statisticsThis view has a resettable counterpart. This means, you can also see the values since the last reset in the dependent view M_GARBAGE_COLLECTION_STATISTICS_RESET. To reset the values, use the SQL command: ALTER SYSTEM RESET MONITORING VIEW SYS.M_GARBAGE_COLLECTION_STATISTICS_RESET or the management console command: monitor reset -n M_GARBAGE_COLLECTION_STATISTICS_RESET

Full description

This view shows various statistics about garbage collection jobs.

Garbage collection is used to remove old versions of data objects from the system. Afterwards no transaction can reference them. References to such objects are kept in history (cleanup) files, which are processed by the garbage collector.

Normally, the system runs in statement consistency isolation level, that is, a consistent view is acquired when an SQL command starts. Alternatively, the system can be run in transaction consistency isolation level, where the consistent view is acquired when the transaction starts and is held until the transaction terminates (snapshot isolation, similar to SERIALIZABLE isolation level). Each consistent view contains a reference to a minReadTID Transaction ID (TID), which is the minimum TID, from which the changes are "seen" by the transaction. Global minReadTID (minimum of minReadTIDs of all consistent views) is used by the garbage collector to determine which history files can be cleaned.

In the case that history files accumulate and MIN_READ_TID doesn't advance, there is a good chance that some transaction holds its consistent view for very long time (for example, a long-running transaction of a forgotten read transaction in a GUI). You can look into M_TRANSACTIONS to see information about each running transaction.

530P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 531: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Structure

Column name Data type Unit Description

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

VOLUME_ID INTEGER Persistence Volume ID

STORE_TYPE VARCHAR(16) type of storage handled (COLUMN STORE, LIVECACHE)

HISTORY_COUNT INTEGER Counter Current count of history files in GC

WAITER_COUNT INTEGER Counter Current count of GC waiters

MIN_READ_TID BIGINT TID Last known minimum TID of a reading transaction at EOT

LAST_STARTED_TID BIGINT TID TID of the last started cleanup job

LAST_STARTED_TID_POSTCOMMIT

BIGINT TID TID of the last started postcommit job

FIRST_WAITING_TID BIGINT TID TID of the first waiting cleanup job

FIRST_WAITING_TID_POSTCOMMIT

BIGINT TID TID of the first waiting postcommit job

ENTERS BIGINT Counter Count of history files which entered the queue for cleanup

ENTERS_POSTCOMMIT BIGINT Counter Count of history files which entered the queue for postcommit

STARTED_JOBS BIGINT Counter Count of garbage collection (cleanup) jobs started

STARTED_JOBS_POSTCOMMIT

BIGINT Counter Count of postcommit jobs started

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 531

Page 532: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

PROCESSED_JOBS BIGINT Counter Count of undo files processed for cleanup

PROCESSED_JOBS_POSTCOMMIT

BIGINT Counter Count of undo files processed for postcommit

QUEUE_LOADS BIGINT Counter Count of all GC queue loads

QUEUE_LOADS_NONEMPTY

BIGINT Counter Count of GC queue loads which found some elements

QUEUE_EMPTY_COUNT BIGINT Counter Count of queue empty states after GC finished

SAVEPOINTS BIGINT Counter Count of savepoints

LAST_HISTORY_SIZE_AT_SVP

BIGINT Counter Count of history files present at savepoint (last)

MAX_HISTORY_SIZE_AT_SVP

BIGINT Counter Count of history files present at savepoint (max)

MIN_HISTORY_SIZE_AT_SVP

BIGINT Counter Count of history files present at savepoint (min)

SUM_HISTORY_SIZE_AT_SVP

BIGINT Counter Count of history files present at savepoint (total)

AVG_HISTORY_SIZE_AT_SVP

DOUBLE Rate Count of history files present at savepoint (avg)

EMPTY_HISTORY_AT_SVP_COUNT

BIGINT Counter Count of savepoints finding empty queue

2.83 M_GARBAGE_COLLECTION_STATISTICS_RESET

Garbage collection/history manager statistics (since last reset)This view contains values accumulated since the last reset of the main view M_GARBAGE_COLLECTION_STATISTICS. Please refer to M_GARBAGE_COLLECTION_STATISTICS for information about the structure and use of this view.In addition to the members mentioned in M_GARBAGE_COLLECTION_STATISTICS, this view also contains a timestamp field RESET_TIME, which indicates the last time the data was reset.

532P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 533: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

2.84 M_HEAP_MEMORY

Memory allocator statisticsThis view has a resettable counterpart. This means, you can also see the values since the last reset in the dependent view M_HEAP_MEMORY_RESET. To reset the values, use the SQL command: ALTER SYSTEM RESET MONITORING VIEW SYS.M_HEAP_MEMORY_RESET or the management console command: monitor reset -n M_HEAP_MEMORY_RESET

Full description

This view contains information about memory consumption of various components in the system. Parallel to heap memory, you can also query memory consumption by connection/statement/user using M_CONTEXT_MEMORY.

The overhead of allocators is not considered here.

M_CONTEXT_MEMORY, M_SERVICE_MEMORY

Structure

Column name Data type Unit Description

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

VOLUME_ID INTEGER Persistence Volume ID

STATISTICS_ID BIGINT Statistics object unique ID

CATEGORY VARCHAR(128) Allocator name

DEPTH BIGINT Depth

INCLUSIVE_SIZE_IN_USE BIGINT Byte Current size of this allocator, including suballocators

INCLUSIVE_COUNT_IN_USE

BIGINT Counter Number of blocks currently in use, including suballocators

INCLUSIVE_ALLOCATED_SIZE

BIGINT Byte Total allocated size in this allocator and suballocators

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 533

Page 534: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

INCLUSIVE_DEALLOCATED_SIZE

BIGINT Byte Total deallocated size in this allocator and suballocators

INCLUSIVE_ALLOCATED_COUNT

BIGINT Counter Count of allocations, including suballocators

INCLUSIVE_DEALLOCATED_COUNT

BIGINT Counter Count of deallocations, including suballocators

INCLUSIVE_MAX_SINGLE_ALLOCATION_SIZE

BIGINT Byte Maximum ever allocated block size in this allocator and suballocators

INCLUSIVE_PEAK_ALLOCATION_SIZE

BIGINT Byte Maximum size of this allocator and suballocators (estimate)

INCLUSIVE_IN_USE_INTEGRAL

BIGINT Average allocated memory by this allocator and its suballocators, multiplied by time since start of measurement (sample based rough estimate), this is usually deactivated, only activate in case this is requested by SAP support. Unit is 1 byte times 1 second (may change in future).

EXCLUSIVE_SIZE_IN_USE BIGINT Byte Current size of this allocator

EXCLUSIVE_COUNT_IN_USE

BIGINT Counter Number of blocks currently in use

EXCLUSIVE_ALLOCATED_SIZE

BIGINT Byte Total allocated size in this allocator

EXCLUSIVE_DEALLOCATED_SIZE

BIGINT Byte Total deallocated size in this allocator

EXCLUSIVE_ALLOCATED_COUNT

BIGINT Counter Count of allocations

EXCLUSIVE_DEALLOCATED_COUNT

BIGINT Counter Count of deallocations

534P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 535: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

EXCLUSIVE_MAX_SINGLE_ALLOCATION_SIZE

BIGINT Byte Maximum ever allocated block size in this allocator

EXCLUSIVE_PEAK_ALLOCATION_SIZE

BIGINT Byte Maximum size of this allocator (estimate)

EXCLUSIVE_ALLOC_ERRORS

BIGINT Counter Count of allocation errors

EXCLUSIVE_IN_USE_INTEGRAL

BIGINT Average allocated memory by this allocator, multiplied by time since start of measurement (sample based rough estimate), this is usually deactivated, only activate in case this is requested by SAP support. Unit is 1 byte times 1 second (may change in future).

MALLOC_PROXY_CACHE_MISSES

BIGINT Counter Count of malloc proxy cache misses

FLAGS VARCHAR(64) Allocator flags

2.85 M_HEAP_MEMORY_RESET

Memory allocator statistics (since last reset)This view contains values accumulated since the last reset of the main view M_HEAP_MEMORY. Please refer to M_HEAP_MEMORY for information about the structure and use of this view.In addition to the members mentioned in M_HEAP_MEMORY, this view also contains a timestamp field RESET_TIME, which indicates the last time the data was reset.

2.86 M_HISTORY_INDEX_LAST_COMMIT_ID

Last commit ID of history index for each session

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 535

Page 536: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Structure

Column name Data type Description

SESSION_ID BIGINT Session ID

SESSION_OWNER_VOLUME_ID BIGINT Volume ID of this session

LAST_COMMIT_ID BIGINT Last commit ID of history index in this session

2.87 M_HOST_INFORMATION

Host information such as machine, OS configuration

Full description

This view contains some host specific information. The following describes the contents of the individual lines of the monitor view (VALUE), as identified by KEY:build_version

Build version number. Same as M_DATABASE.VERSION

build_branchBuild branch name in revision control software

net_publicnamePublic host name that should be used by client interfaces. Can contain a host name, FQDN or IP address

sapsystemTwo digit SAP system instance number

sidThree letter SAP system name

With INIFILE ADMIN privilege, more information is shown:

build_timeBuild compile time

build_gen"opt" or "dbg"

cpu_manufacturer

536P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 537: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

CPU manufacturer

cpu_modelCPU model

cpu_coresNumber of CPU cores

cpu_threadsNumber of logical CPU cores (e.g. hyper threading)

cpu_clockCPU clock in MHz

cpu_summarypreformatted cpu_cores+cpu_threads+cpu_clock string

daemon_active"yes" if hdbdaemon is running

hw_manufacturerHardware manufacturer from BIOS

hw_modelHardware model from BIOS

mem_physPhysical memory size in byte

mem_swapSwap size in byte

net_domaindomain name of current host or "-" if not configured

net_hostnamesAll known host names of this host

net_ip_addressesAll IP adresses of this host

net_realhostnameReal host name if installation was done with a virtual host name, else set to "-"

os_nameOperating system name

os_ppms_nameOperating system name as used by SAP PPMS

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 537

Page 538: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

os_userOperating system user

os_rlimit_nofileLinux RLIMIT_NOFILE value

os_kernel_versionLinux kernel version

platform"windows" or "unix"

sap_retrieval_pathHost specific base directory

sap_retrieval_path_shared"yes" if all sap_retrievel_path directories are located on a shared storage

start_timeStart time of Nameserver

timezone_nameTimezone name

timezone_offsetTimezone offset to GMT in seconds

topology_mem_typeAlways "shared"

topology_mem_infoError message if "shared" memory could not be created

Structure

Column name Data type Description

HOST VARCHAR(64) Host name

KEY VARCHAR(32) Key

VALUE VARCHAR(256) Value

538P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 539: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

2.88 M_HOST_RESOURCE_UTILIZATION

Host resource utilization, CPU time is in milliseconds and added across all cores since system start

Structure

Column name Data type Unit Description

HOST VARCHAR(64) Host name

FREE_PHYSICAL_MEMORY

BIGINT Byte Free physical memory on the host

USED_PHYSICAL_MEMORY

BIGINT Byte Used physical memory on the host

FREE_SWAP_SPACE BIGINT Byte Free swap memory on the host

USED_SWAP_SPACE BIGINT Byte Used swap memory on the host

ALLOCATION_LIMIT BIGINT Byte Allocation limit for all processes

INSTANCE_TOTAL_MEMORY_USED_SIZE

BIGINT Byte Amount of memory from the memory pool that is currently in actual use by SAP HANA processes

INSTANCE_TOTAL_MEMORY_ALLOCATED_SIZE

BIGINT Byte Size of the memory pool for all SAP HANA processes

INSTANCE_CODE_SIZE BIGINT Byte Code size, including shared libraries of SAP HANA processes

INSTANCE_SHARED_MEMORY_ALLOCATED_SIZE

BIGINT Byte Shared memory size of SAP HANA processes

TOTAL_CPU_USER_TIME BIGINT Millisecond CPU time spent in user mode

TOTAL_CPU_SYSTEM_TIME

BIGINT Millisecond CPU time spent in kernel mode

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 539

Page 540: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

TOTAL_CPU_WIO_TIME BIGINT Millisecond CPU time spent in wait IO (Linux only, Windows always 0)

TOTAL_CPU_IDLE_TIME BIGINT Millisecond CPU idle time

SYS_TIMESTAMP TIMESTAMP Host timestamp in local time zone

UTC_TIMESTAMP TIMESTAMP Host timestamp in UTC

2.89 M_IMPORT_BINARY_STATUS

Import status information for current session

Structure

Column name Data type Description

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

CONNECTION_ID INTEGER Connection ID to distinguish data of each import session (-1 for Python)

SCHEMA_NAME NVARCHAR(256) Schema of table or view being imported

TABLE_NAME NVARCHAR(256) Name of table or view being imported

INDEX_TYPE VARCHAR(16) Index type: 'UNKNOWN', 'PHYSICAL', 'OLAP', 'JOIN', 'HIERARCHY', 'CALCULATION', ...

STATUS VARCHAR(16) Import status. 'queued', 'working', 'skipped', 'done', 'failed'

ERROR VARCHAR(512) Empty if import was successful, error text otherwise

540P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 541: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

2.90 M_INIFILES

All configuration files

Full description

Change Inifiles Calls

For the SYSTEM layer (you cannot set the DEFAULT layer):

ALTER SYSTEM INIFILE('filename', layer) SET ('section1', 'key1') = 'value1', ('section2', 'key2') = 'value2';

For the TENANT and HOST layers:

ALTER SYSTEM INIFILE('filename', 'layer', 'layername') SET ('section1', 'key1') = 'value1', ('section2', 'key2') = 'value2';

To remove a section or key:

ALTER SYSTEM INIFILE('filename', 'layer'[, 'layername']) REMOVE ('section1', 'key1'), ('section2', 'key2'), ('section3') with reconfigure;

With reconfigure:

ALTER SYSTEM INIFILE ..... [ WITH RECONFIGURE ] ;

The services to be reconfigured are defined in inifiles.ini

Structure

Column name Data type Unit Description

FILE_NAME VARCHAR(256) Configuration file name

DEFAULT_LAYER VARCHAR(5) Boolean TRUE if file has configuration on this layer (Always TRUE)

SYSTEM_LAYER VARCHAR(5) Boolean TRUE if file has configuration on this layer

TENANT_LAYER VARCHAR(5) Boolean TRUE if file has configuration on this layer

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 541

Page 542: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

HOST_LAYER VARCHAR(5) Boolean TRUE if file has configuration on this layer

2.91 M_INIFILE_CONTENTS

Configuration information from inifiles

Structure

Column name Data type Description

FILE_NAME VARCHAR(256) Configuration file name

LAYER_NAME VARCHAR(16) Configuration layer: DEFAULT, SYSTEM, TENANT, HOST

TENANT_NAME VARCHAR(256) Tenant name, if layer is TENANT

HOST VARCHAR(64) Host name, if layer is HOST

SECTION VARCHAR(128) Configuration section name

KEY VARCHAR(128) Configuration key name

VALUE VARCHAR(5000) Configuration value

2.92 M_JOB_PROGRESS

Current long running system operations

Full description

The view shows current long running system operations.

JOB_NAME

542P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 543: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Value Description

Delta Merge delta merge

Optimize Compression optimize compression

BW F Fact Table Compression fact table compression

Re-partitioning table split and merge operations

Table Redistribution Generate table redistribution plan generation

Table Redistribution Execute table redistribution plan execution

Delta Log Replay delta log replay

DSO activation dso activation

DSO rollback dso rollback

DSO conversion dso conversion

Save PerfTrace saving performance trace

Import import operation

Export export operation

Row Store Reorganization row storage reorganization

Structure

Column name Data type Description

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

SCHEMA_NAME NVARCHAR(256) Schema of the object

OBJECT_NAME NVARCHAR(256) Name of the object

JOB_NAME NVARCHAR(128) Type of the operation

CONNECTION_ID INTEGER Connection that triggered the operation

START_TIME TIMESTAMP Start time of the operation

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 543

Page 544: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Description

CURRENT_PROGRESS INTEGER Steps of the operation that are already finished

MAX_PROGRESS INTEGER Maximum steps of the operation

PROGRESS_DETAIL NVARCHAR(256) Detail information of the operation

2.93 M_LANDSCAPE_HOST_CONFIGURATION

Host roles in a distributed landscape

Full description

The view is read-only. To change the configuration use SAP HANA studio, which internally uses this stored procedure:

UPDATE_LANDSCAPE_CONFIGURATION(ACTION in VARCHAR(80), DATA in NCLOB) -> resultset (NAME,VALUE)

HOST_ACTIVE

Value Description

YES All services are active

STARTING Some services are active, host is starting

PARTIAL Some services are active

STOPPING Some services are active, host is stopping

NO No services are active

HOST_STATUS

Value Description

OK Landscape operational, host actual role equals configured role

IGNORE Landscape operational, host configured as standby is available, but not used

544P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 545: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Value Description

INFO Landscape operational, host actual role is different from configured role

WARNING Landscape not operational, host should become operational after startup/failover

ERROR Landscape not operational, host is missing

FAILOVER_STATUS

Value Description

No failover pending/active

waiting .. sec Failure detected. Waiting some time for restart to prevent unnecessary failover

waiting Failure detected. Waiting for other 'starting' host

failover to 'host' Failover to 'host' active.

failback to 'host' Failback to worker 'host' active. Happens when a standby host was assigned and is stopped. There is no automatic failback while the standby host is assigned, because this would cause some downtime

failed Failover failed. See nameserver.trc for details

NAMESERVER_CONFIG_ROLEDuring installation up to 3 hosts are automatically configured as MASTER candidates. All others are SLAVE.

It is recommended to specify these 3 hosts in the connection url (see SAP HANA Administration Guide, chapter 'Configuring clients for Failover Support), because at least one of these hosts will be active.

NAMESERVER_ACTUAL_ROLEExactly one of the master candidates is MASTER, all other are SLAVE.

The actual master name server and master index server are both on the same host.

INDEXSERVER_CONFIG_ROLEDuring installation with 'hdbaddhost' the host is configured as WORKER or STANDBY

INDEXSERVER_ACTUAL_ROLEExactly one host is MASTER, the others are SLAVE or STANDBY.

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 545

Page 546: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

During normal operation, when all hosts are available, a configured WORKER has an actual role of MASTER or SLAVE and a configured STANDBY has an actual role of STANDBY. After failover the actual roles switch and the HOST_STATUS changes from OK+IGNORE to 2*INFO.

FAILOVER_CONFIG_GROUPHosts can be grouped. During failover a host is looked for within the same group. If no host is available in the same group, hosts from other groups are used. Usage of other groups can be disabled with the configuration parameter: nameserver.ini

Structure

Column name Data type Description

HOST VARCHAR(64) Host name

HOST_ACTIVE VARCHAR(128) Host active Status (Summary of Active values of all services on that host)

HOST_STATUS VARCHAR(128) Host status

FAILOVER_STATUS VARCHAR(128) Failover status

FAILOVER_GROUP VARCHAR(256) DEPRECATED: replaced by FAILOVER_..._GROUP columns

FAILOVER_CONFIG_GROUP VARCHAR(256) Configured failover group

FAILOVER_ACTUAL_GROUP VARCHAR(256) Actual failover group

NAMESERVER_CONFIG_ROLE VARCHAR(16) Nameserver configured role: MASTER, SLAVE

NAMESERVER_ACTUAL_ROLE VARCHAR(16) Nameserver actual role: MASTER, SLAVE

INDEXSERVER_CONFIG_ROLE VARCHAR(16) Indexserver configured role: WORKER, STANDBY

INDEXSERVER_ACTUAL_ROLE VARCHAR(16) Indexserver actual role: MASTER, SLAVE, STANDBY

STORAGE_PARTITION INTEGER Storage Partition ~= subpath used by that host

REMOVE_STATUS VARCHAR(16) Remove progress

546P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 547: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

2.94 M_LICENSE

Information on the currently valid license (if any) installed on this system

Structure

Column name Data type Description

HARDWARE_KEY VARCHAR(11) Hardware key of this SAP HANA installation

SYSTEM_ID VARCHAR(3) System identifier (SID) of this SAP HANA database

INSTALL_NO VARCHAR(10) Installation number of this SAP HANA database

SYSTEM_NO VARCHAR(18) System number of this SAP HANA database

PRODUCT_NAME VARCHAR(256) Name of the licensed software product, e.g. SAP HANA

PRODUCT_LIMIT BIGINT Licensed amount of main memory as specified by the license

PRODUCT_USAGE BIGINT Peak memory allocation since installation, measured hourly

START_DATE TIMESTAMP Start date of the validity period of the license

EXPIRATION_DATE TIMESTAMP Expiration date of the validity period of the license

LAST_SUCCESSFUL_CHECK TIMESTAMP Latest date on which the license was successfully checked and found valid

PERMANENT VARCHAR(5) TRUE if the license is a permanent one, FALSE if the license is a temporary one

VALID VARCHAR(5) TRUE if the license is currently valid, otherwise FALSE

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 547

Page 548: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Description

ENFORCED VARCHAR(5) TRUE if the license is a memory-enforced license, otherwise FALSE

LOCKED_DOWN VARCHAR(5) TRUE if the system is locked down due to license status, otherwise FALSE

MEASUREMENT_XML CLOB Measurement log produced for this licensed system with current memory consumption

2.95 M_LICENSE_USAGE_HISTORY

Information on the maximum resource consumption per time period, used for validity check of license installed on this system (if any)

Structure

Column name Data type Description

PRODUCT_USAGE BIGINT Maximum utilized amount of main memory used in this period

PERIOD_START_TIME TIMESTAMP Start time of the period the maximum was used in

PERIOD_END_TIME TIMESTAMP End time of the period the maximum was used in

2.96 M_LIVECACHE_CONTAINER_STATISTICS

LiveCache container statisticsThis view has a resettable counterpart. This means, you can also see the values since the last reset in the dependent view M_LIVECACHE_CONTAINER_STATISTICS_RESET. To reset the values, use the SQL command: ALTER SYSTEM RESET MONITORING VIEW SYS.M_LIVECACHE_CONTAINER_STATISTICS_RESET or the management console command: monitor reset -n M_LIVECACHE_CONTAINER_STATISTICS_RESET

548P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 549: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Structure

Column name Data type Unit Description

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

CONTAINER_ID BIGINT Container ID

OMS_CLASS_ID INTEGER OMS class ID

OMS_CLASS_NAME VARCHAR(64) OMS class name

OMS_SCHEMA_HANDLE INTEGER OMS schema handle

OMS_CONTAINER_NO INTEGER OMS container number

CLASS_SIZE BIGINT Byte Object class size

KEY_SIZE INTEGER Byte Object key size

KEY_PARTITION_COUNT INTEGER Key partition count

KEY_PARTITION_PREFIX_SIZE

INTEGER Byte Key partition prefix length

CACHED_KEYS VARCHAR(5) Cached keys active: 'TRUE', 'FALSE'

COPY_ON_UPDATE VARCHAR(5) Copy on update active: 'TRUE', 'FALSE'

OBJECT_COUNT BIGINT Counter Object count

OBJECT_SIZE_SUM BIGINT Byte Object size sum

HISTORY_OBJECT_COUNT

BIGINT Counter History (mark deleted) object count

HISTORY_SIZE_SUM BIGINT Byte History data size sum

PAGE_COUNT BIGINT Counter Page count

PAGE_SIZE_SUM BIGINT Byte Page size sum

OBJECT_CREATE_COUNT BIGINT Counter Object create count since restart

OBJECT_UPDATE_COUNT

BIGINT Counter Object update count since restart

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 549

Page 550: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

OBJECT_DELETE_COUNT BIGINT Counter Object delete count since restart

CREATE_TIME TIMESTAMP Create timestamp

2.97 M_LIVECACHE_CONTAINER_STATISTICS_RESET

LiveCache container statistics (since last reset)This view contains values accumulated since the last reset of the main view M_LIVECACHE_CONTAINER_STATISTICS. Please refer to M_LIVECACHE_CONTAINER_STATISTICS for information about the structure and use of this view.In addition to the members mentioned in M_LIVECACHE_CONTAINER_STATISTICS, this view also contains a timestamp field RESET_TIME, which indicates the last time the data was reset.

2.98 M_LIVECACHE_LOCKS

Detailed information on the Object Management System (OMS) locks

Full description

The liveCache uses its own lock-manager for object locks, container locks, and schema locks. This view shows information about all the locks, which are currently kept in this lock manager.

CautionExclusive locks on objects are in most cases not managed by this lock manager, but the necessary lock-information is stored in the respective object header.

This view can only be used if liveCache is enabled.

Structure

Column name Data type Unit Description

HOST VARCHAR(64) Host name

550P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 551: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

PORT INTEGER Internal port

ID VARCHAR(20) ID of the lock (OID, container ID, or schema ID dependent on the lock class)

CLASS VARCHAR(20) The class that the lock belongs to

GRANTED_MODE VARCHAR(20) The mode that the lock has currently granted to some request(s)

MODE VARCHAR(20) The mode that the request is requesting on the lock: 'Free', 'IntendShare', 'IntendExclusive', 'Share', 'ShareIntendExclusive', 'Exclusive'

TYPE VARCHAR(10) The type specifies when the lock can be removed (either at transaction-end (EOT) or if not visible anymore (Consistent))

STATE VARCHAR(10) State of this lock request

TID BIGINT TID Transaction ID belonging to this lock request

TIMEOUT BIGINT Remaining timeout, if timeout is specified

2.99 M_LIVECACHE_LOCK_STATISTICS

LiveCache lock statisticsThis view has a resettable counterpart. This means, you can also see the values since the last reset in the dependent view M_LIVECACHE_LOCK_STATISTICS_RESET. To reset the values, use the SQL command: ALTER SYSTEM RESET MONITORING VIEW SYS.M_LIVECACHE_LOCK_STATISTICS_RESET or the management console command: monitor reset -n M_LIVECACHE_LOCK_STATISTICS_RESET

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 551

Page 552: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Full description

The liveCache uses its own lock-manager for object locks, container locks, and schema locks. This view shows the accumulated statistics of the lock requests to this lock-manager, which have been executed since restart.

CautionThis view is only usable if liveCache is enabled.

Structure

Column name Data type Unit Description

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

CONTAINER_EXCLUSIVE_COUNT

BIGINT Counter Number of exclusive lock requests on containers

CONTAINER_SHARED_COUNT

BIGINT Counter Number of shared lock requests on containers

CONTAINER_COLLISION_COUNT

BIGINT Counter Number of lock collisions on containers

CONTAINER_TIMEOUT_COUNT

BIGINT Counter Number of lock timeouts on containers

SCHEMA_EXCLUSIVE_COUNT

BIGINT Counter Number of exclusive lock requests on schemas

SCHEMA_SHARED_COUNT

BIGINT Counter Number of shared lock requests on schemas

SCHEMA_COLLISION_COUNT

BIGINT Counter Number of lock collisions on schemas

SCHEMA_TIMEOUT_COUNT

BIGINT Counter Number of lock timeouts on schemas

OBJECT_EXCLUSIVE_COUNT

BIGINT Counter Number of exclusive lock requests on objects

OBJECT_SHARED_COUNT

BIGINT Counter Number of shared lock requests on objects

552P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 553: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

OBJECT_COLLISION_COUNT

BIGINT Counter Number of lock collisions on objects

OBJECT_TIMEOUT_COUNT

BIGINT Counter Number of timeouts on objects

COMMITTED_REQUESTS_COUNT

BIGINT Counter Number of committed requests

2.100 M_LIVECACHE_LOCK_STATISTICS_RESET

LiveCache lock statistics (since last reset)This view contains values accumulated since the last reset of the main view M_LIVECACHE_LOCK_STATISTICS. Please refer to M_LIVECACHE_LOCK_STATISTICS for information about the structure and use of this view.In addition to the members mentioned in M_LIVECACHE_LOCK_STATISTICS, this view also contains a timestamp field RESET_TIME, which indicates the last time the data was reset.

2.101 M_LIVECACHE_OMS_VERSIONS

Detailed information on the OMS versions that currently exists

Full description

Status information is shown for each OMS version that currently exists.

CautionThis view can only be used if liveCache is enabled.

Structure

Column name Data type Unit Description

HOST VARCHAR(64) Host name

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 553

Page 554: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

PORT INTEGER Internal port

VERSION_ID VARCHAR(22) ID of the OMS version

CREATE_DATE TIMESTAMP Timestamp of the creation of the OMS version

LAST_OPEN_DATE TIMESTAMP Timestamp, when the OMS version was opened last

IS_OPEN VARCHAR(5) Boolean Flag indicating whether the version is currently open: 'TRUE', 'FALSE'

HEAP_USAGE BIGINT Memory that is currently used by the version

VERSION_DESCRIPTION NVARCHAR(512) Description

2.102 M_LIVECACHE_PROCEDURE_STATISTICS

LiveCache procedure statisticsThis view has a resettable counterpart. This means, you can also see the values since the last reset in the dependent view M_LIVECACHE_PROCEDURE_STATISTICS_RESET. To reset the values, use the SQL command: ALTER SYSTEM RESET MONITORING VIEW SYS.M_LIVECACHE_PROCEDURE_STATISTICS_RESET or the management console command: monitor reset -n M_LIVECACHE_PROCEDURE_STATISTICS_RESET

Full description

For each liveCache procedure, which has been called already since the last restart, statistics are shown.

CautionThis view can only be used if liveCache is enabled.

554P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 555: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Structure

Column name Data type Unit Description

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

OBJECT_NAME VARCHAR(128) Object name

METHOD_NAME VARCHAR(128) Method name

CALL_COUNT BIGINT Counter Number of calls of the procedure

SUM_RUN_TIME BIGINT Microsecond Sum runtime of the procedure

MAX_RUN_TIME BIGINT Microsecond Max runtime of the procedure

MIN_RUN_TIME BIGINT Microsecond Min runtime of the procedure

AVERAGE_RUN_TIME BIGINT Microsecond Average runtime of the procedure

DEREF_COUNT BIGINT Counter Number of OID derefs

DEREF_BASE_COUNT BIGINT Counter Number of OID derefs against basis

DEREF_BASE_IN_VERSION_COUNT

BIGINT Counter Number of OID derefs against basis from within an OMS version

DEREF_KEYED_OBJECT_COUNT

BIGINT Counter Number of key derefs

DEREF_KEYED_OBJECT_BASE_COUNT

BIGINT Counter Number of key derefs against basis

DEREF_KEYED_OBJECT_BASE_IN_VERSION_COUNT

BIGINT Counter Number of key derefs against basis from within an OMS version

ITER_BASE_COUNT BIGINT Counter Number of objects read via an OID-iterator from the basis

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 555

Page 556: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

ITER_KEYED_OBJECT_BASE_COUNT

BIGINT Counter Number of objects read via a key-iterator from the basis

ITER_BASE_IN_VERSION_COUNT

BIGINT Counter Number of objects read via an OID-iterator from the basis from within an OMS version

ITER_IN_VERSION_COUNT

BIGINT Counter Number of objects, created in an OMS-version, read via an OID-iterator

ITER_KEYED_OBJECT_BASE_IN_VERSION_COUNT

BIGINT Counter Number of objects read via an OID-iterator from the basis from within an OMS version

ITER_KEYED_OBJECT_IN_VERSION_COUNT

BIGINT Counter Number of objects, created in an OMS version, read via a key-iterator

DEREF_VAR_OBJECT_COUNT

BIGINT Counter Number of derefs of var objects

DEREF_VAR_OBJECT_BASE_COUNT

BIGINT Counter Number of derefs of var objects against basis

DEREF_VAR_OBJECT_BASE_SIZE

BIGINT Byte Accumulated size of var objects read from the basis

DEREF_VAR_OBJECT_BASE_IN_VERSION_COUNT

BIGINT Counter Number of derefs of var objects against basis from within an OMS version

DEREF_VAR_OBJECT_BASE_IN_VERSION_SIZE

BIGINT Byte Accumulated size of var objects read from the basis from within an OMS version

NEW_OBJECT_COUNT BIGINT Counter Number of newly created standard objects

NEW_KEYED_OBJECT_COUNT

BIGINT Counter Number of newly created keyed objects

556P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 557: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

NEW_VAR_OBJECT_COUNT

BIGINT Counter Number of newly created var objects

NEW_OBJECT_IN_VERSION_COUNT

BIGINT Counter Number of newly created standard objects in an OMS version

NEW_KEYED_OBJECT_IN_VERSION_COUNT

BIGINT Counter Number of newly created keyed objects in an OMS version

NEW_VAR_OBJECT_IN_VERSION_COUNT

BIGINT Counter Number of newly created var objects in an OMS version

STORE_COUNT BIGINT Counter Number of store calls on standard objects

STORE_IN_VERSION_COUNT

BIGINT Counter Number of store calls on standard objects in an OMS versino

STORE_KEYED_OBJECT_COUNT

BIGINT Counter Number of store calls on keyed objects

STORE_KEYED_OBJECT_IN_VERSION_COUNT

BIGINT Counter Number of store calls on keyed objects in an OMS version

STORE_VAR_OBJECT_COUNT

BIGINT Counter Number of store calls on var objects

STORE_VAR_OBJECT_SIZE

BIGINT Byte Accumulated size of store calls on var objects

STORE_VAR_OBJECT_IN_VERSION_COUNT

BIGINT Counter Number of store calls on var objects in an OMS version

STORE_VAR_OBJECT_IN_VERSION_SIZE

BIGINT Byte Accumulated size of store calls on var objects in an OMS version

STORE_BASE_COUNT BIGINT Counter Number of updates of standard objects in the basis

STORE_KEYED_OBJECT_BASE_COUNT

BIGINT Counter Number of updates of keyed objects in the basis

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 557

Page 558: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

STORE_VAR_OBJECT_BASE_COUNT

BIGINT Counter Number of updates of var objects in the basis

STORE_VAR_OBJECT_BASE_SIZE

BIGINT Byte Accumulated sizes of updated objects in the basis

DELETE_COUNT BIGINT Counter Number of delete calls on standard objects

DELETE_KEYED_OBJECT_COUNT

BIGINT Counter Number of delete calls on keyed objects

DELETE_VAR_OBJECT_COUNT

BIGINT Counter Number of delete calls on var objects

DELETE_IN_VERSION_COUNT

BIGINT Counter Number of delete calls on standard objects in an OMS version

DELETE_KEYED_OBJECT_IN_VERSION_COUNT

BIGINT Counter Number of delete calls on keyed objects in an OMS version

DELETE_VAR_OBJECT_IN_VERSION_COUNT

BIGINT Counter Number of delete calls on var objects in an OMS version

DELETE_BASE_COUNT BIGINT Counter Number of deleted standard objects in the basis

DELETE_KEYED_OBJECT_BASE_COUNT

BIGINT Counter Number of deleted keyed objects in the basis

DELETE_VAR_OBJECT_BASE_COUNT

BIGINT Counter Number of deleted var objects in the basis

LOCK_EXCLUSIVE_BASE_COUNT

BIGINT Counter Number of exclusive lock requests on standard objects in the basis

LOCK_SHARE_BASE_COUNT

BIGINT Counter Number of share lock reqeusts on standard objects in the basis

LOCK_EXCLUSIVE_KEYED_OBJECT_BASE_COUNT

BIGINT Counter Number of exclusive lock requests on keyed objects in the basis

558P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 559: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

LOCK_SHARE_KEYED_OBJECT_BASE_COUNT

BIGINT Counter Number of share lock reqeusts on keyed objects in the basis

LOCK_EXCLUSIVE_VAR_OBJECT_BASE_COUNT

BIGINT Counter Number of exclusive lock requests on var objects in the basis

LOCK_SHARE_VAR_OBJECT_BASE_COUNT

BIGINT Counter Number of share lock reqeusts on var objects in the basis

RELEASE_CALLED_COUNT

BIGINT Counter Number of OMS release calls

RELEASE_EXECUTED_COUNT

BIGINT Counter Number of released standard objects

RELEASE_EXECUTED_KEYED_OBJECT_COUNT

BIGINT Counter Number of releases keyed objects

RELEASE_EXECUTED_VAR_OBJECT_COUNT

BIGINT Counter Number of releases var objects

HISTORY_HOP_COUNT BIGINT Counter Number of hops in the history chain during deref

ITER_HISTORY_HOP_COUNT

BIGINT Counter Number of hops in the history chain during iteration

EXCEPTION_COUNT BIGINT Counter Number of dbp-exceptions thrown

OUT_OF_DATE_EXCEPTION_COUNT

BIGINT Counter Number of out-of-date-exceptions thrown

OUT_OF_MEMORY_EXCEPTION_COUNT

BIGINT Counter Number of out-of-memory-exceptions thrown

TIMEOUT_EXCEPTION_COUNT

BIGINT Counter Number of timeout-exceptions thrown

OMS_TERMINATE_COUNT

BIGINT Counter Number of OMS terminate calls

SUBTRANSACTION_ROLLBACK_COUNT

BIGINT Counter Number of rolled back sub-transactions

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 559

Page 560: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

SUBTRANSACTION_COMMIT_COUNT

BIGINT Counter Number of committed sub-transactions

MAX_SUBTRANSACTION_LEVEL

BIGINT Counter Maximal subtransaction level

NEW_CONSISTENT_VIEW_COUNT

BIGINT Counter Number of new-consistent-view calls with objects

AVERAGE_NEW_CONSISTENT_VIEW_WAIT_TIME

BIGINT Second Average wait time of new-consistent-view calls with objects

NEW_CONSISTENT_VIEW_MAX_WAIT_TIME

BIGINT Second Maximal wait time of new-consistent-view calls with objects

KEY_CACHE_HIT_COUNT BIGINT Counter Number of cache hits in the key-cache

KEY_MISS_CACHE_HIT_COUNT

BIGINT Counter Number of cache hits in the key-miss-cache

DEREF_VERSION_KEYED_OBJECT_COUNT

BIGINT Counter Number of key-derefs in an OMS version on objects created in this version

OMS_REHASH_COUNT BIGINT Counter Number of rehashes of the OMS-object-hash

AVERAGE_HASH_CHAIN_SEARCH_LENGTH

BIGINT Microsecond Average search length on the hash-chains of the OMS-object-hash

MAX_HASH_CHAIN_LENGTH

BIGINT Counter Maximum length of a hash-chain of the OMS-object-hash

VERSION_CREATE_COUNT

BIGINT Counter Number of created OMS versions

VERSION_OPEN_COUNT BIGINT Counter Number of open-version calls

VERSION_CLOSE_COUNT BIGINT Counter Number of close-version calls

560P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 561: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

VERSION_DROP_COUNT BIGINT Counter Number of dropped OMS versions

USER_ALLOC_COUNT BIGINT Counter Number of allocations via a user allocator

USER_MAX_CHUNK_ALLOCATED_SIZE

BIGINT Byte Max size of an chunk allocated via a user allocator

USER_MIN_CHUNK_ALLOCATED_SIZE

BIGINT Byte Min size of an chunk allocated via a user allocator

USER_AVERAGE_CHUNK_ALLOCATED_SIZE

BIGINT Microsecond Average size of an chunk allocated via a user allocator

USER_DELETE_COUNT BIGINT Counter Number of deallocations via a user allocator

USER_MAX_CHUNK_DELETED_SIZE

BIGINT Byte Max size of an chunk deallocated via a user allocator

USER_MIN_CHUNK_DELETED_SIZE

BIGINT Byte Min size of an chunk deallocated via a user allocator

USER_AVERAGE_CHUNK_DELETED_SIZE

BIGINT Microsecond Average size of an chunk deallocated via a user allocator

USER_DELTA_MAX_SIZE BIGINT Byte Maximal difference between allocation and deallocation on a user allocator during the execution of a method

OMS_ALLOC_COUNT BIGINT Counter Number of allocations via an OMS internal allocator

OMS_MAX_CHUNK_ALLOCATED_SIZE

BIGINT Byte Max size of an chunk allocated via an OMS internal allocator

OMS_MIN_CHUNK_ALLOCATED_SIZE

BIGINT Byte Min size of an chunk allocated via an OMS internal allocator

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 561

Page 562: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

OMS_AVERAGE_CHUNK_ALLOCATED_SIZE

BIGINT Microsecond Average size of an chunk allocated via an OMS internal allocator

OMS_DELETE_COUNT BIGINT Counter Number of deallocations via an OMS internal allocator

OMS_MAX_CHUNK_DELETED_SIZE

BIGINT Byte Max size of an chunk deallocated via an OMS internal allocator

OMS_MIN_CHUNK_DELETED_SIZE

BIGINT Byte Min size of an chunk deallocated via an OMS internal allocator

OMS_AVERAGE_CHUNK_DELETED_SIZE

BIGINT Byte Average size of an chunk deallocated via an OMS internal allocator

OMS_DELTA_MAX_SIZE BIGINT Byte Maximum difference between allocation and deallocation on an OMS internal allocator during the execution of a method

STREAM_COMMUNICATION_TIME

BIGINT Microsecond Average stream communication time

STREAM_READ_COUNT BIGINT Counter Number of communications for reading ABAP tables

STREAM_WRITE_COUNT BIGINT Counter Number of communications for writing ABAP tables

STREAM_READ_ROW_COUNT

BIGINT Counter Number of rows read from ABAP tables

STREAM_WRITE_ROW_COUNT

BIGINT Counter Number of rows written to ABAP tables

562P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 563: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

2.103 M_LIVECACHE_PROCEDURE_STATISTICS_RESET

LiveCache procedure statistics (since last reset)This view contains values accumulated since the last reset of the main view M_LIVECACHE_PROCEDURE_STATISTICS. Please refer to M_LIVECACHE_PROCEDURE_STATISTICS for information about the structure and use of this view.In addition to the members mentioned in M_LIVECACHE_PROCEDURE_STATISTICS, this view also contains a timestamp field RESET_TIME, which indicates the last time the data was reset.

2.104 M_LIVECACHE_SCHEMA_STATISTICS

LiveCache schema statisticsThis view has a resettable counterpart. This means, you can also see the values since the last reset in the dependent view M_LIVECACHE_SCHEMA_STATISTICS_RESET. To reset the values, use the SQL command: ALTER SYSTEM RESET MONITORING VIEW SYS.M_LIVECACHE_SCHEMA_STATISTICS_RESET or the management console command: monitor reset -n M_LIVECACHE_SCHEMA_STATISTICS_RESET

Structure

Column name Data type Description

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

OMS_SCHEMA_HANDLE INTEGER OMS schema ID

OMS_SCHEMA_NAME NVARCHAR(96) OMS schema name

CREATE_TIME TIMESTAMP Create timestamp

2.105 M_LIVECACHE_SCHEMA_STATISTICS_RESET

LiveCache schema statistics (since last reset)This view contains values accumulated since the last reset of the main view M_LIVECACHE_SCHEMA_STATISTICS. Please refer to M_LIVECACHE_SCHEMA_STATISTICS for information about the structure and use of this view.In addition to the members mentioned in M_LIVECACHE_SCHEMA_STATISTICS, this view also contains a timestamp field RESET_TIME, which indicates the last time the data was reset.

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 563

Page 564: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

2.106 M_LOCK_WAITS_STATISTICS

Accumulated lock wait count and duration for record lock, table lock and metadata lock for all available services from DB startup until now

Structure

Column name Data type Description

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

LOCK_TYPE VARCHAR(32) Lock type: RECORD, TABLE, METADATA

TOTAL_LOCK_WAITS BIGINT Total lock wait count

TOTAL_LOCK_WAIT_TIME BIGINT Total lock wait duration (unit: micro second)

2.107 M_LOG_BUFFERS

Log buffer statisticsThis view has a resettable counterpart. This means, you can also see the values since the last reset in the dependent view M_LOG_BUFFERS_RESET. To reset the values, use the SQL command: ALTER SYSTEM RESET MONITORING VIEW SYS.M_LOG_BUFFERS_RESET or the management console command: monitor reset -n M_LOG_BUFFERS_RESET

Full description

The current configuration of in-memory log buffers is shown in the BUFFER_SIZE and BUFFER_COUNT columns. This defines how much log information can be collected transiently in memory, before the log queue becomes full.

Counters for buffer switches indicate performance of the in-memory log buffers. Normally, buffer switching happens without any waits. In the case of buffer full, however, a wait is necessary. Then, SWITCH_WAIT_COUNT is incremented, otherwise SWITCH_NOWAIT_COUNT is incremented. If the wait ratio is higher than one percent, this indicates a possible misconfiguration of the system. In this case:

● check if regular peaks exceed current log buffer configuration and if so, increase log buffer size and/or count● check if the I/O subsystem is performing poorly (see also M_VOLUME_IO_TOTAL_STATISTICS).

564P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 565: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Due to the lock-free nature of the algorithm used, some race conditions can happen. These are properly detected and resolved. Additionally, a count of such races is recorded in SWITCH_OPEN_COUNT. Normally, the ratio of races to buffer switches should also be under one percent even for high workloads.

M_LOG_PARTITIONS, M_LOG_SEGMENTS, M_VOLUME_IO_TOTAL_STATISTICS

Structure

Column name Data type Unit Description

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

VOLUME_ID INTEGER Persistence Volume ID

LOG_MODE VARCHAR(16) Log mode

BUFFER_SIZE BIGINT Kilobyte Size of one log buffer in memory

BUFFER_COUNT BIGINT Counter Count of log buffers in memory

SEGMENT_SIZE BIGINT Megabyte Maximum size of one log segment

BACKUP_ENABLED VARCHAR(5) Log segment backup enabled: 'TRUE', 'FALSE' ('FALSE' on log backup history broken)

BACKUP_TIMEOUT BIGINT Second Log segment backup timeout

SWITCH_NOWAIT_COUNT

BIGINT Counter Count of buffer switches without blocking on buffer semaphore

SWITCH_WAIT_COUNT BIGINT Counter Count of buffer switches with blocking on buffer semaphore

SWITCH_OPEN_COUNT BIGINT Counter Count of ignored still-open buffer switches (resolved races)

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 565

Page 566: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

2.108 M_LOG_BUFFERS_RESET

Log buffer statistics (since last reset)This view contains values accumulated since the last reset of the main view M_LOG_BUFFERS. Please refer to M_LOG_BUFFERS for information about the structure and use of this view.In addition to the members mentioned in M_LOG_BUFFERS, this view also contains a timestamp field RESET_TIME, which indicates the last time the data was reset.

2.109 M_LOG_PARTITIONS

Log partition statisticsThis view has a resettable counterpart. This means, you can also see the values since the last reset in the dependent view M_LOG_PARTITIONS_RESET. To reset the values, use the SQL command: ALTER SYSTEM RESET MONITORING VIEW SYS.M_LOG_PARTITIONS_RESET or the management console command: monitor reset -n M_LOG_PARTITIONS_RESET

Full description

This view collects various performance statistics for each log partition. The collected statistics can be used to optimize workload.

M_LOG_BUFFERS, M_LOG_SEGMENTS, M_VOLUME_IO_TOTAL_STATISTICS

Structure

Column name Data type Unit Description

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

VOLUME_ID INTEGER Persistence Volume ID

PARTITION_ID BIGINT Log partition ID

PATH VARCHAR(512) Log partition root path

LAST_BUFFER_PREPARE_SIZE

BIGINT Byte Size of log buffer at prepare time (actual log data size) (last)

566P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 567: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

MAX_BUFFER_PREPARE_SIZE

BIGINT Byte Size of log buffer at prepare time (actual log data size) (max)

MIN_BUFFER_PREPARE_SIZE

BIGINT Byte Size of log buffer at prepare time (actual log data size) (min)

SUM_BUFFER_PREPARE_SIZE

BIGINT Byte Size of log buffer at prepare time (actual log data size) (total)

AVG_BUFFER_PREPARE_SIZE

BIGINT Byte Size of log buffer at prepare time (actual log data size) (avg)

LAST_BUFFER_OVERHEAD_SIZE

BIGINT Byte Size of log buffer alignment overhead at I/O time (last)

MAX_BUFFER_OVERHEAD_SIZE

BIGINT Byte Size of log buffer alignment overhead at I/O time (max)

MIN_BUFFER_OVERHEAD_SIZE

BIGINT Byte Size of log buffer alignment overhead at I/O time (min)

SUM_BUFFER_OVERHEAD_SIZE

BIGINT Byte Size of log buffer alignment overhead at I/O time (total)

AVG_BUFFER_OVERHEAD_SIZE

BIGINT Byte Size of log buffer alignment overhead at I/O time (avg)

LAST_BUFFER_IO_SIZE BIGINT Byte Size of log buffer at I/O time (actual data plus alignment overhead) (last)

MAX_BUFFER_IO_SIZE BIGINT Byte Size of log buffer at I/O time (actual data plus alignment overhead) (max)

MIN_BUFFER_IO_SIZE BIGINT Byte Size of log buffer at I/O time (actual data plus alignment overhead) (min)

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 567

Page 568: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

SUM_BUFFER_IO_SIZE BIGINT Byte Size of log buffer at I/O time (actual data plus alignment overhead) (total)

AVG_BUFFER_IO_SIZE BIGINT Byte Size of log buffer at I/O time (actual data plus alignment overhead) (avg)

LAST_GROUP_COMMIT_FREQUENCY

BIGINT Counter Group commit frequency (callback count per buffer with sync callback) (last)

MAX_GROUP_COMMIT_FREQUENCY

BIGINT Counter Group commit frequency (callback count per buffer with sync callback) (max)

MIN_GROUP_COMMIT_FREQUENCY

BIGINT Counter Group commit frequency (callback count per buffer with sync callback) (min)

SUM_GROUP_COMMIT_FREQUENCY

BIGINT Counter Group commit frequency (callback count per buffer with sync callback) (total)

AVG_GROUP_COMMIT_FREQUENCY

BIGINT Counter Group commit frequency (callback count per buffer with sync callback) (avg)

LAST_CALLBACK_TIME BIGINT Microsecond Callback time per buffer with sync callback (last)

MAX_CALLBACK_TIME BIGINT Microsecond Callback time per buffer with sync callback (max)

MIN_CALLBACK_TIME BIGINT Microsecond Callback time per buffer with sync callback (min)

SUM_CALLBACK_TIME BIGINT Microsecond Callback time per buffer with sync callback (total)

AVG_CALLBACK_TIME BIGINT Microsecond Callback time per buffer with sync callback (avg)

PREPARED_BUFFERS BIGINT Counter Count of buffers prepared for I/O

WRITTEN_BUFFERS BIGINT Counter Count of completed and written buffers

568P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 569: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

WRITTEN_BUFFERS_OOO BIGINT Counter Count of buffers written out-of-order

NEW_SEGMENT_REQUEST_COUNT

BIGINT Counter Count of new log segment requests

FREE_SEGMENTS BIGINT Counter Count of currently free log segments

IN_BACKUP_SEGMENTS BIGINT Counter Count of currently in-backup log segments

IN_BACKUP_TRUNCATED_SEGMENTS

BIGINT Counter Count of currently in-backup truncated log segments

BACKED_UP_SEGMENTS BIGINT Counter Count of log segments backed up so far

TOTAL_SEGMENTS BIGINT Counter Total log segment count in the partition

RECOVERY_SEGMENTS_IN_LOAD

BIGINT Counter Count of segments in-load during recovery

RECOVERY_SEGMENTS_WAITING_FOR_LOAD

BIGINT Counter Count of segments waiting for load during recovery

RECOVERY_SEGMENTS_IN_PROCESS

BIGINT Counter Count of segments in process during recovery

RECOVERY_SEGMENTS_PROCESSED

BIGINT Counter Count of segments processed during recovery

2.110 M_LOG_PARTITIONS_RESET

Log partition statistics (since last reset)This view contains values accumulated since the last reset of the main view M_LOG_PARTITIONS. Please refer to M_LOG_PARTITIONS for information about the structure and use of this view.In addition to the members mentioned in M_LOG_PARTITIONS, this view also contains a timestamp field RESET_TIME, which indicates the last time the data was reset.

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 569

Page 570: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

2.111 M_LOG_SEGMENTS

Log segment statisticsThis view has a resettable counterpart. This means, you can also see the values since the last reset in the dependent view M_LOG_SEGMENTS_RESET. To reset the values, use the SQL command: ALTER SYSTEM RESET MONITORING VIEW SYS.M_LOG_SEGMENTS_RESET or the management console command: monitor reset -n M_LOG_SEGMENTS_RESET

Full description

This view describes each allocated log segment and shows its current state and log position range, which is currently contained in this segment.

The following log segment states exist:

● Formatting - The log segment is being formatted and not yet used.● Preallocated - The log segment has been preallocated, but never used.● Writing - The log segment is currently being written.● Closed - The log segment is closed, not backed up and is still required for restart.● Truncated - The log segment is not required for restart, but has not been backed up.● BackedUp - The log segment has been backed up, but is still required for restart.● Free - The log segment has been backed up, it is not required for restart and can be reused.

In case you are using log_mode = legacy, you must execute a data backup in order to release log files for reuse (log segments will stay in the state Closed or BackedUp until the backup is done). After a data backup, empty log files can be freed explicitly after backup using the ALTER SYSTEM RECLAIM LOG SQL command. This command can also be used in other log modes after a savepoint to release empty log files freed by the savepoint.

M_LOG_BUFFERS, M_LOG_PARTITIONS, M_VOLUME_IO_TOTAL_STATISTICS

Structure

Column name Data type Unit Description

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

VOLUME_ID INTEGER Persistence Volume ID

PARTITION_ID BIGINT Log partition ID

SEGMENT_ID BIGINT Log segment ID within partition

570P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 571: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

FILE_NAME VARCHAR(512) Log segment file name

FILE_OFFSET BIGINT Byte Start position of log segment in the file

STATE VARCHAR(16) Log segment state

MIN_POSITION BIGINT First position contained in this log segment

MAX_POSITION BIGINT Position behind the last log record in this log segment (closed log segments only)

HOLE_POSITION BIGINT Start position of the log hole before this log segment (equal to min position if no hole)

USED_SIZE BIGINT Byte Used log segment size in bytes

TOTAL_SIZE BIGINT Byte Total log segment size in bytes

IN_BACKUP VARCHAR(5) Flag for log segment in backup: 'TRUE', 'FALSE'

2.112 M_LOG_SEGMENTS_RESET

Log segment statistics (since last reset)This view contains values accumulated since the last reset of the main view M_LOG_SEGMENTS. Please refer to M_LOG_SEGMENTS for information about the structure and use of this view.In addition to the members mentioned in M_LOG_SEGMENTS, this view also contains a timestamp field RESET_TIME, which indicates the last time the data was reset.

2.113 M_MEMORY_OBJECTS

Memory object statisticsThis view has a resettable counterpart. This means, you can also see the values since the last reset in the dependent view M_MEMORY_OBJECTS_RESET. To reset the values, use the SQL command: ALTER SYSTEM RESET MONITORING VIEW SYS.M_MEMORY_OBJECTS_RESET or the management console command: monitor reset -n M_MEMORY_OBJECTS_RESET

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 571

Page 572: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Full description

This view provides information about the number and size of resources currently in the resource container and about the throughput of the resource container. One row in this view represents one resource type (the type is specified by the resource statistic). The resource statistics are kept in a tree data structure and this view represents this tree in a human-readable form. Each value (except for HOST, PORT, VOLUME_ID, STATISTICS_NAME) is the AGGREGATED value of the subtree (including the current node).

Structure

Column name Data type Unit Description

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

VOLUME_ID INTEGER Persistence Volume ID

TYPE VARCHAR(128) Object (statistic) type

OBJECT_COUNT BIGINT Counter Number of objects currently in memory object container

OBJECT_SIZE BIGINT Byte Size of objects currently in memory object container

NON_SWAPPABLE_SIZE BIGINT Byte Size of non swappable objects currently in memory object container

SWAPPABLE_SIZE BIGINT Byte Size of swappable objects currently in memory object container

PUT_COUNT BIGINT Counter Total number of put objects

PUT_SIZE BIGINT Byte Total size of put objects

EVICT_COUNT BIGINT Counter Total number of evicted objects

EVICT_SIZE BIGINT Byte Total size of evicted objects

572P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 573: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

TEMP_EVICT_COUNT BIGINT Counter Total number of temp-evicted objects

TEMP_EVICT_SIZE BIGINT Byte Total size of temp-evicted objects

RESIZE_COUNT BIGINT Counter Total number of resizes

RESIZE_DELTA_SIZE BIGINT Byte Total size delta changed by resize of objects

SHRINK_COUNT BIGINT Counter Total number of shrunk objects

SHRINK_SIZE BIGINT Byte Total size of shrunk objects

FAILED_SHRINK_COUNT BIGINT Counter Total number of objects shrink failed to remove

FAILED_SHRINK_SIZE BIGINT Byte Total size of objects shrink failed to remove

2.114 M_MEMORY_OBJECTS_RESET

Memory object statistics (since last reset)This view contains values accumulated since the last reset of the main view M_MEMORY_OBJECTS. Please refer to M_MEMORY_OBJECTS for information about the structure and use of this view.In addition to the members mentioned in M_MEMORY_OBJECTS, this view also contains a timestamp field RESET_TIME, which indicates the last time the data was reset.

2.115 M_MEMORY_OBJECT_DISPOSITIONS

Disposition specific memory object statistics. The statistics are calculated and reading them may take a while.

Full description

The number and the size of resources in the resource container are shown depending on their specific disposition (whether the memory objects are short, mid, long-term or non-swappable). For each type of resource (specified by the resource statistic), which is currently in the resource container, one row is added to this view. The tree structure of the resource statistics is not considered here, therefore the values are not aggregated.

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 573

Page 574: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Caution: Reading this view may take some time as the entire resource container must be traversed to generate this view.

Structure

Column name Data type Unit Description

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

VOLUME_ID INTEGER Persistence Volume ID

TYPE VARCHAR(128) Object (statistic) type)

TEMPORARY_OBJECT_COUNT

BIGINT Counter Number of temporary objects

EARLY_UNLOAD_OBJECT_COUNT

BIGINT Counter Number of early unload objects

INTERNAL_SHORT_TERM_OBJECT_COUNT

BIGINT Counter Number of internal short term objects

SHORT_TERM_OBJECT_COUNT

BIGINT Counter Number of short term objects

MID_TERM_OBJECT_COUNT

BIGINT Counter Number of mid term objects

LONG_TERM_OBJECT_COUNT

BIGINT Counter Number of long term objects

NON_SWAPPABLE_OBJECT_COUNT

BIGINT Counter Number of non swappable objects

TEMPORARY_OBJECT_SIZE

BIGINT Byte Size of temporary objects

EARLY_UNLOAD_OBJECT_SIZE

BIGINT Byte Size of early unload objects

INTERNAL_SHORT_TERM_OBJECT_SIZE

BIGINT Byte Size of internal short term objects

SHORT_TERM_OBJECT_SIZE

BIGINT Byte Size of short term objects

MID_TERM_OBJECT_SIZE BIGINT Byte Size of mid term objects

574P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 575: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

LONG_TERM_OBJECT_SIZE

BIGINT Byte Size of long term objects

NON_SWAPPABLE_OBJECT_SIZE

BIGINT Byte Size of non swappable objects

2.116 M_MERGED_TRACES

Contains the merged content of the server trace files for all of the SAP HANA processes

Structure

Column name Data type Unit Description

HOST VARCHAR(64) Host on which server process ran

PORT INTEGER Communication port of server process

USER_NAME NVARCHAR(256) Database user

APPLICATION_USER_NAME

NVARCHAR(256) Application user

SERVICE_NAME VARCHAR(256) Name of server process

CONNECTION_ID INTEGER Connection ID

TRANSACTION_ID INTEGER Transaction ID

UPDATE_TRANSACTION_ID

BIGINT Update transaction ID

THREAD_ID BIGINT ID of thread that wrote trace entry

TIMESTAMP TIMESTAMP Time when trace entry was written

TRACE_LEVEL VARCHAR(16) Trace level

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 575

Page 576: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

COMPONENT VARCHAR(16) Trace component

SOURCE_FILE_NAME VARCHAR(512) Source file which contains trace

SOURCE_FILE_LINE BIGINT Source file line

TRACE_TEXT NCLOB Traced text

TRACE_FILE_NAME VARCHAR(256) Name of trace file containing trace entry

TRACE_FILE_LINE INTEGER Trace file line

PASSPORT_ROOT_CONTEXT_ID

VARCHAR(32) Guid SAP EPP Passport GUID identifying source of request

PASSPORT_TRANSACTION_ID

VARCHAR(32) SAP EPP Passport GUID identifying business transaction

PASSPORT_CONNECTION_ID

VARCHAR(32) Guid SAP EPP Passport GUID identifying connection

PASSPORT_CONNECTION_COUNTER

BIGINT SAP EPP Passport connection counter

PASSPORT_COMPONENT_NAME

NVARCHAR(32) SAP EPP Passport component name of initial/root context

PASSPORT_ACTION NVARCHAR(40) SAP EPP Passport action

2.117 M_MONITORS

Available monitoring views

Full description

This view can be used in conjunction with M_MONITOR_COLUMNS to get information about existing monitoring views.

M_MONITOR_COLUMNS

576P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 577: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Structure

Column name Data type Description

SCHEMA_NAME NVARCHAR(256) Schema name

VIEW_NAME NVARCHAR(256) Name of monitoring view

DESCRIPTION NVARCHAR(2000) Short description of the monitoring view

RESETTABLE VARCHAR(5) Set to TRUE, if values of this monitor can be reset

2.118 M_MONITOR_COLUMNS

All the columns in the monitoring views

Full description

This view can be used in conjunction with M_MONITORS to get information about existing monitoring views.

M_MONITORS

Structure

Column name Data type Description

VIEW_NAME NVARCHAR(256) Name of monitoring view

VIEW_COLUMN_NAME NVARCHAR(256) Name of monitoring view column

DATA_TYPE_ID SMALLINT Column data type ID

DATA_TYPE_NAME VARCHAR(16) Column data type name

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 577

Page 578: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Description

POSITION INTEGER Ordinal position of the column in a record

DEFAULT_VALUE NVARCHAR(5000) Default value

UNIT VARCHAR(16) Unit for the value

COLLATION NVARCHAR(256) Collation

LENGTH INTEGER Length

SCALE INTEGER Scale

IS_NULLABLE VARCHAR(5) TRUE, if NULL value is allowed

DESCRIPTION NVARCHAR(5000) Short description of the monitoring view column

2.119 M_MUTEXES

Mutex statisticsThis view has a resettable counterpart. This means, you can also see the values since the last reset in the dependent view M_MUTEXES_RESET. To reset the values, use the SQL command: ALTER SYSTEM RESET MONITORING VIEW SYS.M_MUTEXES_RESET or the management console command: monitor reset -n M_MUTEXES_RESET

Full description

This view contains information about single mutex (mutual exclusion) objects or groups of mutex objects. It does not contain information about all mutex objects. Information like LOCK_COUNT, WAIT_COUNT and WAIT_TIMES can be used to analyze performance bottlenecks. Using OWNER_ID you can find possible deadlocks.

Structure

Column name Data type Unit Description

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

578P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 579: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

VOLUME_ID INTEGER Persistence Volume ID

STATISTICS_NAME VARCHAR(128) Statistics object name

STATISTICS_ID BIGINT Statistics object unique ID

LOCK_COUNT BIGINT Counter Count of lock calls

WAIT_COUNT BIGINT Counter Count of blocking lock calls

SPURIOUS_WAKEUP_COUNT

BIGINT Counter Count of spurious wakeups (collisions on futex)

COLLISION_RATE DOUBLE Percent Collision rate in percent

OWNER_ID BIGINT Context ID of the owner context

LAST_WAIT_TIME BIGINT Microsecond Time of blocking lock calls (last)

MAX_WAIT_TIME BIGINT Microsecond Time of blocking lock calls (max)

MIN_WAIT_TIME BIGINT Microsecond Time of blocking lock calls (min)

SUM_WAIT_TIME BIGINT Microsecond Time of blocking lock calls (total)

AVG_WAIT_TIME BIGINT Microsecond Time of blocking lock calls (avg)

CREATE_COUNT BIGINT Counter Count of mutex creation (for shared statistics only)

DESTROY_COUNT BIGINT Counter Count of mutex destruction (for shared statistics only)

2.120 M_MUTEXES_RESET

Mutex statistics (since last reset)This view contains values accumulated since the last reset of the main view M_MUTEXES. Please refer to M_MUTEXES for information about the structure and use of this view.In addition to

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 579

Page 580: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

the members mentioned in M_MUTEXES, this view also contains a timestamp field RESET_TIME, which indicates the last time the data was reset.

2.121 M_MVCC_TABLES

Statistics of row-store Multiversion Concurrency Control (MVCC) manager

Structure

Column name Data type Description

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

NAME VARCHAR(256) Name column

VALUE VARCHAR(128) Value column

2.122 M_OBJECT_LOCKS

Status of currently acquired locks on objects with detailed information such as lock acquisition time, lock mode

Structure

Column name Data type Description

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

LOCK_OWNER_TRANSACTION_ID INTEGER Transaction object ID owning the lock

LOCK_OWNER_UPDATE_TRANSACTION_ID

BIGINT Write transaction ID owning the lock

580P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 581: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Description

ACQUIRED_TIME TIMESTAMP Lock acquisition time

SCHEMA_NAME NVARCHAR(256) Schema name

OBJECT_NAME NVARCHAR(256) Object name

OBJECT_TYPE VARCHAR(32) Object type

LOCK_MODE VARCHAR(32) Lock mode: EXCLUSIVE, INTENTIONAL EXCLUSIVE

2.123 M_OBJECT_LOCK_STATISTICS

Lock contention statistics - lock wait count, wait time, failed count for each objectsThis view has a resettable counterpart. This means, you can also see the values since the last reset in the dependent view M_OBJECT_LOCK_STATISTICS_RESET. To reset the values, use the SQL command: ALTER SYSTEM RESET MONITORING VIEW SYS.M_OBJECT_LOCK_STATISTICS_RESET or the management console command: monitor reset -n M_OBJECT_LOCK_STATISTICS_RESET

Structure

Column name Data type Description

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

OBJECT_TYPE VARCHAR(32) Object Type: RECORD, TABLE, VIEW, SYNONYM, SEQUENCE..

SCHEMA_NAME NVARCHAR(256) Schema name that the Object belongs to

OBJECT_NAME NVARCHAR(256) Object Name

PART_ID INTEGER Partition no. (0 for non-partitioned tables, -1 for not supported)

OBJECT_ID BIGINT Object ID

LOCK_TYPE VARCHAR(32) Lock Type: OBJECT, RECORD

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 581

Page 582: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Description

LOCK_WAIT_COUNT BIGINT Lock Wait Count

LOCK_WAIT_TIME BIGINT Lock Wait Time (unit: micro second)

LOCK_FAILED_COUNT BIGINT Lock Failed Count (only supported RECORD type lock failed count)

2.124 M_OBJECT_LOCK_STATISTICS_RESET

Lock contention statistics - lock wait count, wait time, failed count for each objects (since last reset)This view contains values accumulated since the last reset of the main view M_OBJECT_LOCK_STATISTICS. Please refer to M_OBJECT_LOCK_STATISTICS for information about the structure and use of this view.In addition to the members mentioned in M_OBJECT_LOCK_STATISTICS, this view also contains a timestamp field RESET_TIME, which indicates the last time the data was reset.

2.125 M_PAGEACCESS_STATISTICS

PageAccess statisticsThis view has a resettable counterpart. This means, you can also see the values since the last reset in the dependent view M_PAGEACCESS_STATISTICS_RESET. To reset the values, use the SQL command: ALTER SYSTEM RESET MONITORING VIEW SYS.M_PAGEACCESS_STATISTICS_RESET or the management console command: monitor reset -n M_PAGEACCESS_STATISTICS_RESET

Full description

This view contains information about pages accessed. TYPE specifies the pageaccess. The *_COUNT values are the number of the respective operations on the page access. CHUNK_SIZE is the number of pages accessed by one operation ( CHUNK_SIZE is 1 except for RowStorePageAccess where blocks of pages are accessed. For example, LOAD_COUNT=4 and CHUNK_SIZE=1024 means that 2*1024=4096 pages had been loaded). On allocation / deallocation the corresponding Converter is accessed.

M_CONVERTER_STATISTICS

582P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 583: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Structure

Column name Data type Unit Description

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

VOLUME_ID INTEGER Persistence Volume ID

TYPE VARCHAR(32) Type of pageaccess

CHUNK_SIZE INTEGER Counter Chunk size

ALLOCATE_COUNT BIGINT Counter Number of allocations

GET_COUNT BIGINT Counter Number of gets

LOAD_COUNT BIGINT Counter Number of synchronous loads

TRIGGER_LOAD_COUNT BIGINT Counter Number of asynchronous loads

DEALLOCATE_COUNT BIGINT Counter Number of deallocations

2.126 M_PAGEACCESS_STATISTICS_RESET

PageAccess statistics (since last reset)This view contains values accumulated since the last reset of the main view M_PAGEACCESS_STATISTICS. Please refer to M_PAGEACCESS_STATISTICS for information about the structure and use of this view.In addition to the members mentioned in M_PAGEACCESS_STATISTICS, this view also contains a timestamp field RESET_TIME, which indicates the last time the data was reset.

2.127 M_PASSWORD_POLICY

Effective password policy settings

Full description

This view contains several lines of information about the current password policy. The following describes the contents of the individual lines of the monitor view (VALUE), as identified by PROPERTY:

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 583

Page 584: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

force_first_password_changeDefines if a user is forced to change his administrator-given password before being allowed to work any further

last_used_passwordsNumber of recently used passwords of a user, which they cannot reuse

maximum_invalid_connect_attemptsMaximum number of allowed invalid connect attempts before a user is locked

maximum_password_lifetimeNumber of days a password stays valid

maximum_unused_inital_password_lifetimeNumber of days an unused administrator-given password stays valid

maximum_unused_productive_password_lifetimeNumber of days an unused user-given password stays valid

minimal_password_lengthMinimum number of characters required by a valid password

minimum_password_lifetimeMinimum number of days until a user-given password can be changed

password_expire_warning_timeWarnings about nearly expired password will start to be shown at the configured number of days before expiration

password_layoutDescribes the kind(s) of character the password has to consist of

password_lock_timeNumber of minutes the user is locked after too many invalid connect attempts

Structure

Column name Data type Description

PROPERTY VARCHAR(128) Configuration property

VALUE VARCHAR(16) Value

584P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 585: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

2.128 M_PERFTRACE

Current PerfTrace state

Full description

The performance trace (PerfTrace) displays detailed information about query execution.

Performance Trace calls

Start performancetTrace. It can be restricted to a specific SQL and application user. Optionally plan execution details can be recorded. If a duration is specified it automatically stops after the configured amount of seconds.

ALTER SYSTEM START PERFTRACE [USER name] [APPLICATIONUSER name] [PLAN_EXECUTION] [FUNCTION_PROFILER] [DURATION seconds]

Stop Performance Trace

ALTER SYSTEM STOP PERFTRACE

Collect performancetTrace data and save into a file. The file is located on the server in the trace directory. If no file name is given 'perftrace.tpt' is used.

ALTER SYSTEM SAVE PERFTRACE [INTO FILE 'filename']

Structure

Column name Data type Unit Description

STATUS VARCHAR(16) Status: STOPPED, STARTED, SAVING

START_TIME TIMESTAMP Start time

STOP_TIME TIMESTAMP Stop time

FILE_SIZE BIGINT Byte Size of collected trace files. Only valid if stopped and not saved

REMAINING_SECONDS INTEGER Second Remaining seconds until automatic stop

USER_NAME NVARCHAR(256) SQL user name filter

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 585

Page 586: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

APPLICATION_USER_NAME

NVARCHAR(256) Application user name filter

APPLICATION_NAME NVARCHAR(256) Application name filter

PASSPORT_TRACELEVEL VARCHAR(8) Passport filter: 'MEDIUM', 'HIGH'

PLAN_EXECUTION VARCHAR(5) Boolean Flag if plan execution details are recorded

FUNCTION_PROFILER VARCHAR(5) Boolean Flag if function profiler details are recorded: 'TRUE', 'FALSE'

2.129 M_PERSISTENCE_ENCRYPTION_KEYS

Information about encryption page keys

Structure

Column name Data type Unit Description

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

VALID_FROM_SAVEPOINT

INTEGER HEXID Valid from savepoint version

VALID_FROM_TIMESTAMP

TIMESTAMP Microsecond Valid from timestamp given in UTC

IS_ENCRYPTED VARCHAR(5) Persistence encryption is active: 'TRUE', 'FALSE'

2.130 M_PERSISTENCE_ENCRYPTION_STATUS

Information about persistence encryption

586P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 587: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Structure

Column name Data type Unit Description

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

ENCRYPTION_ACTIVE VARCHAR(5) Encryption is currently active for writing into persistence: 'TRUE', 'FALSE'

ENCRYPTION_ACTIVE_AFTER_NEXT_SAVEPOINT

VARCHAR(5) Encryption will be active for writing into persistence after next savepoint: 'TRUE', 'FALSE'

KEY_CHANGE_WITH_NEXT_SAVEPOINT

VARCHAR(5) Next savepoint will activate a new key: 'TRUE', 'FALSE'

ROOT_KEY_CHANGE_WITH_NEXT_SAVEPOINT

VARCHAR(5) Next savepoint will activate a new root key: 'TRUE', 'FALSE'

DATA_CONVERSION_ACTIVE

VARCHAR(5) Conversion of data to latest encryption status or key active: 'TRUE', 'FALSE'

KEY_PAGE_ENTRY_COUNT

BIGINT Counter Number of entries within key page

2.131 M_PERSISTENCE_MANAGERS

Persistence manager statisticsThis view has a resettable counterpart. This means, you can also see the values since the last reset in the dependent view M_PERSISTENCE_MANAGERS_RESET. To reset the values, use the SQL command: ALTER SYSTEM RESET MONITORING VIEW SYS.M_PERSISTENCE_MANAGERS_RESET or the management console command: monitor reset -n M_PERSISTENCE_MANAGERS_RESET

Full description

Persistence manager is the module responsible for low-level operations on the persistent data structures. This view shows various statistics counters, which are used to measure the performance of those operations.

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 587

Page 588: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

M_GARBAGE_COLLECTION_STATISTICS

Structure

Column name Data type Unit Description

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

VOLUME_ID INTEGER Persistence Volume ID

MAX_TID BIGINT TID Maximum known TID

CCH_COUNT BIGINT Counter Count of normal consistent changes (terminated sessions)

MASS_CCH_COUNT BIGINT Counter Count of consistent changes for mass operations (terminated sessions)

LAST_CCH_TIME BIGINT Microsecond Time spent in normal consistent changes (terminated sessions) (last)

MAX_CCH_TIME BIGINT Microsecond Time spent in normal consistent changes (terminated sessions) (max)

MIN_CCH_TIME BIGINT Microsecond Time spent in normal consistent changes (terminated sessions) (min)

SUM_CCH_TIME BIGINT Microsecond Time spent in normal consistent changes (terminated sessions) (total)

AVG_CCH_TIME BIGINT Microsecond Time spent in normal consistent changes (terminated sessions) (avg)

588P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 589: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

LAST_MASS_CCH_TIME BIGINT Microsecond Time spent in consistent changes for mass operations (terminated sessions) (last)

MAX_MASS_CCH_TIME BIGINT Microsecond Time spent in consistent changes for mass operations (terminated sessions) (max)

MIN_MASS_CCH_TIME BIGINT Microsecond Time spent in consistent changes for mass operations (terminated sessions) (min)

SUM_MASS_CCH_TIME BIGINT Microsecond Time spent in consistent changes for mass operations (terminated sessions) (total)

AVG_MASS_CCH_TIME BIGINT Microsecond Time spent in consistent changes for mass operations (terminated sessions) (avg)

PREPARE_COMMIT_POS BIGINT Newest known log position of prepare commit (slave only)

MASTER_COMMIT_POS BIGINT Newest known log position of commit record on transaction master from the point of view of this node

INDOUBT_WAITERS BIGINT Count of in-doubt waiters for currently-running COMMIT (master only)

INDOUBT_RESTART_COUNT

BIGINT Counter Count of open in-doubt transactions before restart (master only)

INDOUBT_ONLINE_COUNT

BIGINT Counter Count of open in-doubt transactions since last restart (master only)

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 589

Page 590: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

SAVEPOINT_CONFIG_FREQUENCY

BIGINT Second Configured savepoint frequency

SAVEPOINT_ACTIVE_FREQUENCY

BIGINT Second Currently active savepoint frequency

CHECKSUM_ALGORITHM VARCHAR(16) Currently used checksum algorithm for modified pages and log buffers

2.132 M_PERSISTENCE_MANAGERS_RESET

Persistence manager statistics (since last reset)This view contains values accumulated since the last reset of the main view M_PERSISTENCE_MANAGERS. Please refer to M_PERSISTENCE_MANAGERS for information about the structure and use of this view.In addition to the members mentioned in M_PERSISTENCE_MANAGERS, this view also contains a timestamp field RESET_TIME, which indicates the last time the data was reset.

2.133 M_PLUGIN_MANIFESTS

Information about installed plugins

Structure

Column name Data type Description

PLUGIN_NAME VARCHAR(32) Plugin name

KEY VARCHAR(64) Key

VALUE VARCHAR(256) Value

2.134 M_PREPARED_STATEMENTS

Prepared statements list

590P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 591: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Structure

Column name Data type Unit Description

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

CONNECTION_ID INTEGER Connection ID

STATEMENT_ID VARCHAR(256) Prepared statement ID

START_MVCC_TIMESTAMP

BIGINT Internal MVCC timestamp of the transaction start time

COMPILED_TIME TIMESTAMP Compilation timestamp of the statement

STATEMENT_STATUS VARCHAR(128) Status of SQL statement

STATEMENT_STRING NCLOB SQL statement

ALLOCATED_MEMORY_SIZE

BIGINT Byte Current snapshot of allocated memory size for executing this statement

USED_MEMORY_SIZE BIGINT Byte Current snapshot of used memory size for executing this statement

PLAN_ID BIGINT Logical plan ID

LAST_EXECUTED_TIME TIMESTAMP Recently executed time of statement. This timestamp is updated in cases of opening cursor and executing DML/DDL. But, neither fetching results for cursor nor closing cursor update this field.

LAST_ACTION_TIME TIMESTAMP Recently performed time of action against the statement. This timestamp is updated in cases of opening cursor, executing DML/DDL,

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 591

Page 592: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

fetching results, and closing cursor.

RECOMPILE_COUNT BIGINT Recompile count

EXECUTION_COUNT BIGINT Count of executions

AVG_EXECUTION_TIME BIGINT Average time of statement execution

MAX_EXECUTION_TIME BIGINT Maximum time of statement execution

MIN_EXECUTION_TIME BIGINT Minimum time of statement execution

TOTAL_EXECUTION_TIME BIGINT Sum of statement execution time

AVG_CURSOR_DURATION

BIGINT Average time of statement execution including communication time with clients

MAX_CURSOR_DURATION

BIGINT Maximum time of statement execution including communication time with clients

MIN_CURSOR_DURATION BIGINT Minimum time of statement execution including communication time with clients

TOTAL_CURSOR_DURATION

BIGINT Sum of statement execution time including communication time with clients

AVG_EXECUTION_MEMORY_SIZE

BIGINT Average memory size used during each execution

MAX_EXECUTION_MEMORY_SIZE

BIGINT Maximum memory size used during each execution

592P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 593: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

MIN_EXECUTION_MEMORY_SIZE

BIGINT Minimum memory size used during each execution

TOTAL_EXECUTION_MEMORY_SIZE

BIGINT Sum of memory size used during each execution

AVG_LOCKWAIT_TIME BIGINT Average lock wait time for the statement

MAX_LOCKWAIT_TIME BIGINT Maximum lock wait time for the statement

MIN_LOCKWAIT_TIME BIGINT Minimum lock wait time for the statement

TOTAL_LOCKWAIT_COUNT

BIGINT Total lock wait count for the statement

TOTAL_LOCKWAIT_TIME BIGINT Accumulated lock wait time for the statement

AVG_PREPARATION_TIME

BIGINT Average time of statement preparation

MAX_PREPARATION_TIME

BIGINT Maximum time of statement preparation

MIN_PREPARATION_TIME BIGINT Minimum time of statement preparation

TOTAL_PREPARATION_TIME

BIGINT Total time of statement preparation

TOTAL_PREPARATION_COUNT

BIGINT Total count of statement preparation

HAS_HOLDABLE_CURSOR

VARCHAR(5) Holdable cursor existence

PARENT_STATEMENT_ID VARCHAR(256) Parent prepared statement ID

APPLICATION_SOURCE NVARCHAR(256) Application source information

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 593

Page 594: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

2.135 M_READWRITELOCKS

Read/Write lock statisticsThis view has a resettable counterpart. This means, you can also see the values since the last reset in the dependent view M_READWRITELOCKS_RESET. To reset the values, use the SQL command: ALTER SYSTEM RESET MONITORING VIEW SYS.M_READWRITELOCKS_RESET or the management console command: monitor reset -n M_READWRITELOCKS_RESET

Full description

This view contains information about single reader/writer lock objects or groups of reader/writer lock objects. It does not contain information about all reader/writer lock. Information like LOCK_COUNT, WAIT_COUNT and WAIT_TIMES can be used to analyze performance bottlenecks.

Structure

Column name Data type Unit Description

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

VOLUME_ID INTEGER Persistence Volume ID

STATISTICS_NAME VARCHAR(128) Statistics object name

STATISTICS_ID BIGINT Statistics object unique ID

OWNER_ID BIGINT Context ID of the owner context (for exclusive/intent locks)

EXCLUSIVE_LOCK_COUNT

BIGINT Counter Count of exclusive lock calls

EXCLUSIVE_WAIT_COUNT

BIGINT Counter Count of blocking exclusive lock calls

EXCLUSIVE_CAS_COLLISION_COUNT

BIGINT Counter Collision count on atomic operation on exclusive lock

EXCLUSIVE_COLLISION_RATE

DOUBLE Percent Collision rate on exclusive lock in percent

594P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 595: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

LAST_EXCLUSIVE_WAIT_TIME

BIGINT Microsecond Time of blocking exclusive lock calls (last)

MAX_EXCLUSIVE_WAIT_TIME

BIGINT Microsecond Time of blocking exclusive lock calls (max)

MIN_EXCLUSIVE_WAIT_TIME

BIGINT Microsecond Time of blocking exclusive lock calls (min)

SUM_EXCLUSIVE_WAIT_TIME

BIGINT Microsecond Time of blocking exclusive lock calls (total)

AVG_EXCLUSIVE_WAIT_TIME

BIGINT Microsecond Time of blocking exclusive lock calls (avg)

INTENT_LOCK_COUNT BIGINT Counter Count of intent lock calls

INTENT_WAIT_COUNT BIGINT Counter Count of blocking intent lock calls

INTENT_CAS_COLLISION_COUNT

BIGINT Counter Collision count on atomic operation on intent lock

INTENT_TIMEOUT_COUNT

BIGINT Counter Count of timed out intent lock calls

INTENT_COLLISION_RATE

DOUBLE Percent Collision rate on intent lock in percent

LAST_INTENT_WAIT_TIME

BIGINT Microsecond Time of blocking intent lock calls (last)

MAX_INTENT_WAIT_TIME BIGINT Microsecond Time of blocking intent lock calls (max)

MIN_INTENT_WAIT_TIME BIGINT Microsecond Time of blocking intent lock calls (min)

SUM_INTENT_WAIT_TIME BIGINT Microsecond Time of blocking intent lock calls (total)

AVG_INTENT_WAIT_TIME BIGINT Microsecond Time of blocking intent lock calls (avg)

SHARED_LOCK_COUNT BIGINT Counter Count of shared lock calls

SHARED_WAIT_COUNT BIGINT Counter Count of blocking shared lock calls

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 595

Page 596: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

SHARED_CAS_COLLISION_COUNT

BIGINT Counter Collision count on atomic operation on shared lock

SHARED_TIMEOUT_COUNT

BIGINT Counter Count of timed out shared lock calls

SHARED_COLLISION_RATE

DOUBLE Percent Collision rate on shared lock in percent

LAST_SHARED_WAIT_TIME

BIGINT Microsecond Time of blocking shared lock calls (last)

MAX_SHARED_WAIT_TIME

BIGINT Microsecond Time of blocking shared lock calls (max)

MIN_SHARED_WAIT_TIME

BIGINT Microsecond Time of blocking shared lock calls (min)

SUM_SHARED_WAIT_TIME

BIGINT Microsecond Time of blocking shared lock calls (total)

AVG_SHARED_WAIT_TIME

BIGINT Microsecond Time of blocking shared lock calls (avg)

COLLISION_RATE DOUBLE Percent Global collision rate

CREATE_COUNT BIGINT Counter Count of read/write lock creation (for shared statistics only)

DESTROY_COUNT BIGINT Counter Count of read/write lock destruction (for shared statistics only)

2.136 M_READWRITELOCKS_RESET

Read/Write lock statistics (since last reset)This view contains values accumulated since the last reset of the main view M_READWRITELOCKS. Please refer to M_READWRITELOCKS for information about the structure and use of this view.In addition to the members mentioned in M_READWRITELOCKS, this view also contains a timestamp field RESET_TIME, which indicates the last time the data was reset.

596P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 597: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

2.137 M_RECORD_LOCKS

Record lock status

Structure

Column name Data type Description

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

LOCK_OWNER_TRANSACTION_ID INTEGER Transaction object ID owning the lock

LOCK_OWNER_UPDATE_TRANSACTION_ID

BIGINT Write transaction ID owning the lock

ACQUIRED_TIME TIMESTAMP Lock acquisition time

RECORD_ID VARCHAR(256) Record ID

SCHEMA_NAME NVARCHAR(256) Schema name

TABLE_NAME NVARCHAR(256) Table name

LOCK_MODE VARCHAR(32) Lock mode:I (Exclusive Lock)

2.138 M_REMOTE_CONNECTIONS

Detailed information on remote connections between database and remote sources. Information includes connection status, adapter name and adapter properties

Structure

Column name Data type Unit Description

CONNECTION_ID INTEGER Connection ID

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 597

Page 598: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

REMOTE_SOURCE_NAME NVARCHAR(256) Remote source name

ADAPTER_NAME NVARCHAR(256) Adapter name

REMOTE_SOURCE_USER_NAME

NVARCHAR(256) Remote source user name

START_TIME TIMESTAMP Connected time

CONNECTION_STATUS VARCHAR(16) Connection status: CONNECTED or DISCONNECTED

DETAILS VARCHAR(512) Adapter properties

STATEMENT_COUNT BIGINT Counter Number of executed statements

2.139 M_REMOTE_STATEMENTS

Detailed information on executed remote queries. Information includes query status, number of fetched rows

Structure

Column name Data type Unit Description

CONNECTION_ID INTEGER Connection ID

TRANSACTION_ID INTEGER Transaction ID

REMOTE_SOURCE_NAME NVARCHAR(256) Remote source name

START_TIME TIMESTAMP Statement start time

END_TIME TIMESTAMP Time when the statement is closed

FETCHED_RECORD_COUNT

BIGINT Counter Number of fetched records

REMOTE_STATEMENT_STATUS

VARCHAR(16) Statement status: 'EXECUTING', 'CLOSED'

598P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 599: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

REMOTE_STATEMENT_STRING

NCLOB Statement string

2.140 M_REORG_ALGORITHMS

Landscape redistribution algorithms

Structure

Column name Data type Description

ALGORITHM_ID INTEGER ID of algorithm

DESCRIPTION VARCHAR(256) Description

PARAMETERS VARCHAR(256) Optional parameters

2.141 M_REPO_TRANSPORT_FILES

All repository transport files

Structure

Column name Data type Unit Description

HOST VARCHAR(64) Host name

FILE_NAME VARCHAR(256) File name

FILE_SIZE BIGINT Byte File size

FILE_MTIME TIMESTAMP File date

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 599

Page 600: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

2.142 M_RS_INDEXES

Statistics of B-tree and CPB-tree indexes

Structure

Column name Data type Unit Description

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

SCHEMA_NAME NVARCHAR(256) Schema name

TABLE_NAME NVARCHAR(256) Table name

INDEX_NAME NVARCHAR(256) Index name

KEY_TYPE VARCHAR(128) Key type (data type or composite)

INDEX_STATUS VARCHAR(16) Index status: 'VALID', 'INVALID', 'UNUSABLE'

TREE_HEIGHT BIGINT B-tree level

LEAF_NODE_COUNT BIGINT Number of leaf nodes

NONLEAF_NODE_COUNT BIGINT Number of intermediate nodes

NODE_SIZE BIGINT Byte Node size

FANOUT DOUBLE Index fan-out

BULKLOAD_FACTOR DOUBLE Fill factor of creating or recovering indexes

INDEX_SIZE BIGINT Byte Index size in memory = number of nodes * node size

ENTRY_COUNT BIGINT Number of indexed records

FIXED_LEAF_NODE_COUNT

BIGINT Number of fixed leaf nodes. 'FIXED' means that

600P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 601: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

the key lengths of all entries in the node have the same value

FIXED_NONLEAF_NODE_COUNT

BIGINT Number of fixed non-leaf nodes

AVG_LEAF_OFFSET_SIZE DOUBLE Average offset size of leaf nodes

AVG_NONLEAF_OFFSET_SIZE

DOUBLE Average offset size of non-leaf nodes

AVG_LEAF_POINTER_SIZE

DOUBLE Average pointer size of leaf nodes

AVG_NONLEAF_POINTER_SIZE

DOUBLE Average pointer size of non-leaf nodes

LEAF_PARTIAL_KEY_SIZE BIGINT Partial key length of leaf node

NONLEAF_PARTIAL_KEY_SIZE

BIGINT Partial key length of non-leaf node

INDEX_UTILIZATION DOUBLE Index utilization (num_entries / max_entries)

IS_UNIQUE VARCHAR(5) Information whether the index is unique: 'TRUE', 'FALSE'

SEARCH_COUNT BIGINT Number of search operations on this CPB-tree index since monitoring level was changed to 2

INSERT_COUNT BIGINT Number of insert operations on this CPB-tree index since monitoring level was changed to 2

REMOVE_COUNT BIGINT Number of remove operations on this CPB-tree index since

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 601

Page 602: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

monitoring level was changed to 2

FULL_KEY_REFERENCE_COUNT

BIGINT Number of references of full keys on this CPB-tree index since monitoring level was changed to 2. Full key references occur when keys cannot be resolved by partial keys in CPB-tree nodes

DISTINCT_KEY_COUNT BIGINT Number of distinct keys

KEY_COUNT BIGINT Number of keys

ELIMINATED_DUPLICATE_LEAF_NODE_COUNT

BIGINT Number of leaf nodes whose duplicate keys are eliminated

UNUSED_LEAF_SLOTS_PER_NODE

DOUBLE Number of unused slots per leaf node

2.143 M_RS_MEMORY

RS Memory Statistics

Structure

Column name Data type Unit Description

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

CATEGORY VARCHAR(128) Module name

ALLOCATED_SIZE BIGINT Byte Allocated memory size of the module

USED_SIZE BIGINT Byte Used memory size of the module

602P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 603: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

FREE_SIZE BIGINT Byte Free memory size of the module

2.144 M_RS_TABLES

Information on row tables: detailed table sizes and record count

Structure

Column name Data type Unit Description

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

SCHEMA_NAME NVARCHAR(256) Schema name

TABLE_NAME NVARCHAR(256) Table name

RECORD_COUNT BIGINT Number of records in this table

ALLOCATED_FIXED_PART_SIZE

BIGINT Byte Allocated memory size for fixed-size part

FIXED_PAGE_HEADER_SIZE

BIGINT Byte Allocated and used memory size for page headers of fixed-size part

FIXED_PAGE_FRAGMENT_SIZE

BIGINT Byte Fragmented memory size of fixed-size part

USED_FIXED_PART_SIZE BIGINT Byte Used memory size for fixed-size part

FIXED_PART_FRAGMENT_SIZE

BIGINT Byte Fragmented memory size of used fixed-size part

FIXED_PART_FREE_SIZE BIGINT Byte Free memory size in the pages of fixed-size part

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 603

Page 604: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

ALLOCATED_VARIABLE_PART_SIZE

BIGINT Byte Allocated memory size for variable-size part

USED_VARIABLE_PART_SIZE

BIGINT Byte Used memory size for variable-size part

VARIABLE_PART_FRAGMENT_SIZE

BIGINT Byte Fragmented memory size of used variable-size part

LOAD_STATUS VARCHAR(32) Loading state of table: 'LOADED', 'NOW_LOADING', 'PREPARING_UNLOAD', 'NOW_UNLOADING', 'UNLOADED', 'NOT_SUPPORTED'

2.145 M_RS_TABLE_VERSION_STATISTICS

Information on row table versions: detailed version counts and used sizes

Structure

Column name Data type Description

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

SCHEMA_NAME NVARCHAR(256) Name of schema to which the container belongs

TABLE_NAME NVARCHAR(256) Table name of the container

TABLE_OID BIGINT Object ID of the table

CONTAINER_ID INTEGER Some tables may have several containers to store its data. Container ID is an unique identifier of each container

IS_SYSTEM_TABLE VARCHAR(5) TRUE if the table is a system table

604P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 605: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Description

VERSION_COUNT BIGINT Number of all versions in the container. This includes all versions regardless of their version type and status.

INSERT_VERSION_COUNT BIGINT Number of insert-versions in the container

UPDATE_VERSION_COUNT BIGINT Number of update-versions in the container

DELETE_VERSION_COUNT BIGINT Number of delete-versions in the container

COMMITTED_VERSION_COUNT BIGINT Number of all committed versions in the container (includes all types)

COMMITTED_INSERT_VERSION_COUNT

BIGINT Number of committed insert-versions in the container

COMMITTED_UPDATE_VERSION_COUNT

BIGINT Number of committed update-versions in the container

COMMITTED_DELETE_VERSION_COUNT

BIGINT Number of committed delete-versions in the container

UNCOMMITTED_VERSION_COUNT BIGINT Number of all uncommitted versions in the container (includes all types)

UNCOMMITTED_INSERT_VERSION_COUNT

BIGINT Number of uncommitted insert-versions in the container

UNCOMMITTED_UPDATE_VERSION_COUNT

BIGINT Number of uncommitted update-versions in the container

UNCOMMITTED_DELETE_VERSION_COUNT

BIGINT Number of uncommitted delete-versions in the container

VERSION_SIZE BIGINT Used sized of versions in the container. This includes all versions regardless of their version type and status.

INSERT_VERSION_SIZE BIGINT Used sized of insert-versions in the container

UPDATE_VERSION_SIZE BIGINT Used sized of update-versions in the container

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 605

Page 606: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Description

DELETE_VERSION_SIZE BIGINT Used sized of delete-versions in the container

COMMITTED_VERSION_SIZE BIGINT Used sized of all committed versions in the container (includes all types)

COMMITTED_INSERT_VERSION_SIZE

BIGINT Used sized of committed insert-versions in the container

COMMITTED_UPDATE_VERSION_SIZE

BIGINT Used sized of committed update-versions in the container

COMMITTED_DELETE_VERSION_SIZE

BIGINT Used sized of committed delete-versions in the container

UNCOMMITTED_VERSION_SIZE BIGINT Used sized of all uncommitted versions in the container (includes all types)

UNCOMMITTED_INSERT_VERSION_SIZE

BIGINT Used sized of uncommitted insert-versions in the container

UNCOMMITTED_UPDATE_VERSION_SIZE

BIGINT Used sized of uncommitted update-versions in the container

UNCOMMITTED_DELETE_VERSION_SIZE

BIGINT Used sized of uncommitted delete-versions in the container

MIN_COMMIT_ID BIGINT Each committed version has its commit ID. MIN_COMMIT_ID refers to the minimum value of commit ID among all committed versions

2.146 M_SAVEPOINTS

Current and historical savepoint statistics

Full description

This monitor view contains information about the current and (some) past savepoints. At this time, information is kept on the last 128 savepoints per persistence manager.

606P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 607: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

NoteOnly savepoint information since startup is kept. The information in this monitor view is not persisted. The statistics server collects some information about savepoints and persists it.

A savepoint is triggered periodically, but it can be also triggered on demand using SQL command ALTER SYSTEM SAVEPOINT or by a data backup. The savepoint then runs through various states, which are then recorded in STATE column:

● INITIAL - empty statistics record (just allocated), will immediately go to PREPARE state.● PREPARE - savepoint is preparing to run.● PAGEFLUSH - flush dirty pages asynchronously. PAGES and SIZE counters will be updated to reflect savepoint

progress.● PRECRITICAL - run any pre-critical-phase callbacks and wait for I/O of the rest of the flushed pages.● ENTERCRITICAL - entering critical phase: stop updaters and wait for critical phase lock.● CRITICAL - critical phase: copy and trigger write of any still-dirty pages, record various information in restart

record (log position, transaction manager state, etc.), increment savepoint version. PAGES_IN_CRITICAL_PHASE and SIZE_IN_CRITICAL_PHASE counters are updated appropriately.

● EXITCRITICAL - exit critical phase: release critical phase lock and restart updaters.● POSTCRITICAL - call any post-critical-phase callbacks and finalize savepoint record, clean up unneeded RTT

entries.● FINISHING - wait for flush of pages written in critical phase and write out restart record and anchor page.● DONE - savepoint was completed successfully.● ABORTED - savepoint was aborted (e.g., due to timeout during synchronization global savepoint).

The following information can be extracted from the numbers in this view:

● CRITICAL_PHASE_DURATION shows the period of time during which the updaters were blocked in a savepoint. Normally, this should be in the milliseconds range, except for a global savepoint for data backup, which may take longer due to global synchronization across all nodes. If the critical phase duration is too long, there is probably some problem (e.g., I/O load is too high).

● DURATION shows the total time taken by a savepoint. This should be significantly less than configured savepoint frequency REQUESTED_FREQUENCY (in the range 0-10%, depending on load). Higher ratios indicates I/O overload.

● TIME_SINCE_PREVIOUS should be close to REQUESTED_FREQUENCY. If it is significantly higher, this indicates that the savepoint is encountering a block, such as a very long column merge operation.

● Ratio of FLUSHED_PAGES* vs. FLUSHED_ROWSTORE_PAGES* or ratio of FLUSHED_SIZE* vs. FLUSHED_ROWSTORE_SIZE* show the respective load of column store vs. row store. Row store is only flushed during savepoint, column store also flushes the data between savepoints to balance the load.

● High ratio of FLUSHED_*PAGES_IN_CRITICAL_PHASE vs. FLUSHED_*PAGES or ratio of FLUSHED_*SIZE_IN_CRITICAL_PHASE vs. FLUSHED_*SIZE indicate potential I/O overload. Normally, zero or only a few pages should be written in the critical phase, except for special situations like global savepoint for data backup (but also in this case, the number of pages written in the critical phase should be on the order of magnitude 1% or less of asynchronously flushed pages). High amounst of data written in the critical phase indicates overload of the I/O subsystem and will most probably lead to increased blocking times of update transactions due to increased CRITICAL_PHASE_DURATION.

● Big RTT_SIZE (more than a few entries) indicates some problem in distributed transaction handling. RTT (rollback transaction table) holds rollback entries for distributed transactions currently in rollback. Normally, these entries are eliminated very fast, after the respective rollback is finished. In case where a slave node

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 607

Page 608: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

failed, entries for this slave node are held persistently until the slave node restarts. Normally, this number should go to zero or close to zero a short time after the restart of a failed slave node (or after the restart of the whole system).

Aggregated values for individual counters can be queried from M_SAVEPOINT_STATISTICS.

M_SAVEPOINT_STATISTICS

Structure

Column name Data type Unit Description

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

VOLUME_ID INTEGER Persistence Volume ID

START_TIME TIMESTAMP Savepoint start time

STATE VARCHAR(16) Savepoint state

VERSION INTEGER Counter Savepoint version

REQUESTED_FREQUENCY

BIGINT Second Configured savepoint frequency

TIME_SINCE_PREVIOUS BIGINT Second Time between previous and this savepoint

DURATION BIGINT Microsecond Total time spent for creating savepoint

CRITICAL_PHASE_DURATION

BIGINT Microsecond Time spent in critical phase (updates are blocked during this)

TOTAL_SIZE BIGINT Byte Total amount of bytes written for this savepoint

FLUSHED_PAGES BIGINT Counter Count of asynchronously flushed pages

FLUSHED_PAGES_IN_CRITICAL_PHASE

BIGINT Counter Count of pages flushed in critical phase

FLUSHED_ROWSTORE_PAGES

BIGINT Counter Count of asynchronously flushed row store pages

608P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 609: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

FLUSHED_ROWSTORE_PAGES_IN_CRITICAL_PHASE

BIGINT Counter Count of row store pages flushed in critical phase

FLUSHED_SIZE BIGINT Byte Size of asynchronously flushed pages

FLUSHED_SIZE_IN_CRITICAL_PHASE

BIGINT Byte Size of pages flushed in critical phase

FLUSHED_ROWSTORE_SIZE

BIGINT Byte Size of asynchronously flushed row store pages

FLUSHED_ROWSTORE_SIZE_IN_CRITICAL_PHASE

BIGINT Byte Size of row store pages flushed in critical phase

RTT_SIZE BIGINT Counter Total size of rollback transaction table at this savepoint

2.147 M_SAVEPOINT_STATISTICS

Savepoint statisticsThis view has a resettable counterpart. This means, you can also see the values since the last reset in the dependent view M_SAVEPOINT_STATISTICS_RESET. To reset the values, use the SQL command: ALTER SYSTEM RESET MONITORING VIEW SYS.M_SAVEPOINT_STATISTICS_RESET or the management console command: monitor reset -n M_SAVEPOINT_STATISTICS_RESET

Full description

This view shows information about executed savepoints.

Columns START_TIME, STATE, VERSION and LAST_* relate to the last executed or currently-executing savepoint. Other columns contain aggregated values. Refer to M_SAVEPOINTS for further information about various counters.

M_SAVEPOINTS

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 609

Page 610: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Structure

Column name Data type Unit Description

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

VOLUME_ID INTEGER Persistence Volume ID

SAVEPOINTS BIGINT Counter Count of executed savepoints

START_TIME TIMESTAMP Last savepoint start time clock)

STATE VARCHAR(16) Last savepoint state

VERSION INTEGER Counter Last savepoint version

REQUESTED_FREQUENCY

BIGINT Second Currently active configured savepoint frequency

LAST_FREQUENCY BIGINT Second Actual savepoint frequency (time between last two savepoints) (last)

AVG_FREQUENCY BIGINT Second Actual savepoint frequency (time between last two savepoints) (avg)

LAST_DURATION BIGINT Microsecond Total time spent creating savepoint (last)

AVG_DURATION BIGINT Microsecond Total time spent creating savepoint (avg)

LAST_CRITICAL_PHASE_DURATION

BIGINT Microsecond Time spent in critical phase (updates are blocked during this phase) (last)

AVG_CRITICAL_PHASE_DURATION

BIGINT Microsecond Time spent in critical phase (updates are blocked during this phase) (avg)

610P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 611: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

LAST_TOTAL_SIZE BIGINT Byte Total amount of bytes written for a savepoint (last)

AVG_TOTAL_SIZE BIGINT Byte Total amount of bytes written for a savepoint (avg)

LAST_FLUSHED_PAGES BIGINT Counter Count of asynchronously flushed pages (last)

AVG_FLUSHED_PAGES DOUBLE Rate Count of asynchronously flushed pages (avg)

LAST_FLUSHED_PAGES_IN_CRITICAL_PHASE

BIGINT Counter Count of pages flushed in critical phase (last)

AVG_FLUSHED_PAGES_IN_CRITICAL_PHASE

DOUBLE Rate Count of pages flushed in critical phase (avg)

LAST_FLUSHED_ROWSTORE_PAGES

BIGINT Counter Count of asynchronously flushed row store pages (last)

AVG_FLUSHED_ROWSTORE_PAGES

DOUBLE Rate Count of asynchronously flushed row store pages (avg)

LAST_FLUSHED_ROWSTORE_PAGES_IN_CRITICAL_PHASE

BIGINT Counter Count of row store pages flushed in critical phase (last)

AVG_FLUSHED_ROWSTORE_PAGES_IN_CRITICAL_PHASE

DOUBLE Rate Count of row store pages flushed in critical phase (avg)

LAST_FLUSHED_SIZE BIGINT Byte Size of asynchronously flushed pages (last)

AVG_FLUSHED_SIZE BIGINT Byte Size of asynchronously flushed pages (avg)

LAST_FLUSHED_SIZE_IN_CRITICAL_PHASE

BIGINT Byte Size of pages flushed in critical phase (last)

AVG_FLUSHED_SIZE_IN_CRITICAL_PHASE

BIGINT Byte Size of pages flushed in critical phase (avg)

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 611

Page 612: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

LAST_FLUSHED_ROWSTORE_SIZE

BIGINT Byte Size of asynchronously flushed row store pages (last)

AVG_FLUSHED_ROWSTORE_SIZE

BIGINT Byte Size of asynchronously flushed row store pages (avg)

LAST_FLUSHED_ROWSTORE_SIZE_IN_CRITICAL_PHASE

BIGINT Byte Size of row store pages flushed in critical phase (last)

AVG_FLUSHED_ROWSTORE_SIZE_IN_CRITICAL_PHASE

BIGINT Byte Size of row store pages flushed in critical phase (avg)

LAST_RTT_SIZE BIGINT Counter Total size of rollback transaction table at last savepoint (may be less than sum of components if there are duplicate TIDs)

2.148 M_SAVEPOINT_STATISTICS_RESET

Savepoint statistics (since last reset)This view contains values accumulated since the last reset of the main view M_SAVEPOINT_STATISTICS. Please refer to M_SAVEPOINT_STATISTICS for information about the structure and use of this view.In addition to the members mentioned in M_SAVEPOINT_STATISTICS, this view also contains a timestamp field RESET_TIME, which indicates the last time the data was reset.

2.149 M_SEMAPHORES

Semaphore statisticsThis view has a resettable counterpart. This means, you can also see the values since the last reset in the dependent view M_SEMAPHORES_RESET. To reset the values, use the SQL command: ALTER SYSTEM RESET MONITORING VIEW SYS.M_SEMAPHORES_RESET or the management console command: monitor reset -n M_SEMAPHORES_RESET

612P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 613: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Full description

This view contains information about single semaphore objects or groups of semaphore objects. It does not contain information about all semaphores.

Structure

Column name Data type Unit Description

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

VOLUME_ID INTEGER Persistence Volume ID

STATISTICS_NAME VARCHAR(128) Statistics object name

STATISTICS_ID BIGINT Statistics object unique ID

WAIT_COUNT BIGINT Counter Count of wait calls

BLOCKING_COUNT BIGINT Counter Count of blocking wait calls

TIMEOUT_COUNT BIGINT Counter Count of timeouts

WAIT_RATE DOUBLE Percent Wait rate

LAST_BLOCKING_TIME BIGINT Microsecond Time of blocking wait calls (last)

MAX_BLOCKING_TIME BIGINT Microsecond Time of blocking wait calls (max)

MIN_BLOCKING_TIME BIGINT Microsecond Time of blocking wait calls (min)

SUM_BLOCKING_TIME BIGINT Microsecond Time of blocking wait calls (total)

AVG_BLOCKING_TIME BIGINT Microsecond Time of blocking wait calls (avg)

CREATE_COUNT BIGINT Counter Count of semaphore creation (for shared statistics only)

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 613

Page 614: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

DESTROY_COUNT BIGINT Counter Count of semaphore destruction (for shared statistics only)

2.150 M_SEMAPHORES_RESET

Semaphore statistics (since last reset)This view contains values accumulated since the last reset of the main view M_SEMAPHORES. Please refer to M_SEMAPHORES for information about the structure and use of this view.In addition to the members mentioned in M_SEMAPHORES, this view also contains a timestamp field RESET_TIME, which indicates the last time the data was reset.

2.151 M_SEQUENCES

Sequence statistics

Structure

Column name Data type Unit Description

HOST VARCHAR(64) Host where the sequence cache exists

PORT INTEGER Port where the sequence cache exists

SCHEMA_NAME NVARCHAR(256) Schema name of the sequence

SEQUENCE_NAME NVARCHAR(256) Sequence name

CACHE_SIZE SMALLINT Counter Cache size of the sequence cache

START_VALUE BIGINT Counter Start value of the sequence cache

END_VALUE BIGINT Counter End value of the sequence cache

614P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 615: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

CURRENT_VALUE BIGINT Counter Current value of the sequence cache

2.152 M_SERVICES

Status of all services

Full description

Service Calls:

Stop a service

ALTER SYSTEM STOP SERVICE (host,port)

Kill a service

ALTER SYSTEM KILL SERVICE (host,port) [WITH COREFILE]

Reconfigure a service

ALTER SYSTEM RECONFIGURE SERVICE ('service', 'host', port)

Depending on service, host, port, different services can be reconfigured:

Service Host Port Description

n.a. not empty not 0 Reconfigure single service on host y with port z

not empty not empty 0 Reconfigure all services of type x on host y

not empty empty 0 Reconfigure all services of type x

empty empty 0 Reconfigure all services

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 615

Page 616: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Structure

Column name Data type Description

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

SERVICE_NAME VARCHAR(256) Service name. See M_SERVICE_TYPES for all known service names

PROCESS_ID INTEGER Process ID

DETAIL VARCHAR(128) Only for display. Use COORDINATOR_TYPE to test service role

ACTIVE_STATUS VARCHAR(16) NO, YES, UNKNOWN, STARTING, STOPPING

SQL_PORT INTEGER SQL port

COORDINATOR_TYPE VARCHAR(16) Coordinator type in distributed landscape: MASTER, SLAVE, STANDBY, NONE

2.153 M_SERVICE_COMPONENT_MEMORY

Service-specific memory usage by logical component

Structure

Column name Data type Description

HOST VARCHAR(64) Host where the service is running

PORT INTEGER Port where the service is running

COMPONENT VARCHAR(64) The logical component for which memory usage is reported

616P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 617: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Description

USED_MEMORY_SIZE BIGINT Amount of memory which is currently actually used for the logical component

2.154 M_SERVICE_MEMORY

Detailed information on memory utilization by services

Structure

Column name Data type Unit Description

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

SERVICE_NAME VARCHAR(32) Service name

PROCESS_ID INTEGER Process ID

LOGICAL_MEMORY_SIZE BIGINT Byte Virtual memory size (operating system perspective)

PHYSICAL_MEMORY_SIZE

BIGINT Byte Physical/resident memory size (operating system perspective)

CODE_SIZE BIGINT Byte Code size, including shared libraries

STACK_SIZE BIGINT Byte Stack size

HEAP_MEMORY_ALLOCATED_SIZE

BIGINT Byte Heap part of the memory pool

HEAP_MEMORY_USED_SIZE

BIGINT Byte Amount of pool heap memory that is currently actually in use

SHARED_MEMORY_ALLOCATED_SIZE

BIGINT Byte Shared memory part of the memory pool

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 617

Page 618: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

SHARED_MEMORY_USED_SIZE

BIGINT Byte Amount of pool shared memory that is currently actually in use

COMPACTORS_ALLOCATED_SIZE

BIGINT Byte Part of the memory pool that can potentially (=if unpinned) be freed on memory shortage

COMPACTORS_FREEABLE_SIZE

BIGINT Byte Memory which can actually be freed on memory shortage

ALLOCATION_LIMIT BIGINT Byte Maximum memory pool size (configurable value)

EFFECTIVE_ALLOCATION_LIMIT

BIGINT Byte Effective maximum memory pool size, considering pool sizes of other processes (computed value)

TOTAL_MEMORY_USED_SIZE

BIGINT Amount of memory from the memory pool that is currently actually in use

2.155 M_SERVICE_NETWORK_IO

Service network I/O statisticsThis view has a resettable counterpart. This means, you can also see the values since the last reset in the dependent view M_SERVICE_NETWORK_IO_RESET. To reset the values, use the SQL command: ALTER SYSTEM RESET MONITORING VIEW SYS.M_SERVICE_NETWORK_IO_RESET or the management console command: monitor reset -n M_SERVICE_NETWORK_IO_RESET

Structure

Column name Data type Unit Description

SENDER_HOST VARCHAR(64) Host name of the sending service

618P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 619: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

SENDER_PORT INTEGER Port that the sending service listens on

RECEIVER_HOST VARCHAR(64) Host name of the receiving service

RECEIVER_PORT INTEGER Port that the receiving service listens on

SEND_SIZE BIGINT Byte Number of bytes sent

RECEIVE_SIZE BIGINT Byte Number of bytes received

SEND_DURATION BIGINT Microsecond Time spent sending

RECEIVE_DURATION BIGINT Microsecond Time spent receiving

REQUEST_COUNT BIGINT Counter Number of requests handled

2.156 M_SERVICE_NETWORK_IO_RESET

Service network I/O statistics (since last reset)This view contains values accumulated since the last reset of the main view M_SERVICE_NETWORK_IO. Please refer to M_SERVICE_NETWORK_IO for information about the structure and use of this view.In addition to the members mentioned in M_SERVICE_NETWORK_IO, this view also contains a timestamp field RESET_TIME, which indicates the last time the data was reset.

2.157 M_SERVICE_REPLICATION

Information about replicated services

Structure

Column name Data type Description

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 619

Page 620: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Description

VOLUME_ID INTEGER Volume ID

SITE_ID INTEGER Generated site ID

SITE_NAME VARCHAR(256) Logical site name

SECONDARY_HOST VARCHAR(64) Secondary Host Name

SECONDARY_PORT INTEGER Secondary Port

SECONDARY_SITE_ID INTEGER Generated ID of secondary site

SECONDARY_SITE_NAME VARCHAR(256) Secondary logical site name

SECONDARY_ACTIVE_STATUS VARCHAR(16) Secondary Active Status

SECONDARY_CONNECT_TIME TIMESTAMP Time the connection was established from the secondary

SECONDARY_RECONNECT_COUNT

INTEGER Secondary Reconnect Count

SECONDARY_FAILOVER_COUNT INTEGER Secondary Failover Count

REPLICATION_MODE VARCHAR(16) Replication Mode

REPLICATION_STATUS VARCHAR(16) Replication Status

REPLICATION_STATUS_DETAILS VARCHAR(1024) Replication Status Details

LAST_LOG_POSITION BIGINT Current Log Pos

LAST_LOG_POSITION_TIME TIMESTAMP Current Log Pos Timestamp

LAST_SAVEPOINT_VERSION INTEGER Current Savepoint Version

LAST_SAVEPOINT_LOG_POSITION BIGINT Current Savepoint Log Position

LAST_SAVEPOINT_START_TIME TIMESTAMP Current Savepoint Timestamp

SHIPPED_LOG_POSITION BIGINT Shipped Log Positon

SHIPPED_LOG_POSITION_TIME TIMESTAMP Shipped Log Position Timestamp

SHIPPED_LOG_BUFFERS_COUNT BIGINT Shipped Log Buffers Count

SHIPPED_LOG_BUFFERS_SIZE BIGINT Shipped Log Buffers Size in Bytes

SHIPPED_LOG_BUFFERS_DURATION

BIGINT Shipped Log Buffer Duration in microseconds

620P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 621: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Description

SHIPPED_SAVEPOINT_VERSION INTEGER Shipped Savepoint Version

SHIPPED_SAVEPOINT_LOG_POSITION

BIGINT Shipped Savepoint Log Position

SHIPPED_SAVEPOINT_START_TIME

TIMESTAMP Shipped Savepoint Start Time

SHIPPED_FULL_REPLICA_COUNT BIGINT Shipped Full Replica Count

SHIPPED_FULL_REPLICA_SIZE BIGINT Shipped Full Replica Size in Bytes

SHIPPED_FULL_REPLICA_DURATION

BIGINT Shipped Full Replica Duration in microseconds

SHIPPED_LAST_FULL_REPLICA_SIZE

BIGINT Shipped Last Full Replica Size in Bytes

SHIPPED_LAST_FULL_REPLICA_START_TIME

TIMESTAMP Shipped Last Full Replica Start Time

SHIPPED_LAST_FULL_REPLICA_END_TIME

TIMESTAMP Shipped Last Full Replica End Time

SHIPPED_DELTA_REPLICA_COUNT BIGINT Shipped Delta Replica Count

SHIPPED_DELTA_REPLICA_SIZE BIGINT Shipped Delta Replica Size in Bytes

SHIPPED_DELTA_REPLICA_DURATION

BIGINT Shipped Delta Replica Duration in microseconds

SHIPPED_LAST_DELTA_REPLICA_SIZE

BIGINT Shipped Last Delta Replica Size in Bytes

SHIPPED_LAST_DELTA_REPLICA_START_TIME

TIMESTAMP Shipped Last Delta Replica Start Time

SHIPPED_LAST_DELTA_REPLICA_END_TIME

TIMESTAMP Shipped Last Delta Replica End Time

2.158 M_SERVICE_STATISTICS

Statistics on active services

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 621

Page 622: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Full description

PROCESS_CPU and TOTAL_CPU contain CPU usage in percent since last select. This select could be done by another user or another session.

To calculate exact CPU usage use 2 selects and this formula:

process_cpu = (select2.process_cpu-time - select1.process_cpu_time) / (select2.sys_timestamp - select1.sys_timestamp) total_cpu = (select2.total_cpu_time - select1.total_cpu_time ) / (select2.sys_timestamp - select1.sys_timestamp)ACTIVE

Value Description

NO Service not started.

STARTING Service is starting. This state might last for several minutes on first startup or recovery.

YES Service started and ready for requests.

STOPPING Service is stopping.

UNKNOWN Initial state after starting a landscape or when state not known (e.g after crash). If the service does not start within a minute this state changes to NO.

Structure

Column name Data type Unit Description

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

SERVICE_NAME VARCHAR(32) Service name

PROCESS_ID INTEGER Process ID

DETAIL VARCHAR(128) Detail information, similar to COORDINATOR_TYPE in M_SERVICES

622P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 623: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

ACTIVE_STATUS VARCHAR(16) NO, YES, UNKNOWN, STARTING, STOPPING

START_TIME TIMESTAMP Process start timestamp

SYS_TIMESTAMP TIMESTAMP Current system timestamp

PROCESS_CPU SMALLINT Percent CPU usage of current process

PROCESS_CPU_TIME BIGINT Millisecond CPU usage of current process since start

TOTAL_CPU SMALLINT Percent CPU usage of all processes

TOTAL_CPU_TIME BIGINT Millisecond CPU usage of all processes since start

PROCESS_MEMORY BIGINT Process logical memory usage

PROCESS_PHYSICAL_MEMORY

BIGINT Process physical memory usage

TOTAL_MEMORY BIGINT Host physical+swap memory usage

AVAILABLE_MEMORY BIGINT Host physical+swap memory size

PHYSICAL_MEMORY BIGINT Host physical memory size

REQUESTS_PER_SEC DOUBLE Rate Requests per second. Average over last 1000 requests

RESPONSE_TIME INTEGER Millisecond Request response time. Average over last 1000 requests

FINISHED_NON_INTERNAL_REQUEST_COUNT

BIGINT Counter Finished requests

ALL_FINISHED_REQUEST_COUNT

BIGINT Counter Finished requests including internal requests

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 623

Page 624: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

ACTIVE_REQUEST_COUNT

INTEGER Number of active requests

PENDING_REQUEST_COUNT

INTEGER Number of pending requests

ACTIVE_THREAD_COUNT INTEGER Number of active threads

THREAD_COUNT INTEGER Number of total threads

OPEN_FILE_COUNT INTEGER Number of open files

2.159 M_SERVICE_THREADS

Detailed information on threads created by services

Structure

Column name Data type Unit Description

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

SERVICE_NAME VARCHAR(32) Service name. See M_SERVICE_TYPES for all known service names

HIERARCHY VARCHAR(128) Thread grouping information. Filled with Connection-ID/Update-Transaction-ID/Transaction-ID or left empty for inactive threads

CONNECTION_ID INTEGER Connection ID

THREAD_ID BIGINT Thread ID

THREAD_TYPE VARCHAR(128) Thread Type

THREAD_METHOD VARCHAR(256) Thread method

624P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 625: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

THREAD_DETAIL NCLOB Thread detail

THREAD_STATE VARCHAR(32) Thread state

IS_ACTIVE VARCHAR(5) Is thread active

DURATION BIGINT Millisecond Thread Duration

CALLER VARCHAR(256) The service which called this thread

CALLING VARCHAR(256) The service which the thread calls

USER_NAME NVARCHAR(256) SQL user name

APPLICATION_USER_NAME

NVARCHAR(256) Application user name

CPU_TIME_SELF BIGINT Microsecond CPU time of thread

CPU_TIME_CUMULATIVE BIGINT Microsecond CPU time of thread and assoziated children

TRANSACTION_ID INTEGER Transaction ID

UPDATE_TRANSACTION_ID

BIGINT Update transaction ID

2.160 M_SERVICE_THREAD_CALLSTACKS

Stack frame information for service threads

Structure

Column name Data type Description

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 625

Page 626: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Description

SERVICE_NAME VARCHAR(32) Service name. See M_SERVICE_TYPES for all known service names

THREAD_ID BIGINT Thread ID

FRAME_LEVEL INTEGER Level of stack frame

FRAME_NAME VARCHAR(256) Name of stack frame (function, file, library, ...)

2.161 M_SERVICE_TRACES

Configured trace components for each service type

Structure

Column name Data type Description

SERVICE_NAME VARCHAR(32) Service name

COMPONENT_NAME VARCHAR(32) Trace component name

2.162 M_SERVICE_TYPES

Service types

Structure

Column name Data type Unit Description

SERVICE_NAME VARCHAR(32) Service name

626P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 627: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

INIFILE VARCHAR(36) Configuration file name of service

HAS_DETAIL VARCHAR(5) Boolean Service shows details in M_SERVICE_STATISTICS: 'TRUE', 'FALSE'

2.163 M_SESSION_CONTEXT

Session variables for each connection

Full description

This view shows session variables of all open connections.

Each variable is categorized in SECTION column to USER (user defined variable using SET command or client API call) or SYSTEM (predefined variable or system property).

Predefined Variables

Variable Name (M_SESSION_CONTEXT.KEY)

Value Constraint

Set by Client or Server

Shown in M_SESSION_CONTEXT

Server Usage Description

APPLICATION NVARCHAR(256)

client yes trace filter

M_EXPENSIVE_STATEMENTS.APPLICATION_NAME

Application name

APPLICATIONVERSION

NVARCHAR(256)

client yes no Application version information.

Applications can use their "own" version naming, no format is predefined

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 627

Page 628: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Variable Name (M_SESSION_CONTEXT.KEY)

Value Constraint

Set by Client or Server

Shown in M_SESSION_CONTEXT

Server Usage Description

APPLICATIONUSER

NVARCHAR(256)

client yes trace filter

M_SERVICE_THREADS.APPLICATION_USER

M_MERGED_TRACES.APPLICATION_USER

M_EXPENSIVE_STATEMENTS.APP_USER

Application defined user name

APPLICATIONACTION

NVARCHAR(256)

client yes no With APPLICATIONACTION the application can define what logical action/step it is currently doing.

The usage is up to the application and could be coarse grain like 'create sales order' or fine grain like 'refresh service tab' in HANA Studio

APPLICATIONSOURCE

NVARCHAR(256)

client yes M_EXPENSIVE_STATEMENTS.APPLICATION_SOURCE

M_PREPARED_STATEMENTS.APPLICATION_SOURCE

With APPLICATIONSOURCE the application can define from which source file HANA was called.

The usage is up to the application and could be something like

628P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 629: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Variable Name (M_SESSION_CONTEXT.KEY)

Value Constraint

Set by Client or Server

Shown in M_SESSION_CONTEXT

Server Usage Description

<abap program name>:<line number>

or <java source file name>:<line number>

or <package name>/<file name>:<line number>

or ...

PROTOCOL_VERSION

- server yes internal protocol version of client interface libraries, formated as: <protocol version> (<distribution protocol version>, <data format version>), e.g 4.1 (1,1)

TOTAL_ROWCOUNT

integer server no, only accessible with: select session_context('TOTAL_ROWCOUNT') from DUMMY

SELECT ... LIMIT x TOTAL ROWCOUNT

SELECT ... LIMIT x returns up to x rows. With the optional TOTAL ROWCOUNT the (estimated) total number of rows is set in ROTAL_ROWCOUNT variable. This variable is not deleted/reset by non TOTAL ROWCOUNT statements. The similar SELECT TOP x ... does

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 629

Page 630: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Variable Name (M_SESSION_CONTEXT.KEY)

Value Constraint

Set by Client or Server

Shown in M_SESSION_CONTEXT

Server Usage Description

not support this extension.

This feature is only supported for column tables and views. It can return exact or estimated row count or only the given LIMIT. The concrete return value depends on the statement, used tables and views and internally chosen SQL optimizer strategy. Usage is recommended only for interactive paged searches to show information like 'result 11 to 20 of estimated 50000'.

TRACEPROFILE - client yes trace filter For manual activation of trace profiles defined in inifiles as [traceprofile_<name>]

The value can contain one traceprofile name or a comma separated list of

630P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 631: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Variable Name (M_SESSION_CONTEXT.KEY)

Value Constraint

Set by Client or Server

Shown in M_SESSION_CONTEXT

Server Usage Description

traceprofile names.

In HANA Studio the traceprofiles are accesible as End-To-End Traces.

Structure

Column name Data type Description

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

CONNECTION_ID INTEGER Connection ID

KEY VARCHAR(32) Key name of a session context variable

VALUE NVARCHAR(512) Value of a session context variable

SECTION VARCHAR(8) Section name to distinguish system and user variables: USER=application defined variable using SET command or client API call, SYSTEM=predefined variable or server property

2.164 M_SHARED_MEMORY

Shared memory usage information by SAP HANA indexserver

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 631

Page 632: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Structure

Column name Data type Description

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

CATEGORY VARCHAR(128) Module name

ALLOCATED_SIZE BIGINT Allocated shared memory size on the module

USED_SIZE BIGINT Used shared memory size on the module

FREE_SIZE BIGINT Free shared memory size on the module

2.165 M_SNAPSHOTS

Existing snapshots

Structure

Column name Data type Unit Description

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

VOLUME_ID INTEGER Persistence Volume ID

ID BIGINT Snapshot ID

TIMESTAMP TIMESTAMP Creation time

FOR_BACKUP VARCHAR(5) Created for backup: 'TRUE', 'FALSE'

ANCHOR BIGINT HEXID Anchor

632P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 633: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

2.166 M_SQL_PLAN_CACHE

Statistics of an individual execution planThis view has a resettable counterpart. This means, you can also see the values since the last reset in the dependent view M_SQL_PLAN_CACHE_RESET. To reset the values, use the SQL command: ALTER SYSTEM RESET MONITORING VIEW SYS.M_SQL_PLAN_CACHE_RESET or the management console command: monitor reset -n M_SQL_PLAN_CACHE_RESET

Full description

● GLOBAL: A plan always can be shared with any other connections concurrently. No restriction.● SESSION EXCLUSIVE GLOBAL: If a connection uses a plan, the plan cannot be shared with any other

connections concurrently, but after the connection releases the plan, it can be acquired by another connection.

● SESSION LOCAL: A plan is never shared. This sharing type is more restricted than SESSION EXCLUSIVE GLOBAL. If a connection generates a plan, the plan belongs to the connection. This plan cannot be shared with any other connection and it cannot be also shared with any other cursor even if in the same connection.

● GLOBAL: -1 (always).● SESSION EXCLUSIVE GLOBAL: -1 or owner connection ID with positive value (can be changed).● SESSION LOCAL: owner connection ID with positive value (never changed).

The M_SQL_PLAN_CACHE view shows statistics for an individual plan but not all plans. It shows whether a specified plan runs longer than expected or which part of execution is dominant. For each cached plan, this view delivers statistics from execution on distributed configuration as well as technical details such as related object IDs, updated objects and so on.

Structure

Column name Data type Unit Description

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

VOLUME_ID INTEGER Persistence Volume ID

STATEMENT_STRING NCLOB Statement string

STATEMENT_HASH VARCHAR(32) MD5 hash value for STATEMENT_STRING

USER_NAME NVARCHAR(256) User name who prepared the plan

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 633

Page 634: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

SCHEMA_NAME NVARCHAR(256) Schema name that the SQL plan belongs to. SQL plans are generated in each schema even though the statement string is the same since the query optimizer statistics might be different

IS_VALID VARCHAR(5) TRUE if the plan is currently valid. A plan is invalidated whenever its corresponding schema objects, such as table and view, are changed. Invalidated plans are recompiled if the same statement is executed, otherwise they are evicted by another plan when newly compiled

IS_INTERNAL VARCHAR(5) TRUE if the plan is executed from a database internal connection. FALSE if it is executed from a remote connection

IS_DISTRIBUTED_EXECUTION

VARCHAR(5) TRUE if tables are located in multi nodes, FALSE otherwise

ABAP_VARCHAR_MODE VARCHAR(5) TRUE if ABAP VARCHAR mode enabled, FALSE otherwise. ABAP application developers concern this mode, which indicates null terminated string or not

ACCESSED_OBJECTS VARCHAR(2000) Relevant table object ID list for the plan

TABLE_LOCATIONS VARCHAR(2000) Relevant table locations for the plan

TABLE_TYPES VARCHAR(128) Specification whether the plan refers Column store

634P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 635: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

only, Row store only or mixed, displayed as one of three possible values 'ROW', 'COLUMN', 'ROW, COLUMN'

PLAN_SHARING_TYPE VARCHAR(128) The Plan sharing type: 'GLOBAL', 'SESSION EXCLUSIVE GLOBAL', 'SESSION LOCAL'

OWNER_CONNECTION_ID

INTEGER A Connection owning the plan

PLAN_ID BIGINT Logical plan ID which is a non-negative value

PLAN_MEMORY_SIZE BIGINT Byte Memory size used by the plan

REFERENCE_COUNT BIGINT Counter Number of statements using the plan. When the count reaches zero, it can be evicted by the victim selection policy of plan cache

PARAMETER_COUNT BIGINT Counter Number of parameters to be assigned for the execution

UPDATED_TABLE_OID BIGINT Object ID of the updated table for the plan

EXECUTION_COUNT BIGINT Counter Accumulated count of plan execution

EXECUTION_COUNT_BY_ROUTING

BIGINT Counter Accumulated count of plan execution by client-routed connection in statement routing. This column shows how many times the statement is executed in routed connection. The routed connection means a physical connection in a part of the logical session

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 635

Page 636: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

TOTAL_CURSOR_DURATION

BIGINT Microsecond Sum of time of plan execution including communication time with clients

AVG_CURSOR_DURATION

BIGINT Microsecond Average time of plan execution including communicate time with clients

MIN_CURSOR_DURATION BIGINT Microsecond Minimum time of plan execution including communicate time with clients

MAX_CURSOR_DURATION

BIGINT Microsecond Maximum time of plan execution including communicate time with clients

TOTAL_EXECUTION_TIME BIGINT Microsecond Sum of time of plan executions

AVG_EXECUTION_TIME BIGINT Microsecond Average time of plan execution

MIN_EXECUTION_TIME BIGINT Microsecond Minimum time of plan execution

MAX_EXECUTION_TIME BIGINT Microsecond Maximum time of plan execution

TOTAL_EXECUTION_OPEN_TIME

BIGINT Microsecond Sum of time of establishing result sets

AVG_EXECUTION_OPEN_TIME

BIGINT Microsecond Average time for cursor open

MIN_EXECUTION_OPEN_TIME

BIGINT Microsecond Minimum time for cursor close

MAX_EXECUTION_OPEN_TIME

BIGINT Microsecond Maximum time for cursor close

TOTAL_EXECUTION_FETCH_TIME

BIGINT Microsecond Sum of time for transferring rows

AVG_EXECUTION_FETCH_TIME

BIGINT Microsecond Average time for cursor fetch

636P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 637: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

MIN_EXECUTION_FETCH_TIME

BIGINT Microsecond Minimum time for cursor fetch

MAX_EXECUTION_FETCH_TIME

BIGINT Microsecond Maximum time for cursor fetch

TOTAL_EXECUTION_CLOSE_TIME

BIGINT Microsecond Sum of time for cleanup of result sets

AVG_EXECUTION_CLOSE_TIME

BIGINT Microsecond Average time for cursor close

MIN_EXECUTION_CLOSE_TIME

BIGINT Microsecond Minimum time for cursor close

MAX_EXECUTION_CLOSE_TIME

BIGINT Microsecond Maximum time for cursor close

TOTAL_METADATA_CACHE_MISS_COUNT

BIGINT Counter Accumulated count of metadata cache misses during plan preparation and plan execution. When a metadata object is first requested to be accessed in a slave server instance, it gets the object from a master server instance via network communication, if the object does not exist or is out of date.

TOTAL_TABLE_LOAD_TIME_DURING_PREPARATION

BIGINT Microsecond Sum of table loading time during plan preparation

AVG_TABLE_LOAD_TIME_DURING_PREPARATION

BIGINT Microsecond Average table loading time during plan preparation

MIN_TABLE_LOAD_TIME_DURING_PREPARATION

BIGINT Microsecond Minimum table loading time during plan preparation

MAX_TABLE_LOAD_TIME_DURING_PREPARATION

BIGINT Microsecond Maximum table loading time during plan preparation

PREPARATION_COUNT BIGINT Counter Number of plan preparations

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 637

Page 638: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

TOTAL_PREPARATION_TIME

BIGINT Microsecond Sum of time of plan preparation

AVG_PREPARATION_TIME

BIGINT Microsecond Average time of plan preparation

MIN_PREPARATION_TIME BIGINT Microsecond Minimum time of plan preparation

MAX_PREPARATION_TIME

BIGINT Microsecond Maximum time of plan preparation

TOTAL_RESULT_RECORD_COUNT

BIGINT Counter Accumulated number of records during plan execution.

TOTAL_LOCK_WAIT_COUNT

BIGINT Counter Accumulated lock wait count for the plan

TOTAL_LOCK_WAIT_DURATION

BIGINT Counter Accumulated lock wait duration for the plan

LAST_CONNECTION_ID INTEGER The last connection ID that executed the plan

LAST_EXECUTION_TIMESTAMP

TIMESTAMP Last execution timestamp

LAST_PREPARATION_TIMESTAMP

TIMESTAMP Last preparation timestamp

2.167 M_SQL_PLAN_CACHE_OVERVIEW

Overall statistics of evicted and cached plans

Full description

M_SQL_PLAN_CACHE_OVERVIEW shows the overall statistics of evicted and cached plans. It shows information such as how many times plan eviction occurred and how long it takes to execute currently cached plans. In addition to statistics, the current status and flags of the SQL plan cache are shown in this view.

638P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 639: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Structure

Column name Data type Unit Description

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

STATISTICS_COLLECTION_ENABLED

VARCHAR(5) TRUE if runtime statistics are collected ALTER SYSTEM ALTER CONFIGURATION ('indexserver.ini','system') SET('sql', 'plan_cache_statistics_enabled') = <'True' or 'False'> WITH RECONFIGURE

PLAN_CACHE_CAPACITY BIGINT Byte Maximum SQL Plan Cache size ALTER SYSTEM ALTER CONFIGURATION ('indexserver.ini','system') SET('sql', 'plan_cache_size') = '268435456' WITH RECONFIGURE

EVICTED_PLAN_COUNT BIGINT Number of evicted plans from SQL Plan Cache

EVICTED_PLAN_PREPARATION_COUNT

BIGINT Total plan preparation count for evicted plans

EVICTED_PLAN_EXECUTION_COUNT

BIGINT Total plan execution count for evicted plans

EVICTED_PLAN_PREPARATION_TIME

BIGINT Microsecond Total duration for plan preparation for all evicted plans

EVICTED_PLAN_CURSOR_DURATION

BIGINT Microsecond Total cursor duration for evicted plans

EVICTED_PLAN_TOTAL_EXECUTION_TIME

BIGINT Microsecond Total execution time for evicted plans

EVICTED_PLAN_SIZE BIGINT Byte Accumulated total size of evicted plans

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 639

Page 640: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

CACHED_PLAN_COUNT BIGINT Total cached plan count in SQL Plan Cache

CACHED_PLAN_PREPARATION_COUNT

BIGINT Total plan preparation count for cached plans

CACHED_PLAN_EXECUTION_COUNT

BIGINT Total execution count for cached plans

CACHED_PLAN_PREPARATION_TIME

BIGINT Microsecond Total plan preparation duration for cached plans

CACHED_PLAN_CURSOR_DURATION

BIGINT Microsecond Total cursor duration for cached plans

CACHED_PLAN_TOTAL_EXECUTION_TIME

BIGINT Microsecond Total execution time for cached plans

CACHED_PLAN_SIZE BIGINT Byte Total size of SQL Plan Cache

PLAN_CACHE_ENABLED TINYINT TRUE if SQL Plan Cache is turned on ALTER SYSTEM ALTER CONFIGURATION ('indexserver.ini','system') SET('sql', 'plan_cache_enabled') = <'True' or 'False'> WITH RECONFIGURE

CLEAR_TIMESTAMP TIMESTAMP Timestamp when SQL Plan Cache was cleared for the last time using ALTER SYSTEM CLEAR SQL PLAN CACHE

2.168 M_SQL_PLAN_CACHE_RESET

Statistics of an individual execution plan (since last reset)This view contains values accumulated since the last reset of the main view M_SQL_PLAN_CACHE. Please refer to M_SQL_PLAN_CACHE for information about the structure and use of this view.In addition to the members mentioned in M_SQL_PLAN_CACHE, this view also contains a timestamp field RESET_TIME, which indicates the last time the data was reset.

640P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 641: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

2.169 M_SYSTEM_INFORMATION_STATEMENTS

System information statements

Structure

Column name Data type Description

NAME VARCHAR(64) Statement name

DESCRIPTION NVARCHAR(256) Statement description

STATEMENT NCLOB Actual SQL statement

2.170 M_SYSTEM_LIMITS

System limits information

Structure

Column name Data type Description

CATEGORY VARCHAR(128) Category of system limit is adaptable

NAME NVARCHAR(256) Name of system limit

VALUE VARCHAR(256) Value of system limit

TYPE VARCHAR(128) Type of value

UNIT VARCHAR(256) Unit of value

COMMENT VARCHAR(2000) Additional comment for system limits

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 641

Page 642: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

2.171 M_SYSTEM_OVERVIEW

Overview of system status including important resource usage information and alerts

Structure

Column name Data type Description

SECTION VARCHAR(16) Section name

NAME VARCHAR(32) Key name in section

STATUS VARCHAR(8) Status value: OK, ERROR, WARNING or empty for info items

VALUE VARCHAR(256) Key value in section

2.172 M_TABLES

Information on row and column tables

Structure

Column name Data type Description

SCHEMA_NAME NVARCHAR(256) Schema name

TABLE_NAME NVARCHAR(256) Table name

RECORD_COUNT BIGINT Number of records in this table

TABLE_SIZE BIGINT Allocated memory size for fixed-size and variable-size part

IS_COLUMN_TABLE VARCHAR(5) Specifies whether the table is a column table: 'TRUE', 'FALSE'

TABLE_TYPE VARCHAR(16) Specifies type of the table: 'ROW', 'COLUMN', 'HYBRID'

642P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 643: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Description

IS_PARTITIONED VARCHAR(5) Specifies whether the table is partitioned: 'TRUE', 'FALSE'

IS_REPLICATED VARCHAR(5) Specifies whether the table is replicated: 'TRUE', 'FALSE'

2.173 M_TABLE_LOB_FILES

All LOB files that belong to a table

Structure

Column name Data type Unit Description

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

SCHEMA_NAME NVARCHAR(256) Schema name

TABLE_NAME NVARCHAR(256) Table name

COLUMN_NAME NVARCHAR(256) Column name

PART_ID INTEGER Part ID of split table

TABLE_OID BIGINT Table OID, same as owner_oid if the table is found; 0 otherwise

CONTAINER_ID BIGINT Container ID

PHYSICAL_SIZE BIGINT Byte File size

BINARY_SIZE BIGINT Byte LOB size

CHARACTER_SIZE INTEGER Number of characters in NCLOB

PAGE_COUNT BIGINT Number of pages used for a LOB file

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 643

Page 644: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

LOB_TYPE VARCHAR(5) Type of the lob

2.174 M_TABLE_LOCATIONS

Tables and their logical location. Physical locations are shown in M_TABLE_PERSISTENCE_LOCATIONS

Full description

To move tables to other locations use:

ALTER TABLE name MOVE TO LOCATION 'host:port'

To move parts of a split table to other locations use:

ALTER TABLE name MOVE PART i TO LOCATION 'host:port'

Structure

Column name Data type Description

HOST VARCHAR(64) Host where table data is located. Empty for Views

PORT INTEGER Port where table data is located. 0 for Views

SCHEMA_NAME NVARCHAR(256) Schema name

TABLE_NAME NVARCHAR(256) Table name

PART_ID INTEGER Partition ID. 0 for non-partitioned tables, 1 through number of partitions for partitioned tables. -1 if the whole table is unloaded.

LOCATION VARCHAR(75) Host and port where the table data is located

644P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 645: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

2.175 M_TABLE_PERSISTENCE_LOCATIONS

Column store tables and their physical data locations

Full description

This view shows information on which node contains the persistence parts of a table. This will include the assigned node as visible from the view M_TABLE_LOCATIONS but will also include other nodes that still contains some persistence of the table. This could occur if a table is moved and not yet merged. In this case the old node will still contain some persistence content for the table beside the currently assigned node.

Structure

Column name Data type Description

SCHEMA_NAME NVARCHAR(256) Schema name

TABLE_NAME NVARCHAR(256) Table name

PART_ID INTEGER Partition ID. 0 for non-partitioned tables, 1 through number of partitions for partitioned tables. -1 if the whole table is unloaded.

IS_HISTORY VARCHAR(5) Is this the history part of a table: 'TRUE', 'FALSE'

PERSISTENCE_HOST VARCHAR(64) Host where table data is located

PERSISTENCE_PORT INTEGER Port where table data is located

2.176 M_TABLE_PERSISTENCE_STATISTICS

Persistence virtual file summary statistics for tables

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 645

Page 646: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Structure

Column name Data type Description

SCHEMA_NAME NVARCHAR(256) Schema Name

TABLE_NAME NVARCHAR(256) Table Name

DISK_SIZE BIGINT Total disk size of all table parts

PAGE_COUNT BIGINT Total number of pages of all table parts

BYTES_WRITTEN BIGINT Number of bytes written to the table

BYTES_APPENDED BIGINT Number of bytes appended to the table

BYTES_READ BIGINT Number of bytes read from the table

BYTESTREAM_WRITTEN BIGINT Number of bytes written to the table via streaming interface

APPEND_COUNT BIGINT Number of times the table was appended to

WRITE_COUNT BIGINT Number of times the table was written to

OPTIMIZE_COUNT BIGINT Number of times the table was written to optimized

READ_COUNT BIGINT Number of times the table was read from

TRUNCATE_COUNT BIGINT Number of times the table was truncated

COPY_COUNT BIGINT Number of times the table was copied

2.177 M_TABLE_VIRTUAL_FILES

All virtual files that belong to a table

646P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 647: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Structure

Column name Data type Unit Description

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

SCHEMA_NAME NVARCHAR(256) Schema name

TABLE_NAME NVARCHAR(256) Table name

PART_ID INTEGER Partition ID. 0 for non-partitioned tables, 1 through number of partitions for partitioned tables.

IS_HISTORY VARCHAR(5) Is this the history part of a table: 'TRUE', 'FALSE'

CONTAINER_ID BIGINT Container ID

NAMESPACE VARCHAR(512) Namespace address in the database storage system

NAME VARCHAR(512) Name in the database storage system

PHYSICAL_SIZE BIGINT Byte Storage size used for the file

PAGE_COUNT BIGINT Number of storage pages used for the file

2.178 M_TEMPORARY_OBJECT_DEPENDENCIES

Temporary object dependencies for transient objects

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 647

Page 648: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Structure

Column name Data type Description

BASE_SCHEMA_NAME NVARCHAR(256) Schema name of the base object

BASE_OBJECT_NAME NVARCHAR(256) Object name of the base object

BASE_OBJECT_TYPE VARCHAR(32) Type of the base object

BASE_OBJECT_OID BIGINT Object ID of the base object

BASE_OBJECT_IS_TEMPORARY VARCHAR(5) Temporary property of the base object

DEPENDENT_SCHEMA_NAME NVARCHAR(256) Schema name of the dependent object

DEPENDENT_OBJECT_NAME NVARCHAR(256) Object name of the dependent object

DEPENDENT_OBJECT_TYPE VARCHAR(32) Type of the dependent dependent

DEPENDENT_OBJECT_OID BIGINT Object ID of the dependent dependent

DEPENDENT_OBJECT_IS_TEMPORARY

VARCHAR(5) Temporary property of the dependent dependent

2.179 M_TEMPORARY_TABLES

Temporary tables

Structure

Column name Data type Unit Description

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

SCHEMA_NAME NVARCHAR(256) Schema name

648P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 649: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

TABLE_NAME NVARCHAR(256) Table name

TABLE_OID BIGINT Object ID of the table

COMMENTS NVARCHAR(5000) Comment on the table

FIXED_PART_SIZE SMALLINT Byte Fixed-size part of record

IS_LOGGED VARCHAR(5) Specifies whether logging is enabled for the table: 'TRUE', 'FALSE'

IS_SYSTEM_TABLE VARCHAR(5) Specifies whether the table is a system table: 'TRUE', 'FALSE'

IS_COLUMN_TABLE VARCHAR(5) Specifies whether the table is a column table: 'TRUE', 'FALSE'

IS_INSERT_ONLY VARCHAR(5) Specifies whether the table is an 'insert only' table: 'TRUE', 'FALSE'

IS_TENANT_SHARED_DATA

VARCHAR(5) Specifies whether the table can be shared among other instances: 'TRUE', 'FALSE'

IS_TENANT_SHARED_METADATA

VARCHAR(5) Specifies whether the table is a global table: 'TRUE', 'FALSE'

SESSION_TYPE VARCHAR(16) Session type: 'NONE', 'SIMPLE', 'HISTORY'. For 'HISTORY', time travel is possible

IS_TEMPORARY VARCHAR(5) Specifies whether the table is a temporary table: 'TRUE', 'FALSE'

TEMPORARY_TABLE_TYPE

VARCHAR(8) Temporary table type

IS_USER_DEFINED_TYPE VARCHAR(5) 'TRUE' if user defined table type, 'FALSE' otherwise

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 649

Page 650: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

PRELOAD VARCHAR(5) 'TRUE' if the table uses preloading, else 'FALSE'. Only valid for column store tables

2.180 M_TEMPORARY_TABLE_COLUMNS

Columns of temporary tables

Structure

Column name Data type Unit Description

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

SCHEMA_NAME NVARCHAR(256) Schema name

TABLE_NAME NVARCHAR(256) Table name

TABLE_OID BIGINT Object ID of the table

COLUMN_NAME NVARCHAR(256) Name of the column

POSITION INTEGER Ordinal position of the table column

DATA_TYPE_ID SMALLINT SQL data type ID of the column

DATA_TYPE_NAME VARCHAR(16) SQL data type name of the column

OFFSET SMALLINT Byte Offset of the column in the record

LENGTH INTEGER # of chars for char types; # of max digits for numeric types; # of chars for datetime types; # of bytes for LOB types

650P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 651: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

SCALE INTEGER Numeric types: the maximum number of digits to the right of the decimal point; time, timestamp: the decimal digits are defined as the number of digits to the right of the decimal point in the second's component of the data

IS_NULLABLE VARCHAR(5) Specifies whether the column is allowed to accept a null value: 'TRUE', 'FALSE'

DEFAULT_VALUE NVARCHAR(5000) Default value of the column

COLLATION NVARCHAR(5000) Collation of the column

COMMENTS NVARCHAR(5000) Comments on the column

MAX_VALUE NVARCHAR(5000) Maximum value

MIN_VALUE NVARCHAR(5000) Minimum value

CS_DATA_TYPE_ID INTEGER Column store data type ID

CS_DATA_TYPE_NAME VARCHAR(16) Column store data type name

DDIC_DATA_TYPE_ID INTEGER DDIC data type ID

DDIC_DATA_TYPE_NAME VARCHAR(7) DDIC data type name

COMPRESSION_TYPE VARCHAR(9) Type of compression: 'DEFAULT', 'PREFIXED', 'SPARSE', 'CLUSTERED', 'INDIRECT', 'RLE'

INDEX_TYPE VARCHAR(4) Type of index: 'NONE', 'FULL'

COLUMN_ID BIGINT ID of the column

PRELOAD VARCHAR(5) Specifies if a column is preloaded: 'TRUE', 'FALSE'

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 651

Page 652: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

2.181 M_TEMPORARY_VIEWS

Temporary views

Structure

Column name Data type Description

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

SCHEMA_NAME NVARCHAR(256) Schema name

VIEW_NAME NVARCHAR(256) View name

VIEW_OID BIGINT Object ID of the view

IS_UNICODE VARCHAR(5) Specifies whether the query string contains Unicode: 'TRUE', 'FALSE'

IS_READ_ONLY VARCHAR(5) Specifies whether this view is a read-only or an updatable view: 'TRUE', 'FALSE'

HAS_CHECK_OPTION VARCHAR(5) Specifies whether this view has an updatable view condition: 'TRUE', 'FALSE'

HAS_COLUMN_ALIASE VARCHAR(5) Specifies whether the view has a columns alias : 'TRUE', 'FALSE'

DEFINITION NCLOB Definition of the view

COMMENTS NVARCHAR(5000) Description on the view

IS_COLUMN_VIEW VARCHAR(5) Specifies whether this view is a column view or not: 'TRUE', 'FALSE'

VIEW_TYPE VARCHAR(16) Type of view : 'ROW', 'OLAP', 'JOIN', 'HIERARCHY', 'CALC'

IS_TENANT_SHARED VARCHAR(5) Specifies whether the view metadata can be shared across tenants: 'TRUE', 'FALSE'

652P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 653: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

2.182 M_TEMPORARY_VIEW_COLUMNS

Columns of temporary tables

Structure

Column name Data type Description

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

SCHEMA_NAME NVARCHAR(256) Schema name

VIEW_NAME NVARCHAR(256) View name

VIEW_OID BIGINT Object ID of the view

COLUMN_NAME NVARCHAR(256) View column name

POSITION INTEGER Ordinal position of the view column

DATA_TYPE_ID SMALLINT SQL data type ID of the column

DATA_TYPE_NAME VARCHAR(16) SQL data type name of the column

OFFSET SMALLINT Offset of the column in a record

LENGTH INTEGER # of chars for char types; # of max digits for numeric types; # of chars for datetime types; # of bytes for LOB types

SCALE INTEGER Numeric types: the maximum number of digits to the right of the decimal point; time, timestamp: the decimal digits are defined as the number of digits to the right of the decimal point in the second's component of the data

IS_NULLABLE VARCHAR(5) Specifies whether the column is allowed to accept null value: 'TRUE', 'FALSE'

DEFAULT_VALUE NVARCHAR(5000) Default value

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 653

Page 654: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Description

COLLATION NVARCHAR(5000) Collation

COMMENTS NVARCHAR(5000) Description for this column

MAX_VALUE NVARCHAR(5000) Maximum value

MIN_VALUE NVARCHAR(5000) Minimum value

CS_DATA_TYPE_ID INTEGER Column store data type ID

CS_DATA_TYPE_NAME VARCHAR(16) Column store data type name

DDIC_DATA_TYPE_ID INTEGER DDIC data type ID

DDIC_DATA_TYPE_NAME VARCHAR(7) DDIC data type name

COMPRESSION_TYPE VARCHAR(9) Type of compression: 'DEFAULT', 'PREFIXED', 'SPARSE', 'CLUSTERED', 'INDIRECT', 'RLE'

INDEX_TYPE VARCHAR(4) Type of index: 'NONE', 'FULL'

COLUMN_ID BIGINT ID of the column

PRELOAD VARCHAR(5) Specifies if column is preloaded: 'TRUE', 'FALSE'

2.183 M_TENANTS

Available tenant information

Structure

Column name Data type Description

HOST VARCHAR(64) Tenant service host name

PORT INTEGER Tenant service internal port

TENANT_NAME VARCHAR(256) Tenant name

CREATE_TIME TIMESTAMP Creation time

654P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 655: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Description

TENANT_STATUS VARCHAR(16) Suspend status: SUSPENDED, ACTIVE, PENDING

SQL_PORT INTEGER Tenant service SQL port

2.184 M_TEXT_ANALYSIS_LANGUAGES

List of supported languages

Structure

Column name Data type Description

LANGUAGE_NAME VARCHAR(256) Language name

LANGUAGE_CODE VARCHAR(2) Language ISO 639-1 code

2.185 M_TEXT_ANALYSIS_MIME_TYPES

List of supported mime types

Structure

Column name Data type Description

MIME_TYPE_NAME VARCHAR(256) Name of the mime type

MIME_TYPE_DESCRIPTION NVARCHAR(256) Description of the mime type

2.186 M_TOPOLOGY_TREE

SAP HANA nameserver topology content

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 655

Page 656: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Full description

This monitoring view only returns data if you specify PATH=... . Use '/' as root path. For deeper paths use PATH+'/'+NAME. If NAME contains '/' you have to enclose it in CHR(1), For example

SELECT * FROM M_TOPOLOGY_TREE WHERE PATH='/index/'||CHR(1)||'SYSTEM:A/B'||CHR(1)||'#15046'

To change topology tree values use ALTER SYSTEM INIFILE ('topology.ini','system') set (PATH,NAME)=VALUE To delete values use ALTER SYSTEM INIFILE('topology.ini','system') remove (PATH,NAME)

Structure

Column name Data type Unit Description

PATH VARCHAR(512) Path to Key

NAME VARCHAR(256) Key name

VALUE VARCHAR(256) Key value

LEAF VARCHAR(5) Boolean Leaf flag: 'TRUE', 'FALSE'

2.187 M_TRACEFILES

All trace files

Full description

With the "CLEAR" command, all files that were opened by a service will be removed or reset to size 0. On a distributed system, this command will clear all traces on all hosts.

ALTER SYSTEM CLEAR TRACES ('ALERT','CLIENT','CRASHDUMP,'*','INDEXSERVER',...,,'DAEMON' );

It can clear different types of files:

Name Files

ALERT <service>alert....trc

656P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 657: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Name Files

CLIENT localclient_....trc

CRASHDUMP *.crashdump....trc

* open *.trc files of all active services

INDEXSERVER,NAMESERVER,...,DAEMON open *.trc files of a single service type

This command will delete files on host 'HOST_NAME'. When a service has a trace file open, then it cannot be deleted, so a "CLEAR" command should be used in that case.

ALTER SYSTEM DELETE TRACES ('HOST_NAME', 'FILENAME1', 'FILENAME2' ... );

Structure

Column name Data type Unit Description

HOST VARCHAR(64) Host name

FILE_NAME VARCHAR(256) File name

FILE_SIZE BIGINT Byte File size

FILE_MTIME TIMESTAMP File date

2.188 M_TRACEFILE_CONTENTS

SAP HANA information from trace files

Full description

This view only returns data if you specify 'HOST=... and FILE_NAME=...' as part of the where clause. Use HOST, FILE_NAME as returned by the view M_TRACEFILES. This prevents unintentional materialization of all trace files.

The optional where clause 'OFFSET<,<=,=,>,>= value' is efficiently handled by this view. With 'OFFSET > -value' you can read from the end of the file, without having to know the file size in advance. With OFFSET <> -value you can read from the start and end of a file. Do not use the equivalent OFFSET < value OR OFFSET >-value, because this is very inefficient for large files and returns duplicates for small files where the file size is < 2*value.

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 657

Page 658: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Trace files typically contain ASCII or CESU-8, but can also contain binary data. To support all kinds of data, each byte from the trace file is encoded as one NVARCHAR with values in the range 0 to 255. To recode as CESU-8 you have to use code like in this Python example:

cursor.execute(" select CONTENT from M_TRACEFILE_CONTENTS where HOST='...' and FILE_NAME='...' ")filedata=''for row in cursor.fetchall(): filedata += row[1].encode('latin-1') # reinterpret as bytearraydisplaydata = filedata.decode('utf-8','replace') # do not use 'strict' error handling

Structure

Column name Data type Unit Description

HOST VARCHAR(64) Host name

FILE_NAME VARCHAR(256) File name

OFFSET BIGINT Byte File offset

CONTENT NVARCHAR(1000) File content at offset

2.189 M_TRACE_CONFIGURATION

Trace configuration statisticsThis view has a resettable counterpart. This means, you can also see the values since the last reset in the dependent view M_TRACE_CONFIGURATION_RESET. To reset the values, use the SQL command: ALTER SYSTEM RESET MONITORING VIEW SYS.M_TRACE_CONFIGURATION_RESET or the management console command: monitor reset -n M_TRACE_CONFIGURATION_RESET

Structure

Column name Data type Unit Description

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

VOLUME_ID INTEGER Persistence Volume ID

STATISTICS_NAME VARCHAR(128) Statistics object name

658P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 659: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

TRACE_DIRECTORY VARCHAR(512) Default Trace level

FORMATTER VARCHAR(16) Trace formatter name

FILE_NAME_PREFIX VARCHAR(512) Trace file name prefix

ALERT_FORMATTER VARCHAR(16) Alert trace formatter name

ALERT_FILE_NAME_PREFIX

VARCHAR(512) Alert trace file name prefix

TRACE_FLUSH_INTERVAL

INTEGER Second Trace flush interval

ALERT_TRACE_LEVEL VARCHAR(16) Trace level for alert traces

DEFAULT_TRACE_LEVEL VARCHAR(16) Default Trace level

TRACE_BUFFER_SIZE INTEGER Byte Trace buffer size

MAX_TRACE_FILE_SIZE BIGINT Byte Max trace file size

MAX_TRACE_FILE_ID INTEGER Max trace file id

MAX_TRACE_FILES INTEGER Counter Max trace files to keep

ALERT_TRACE_BUFFER_SIZE

INTEGER Byte Alert trace buffer size

MAX_ALERT_TRACE_FILE_SIZE

BIGINT Byte Max alert trace file size

2.190 M_TRACE_CONFIGURATION_RESET

Trace configuration statistics (since last reset)This view contains values accumulated since the last reset of the main view M_TRACE_CONFIGURATION. Please refer to M_TRACE_CONFIGURATION for information about the structure and use of this view.In addition to the members mentioned in M_TRACE_CONFIGURATION, this view also contains a timestamp field RESET_TIME, which indicates the last time the data was reset.

2.191 M_TRANSACTIONS

All transactions created by users or database

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 659

Page 660: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Structure

Column name Data type Unit Description

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

CONNECTION_ID INTEGER Connection ID

TRANSACTION_ID INTEGER Transaction object ID (This number is reused after a transaction is closed)

VOLUME_ID INTEGER Volume ID where the transaction has started

PRIMARY_TRANSACTION_ID

INTEGER Primary transaction object ID for the external transaction

TRANSACTION_SEQUENCE

INTEGER Transaction sequence number in a transaction

UPDATE_TRANSACTION_ID

BIGINT Write transaction ID (This number is ever increasing)

TRANSACTION_STATUS VARCHAR(128) Transaction status; INACTIVE, ACTIVE, PRECOMMITTED, ABORTING, PARTIAL_ABORTING, ACTIVE_PREPARE_COMMIT

TRANSACTION_TYPE VARCHAR(128) Transaction type; USER, VERSION GARBAGE COLLECTION, DDL VERSION GARBAGE COLLECTION, INTERNAL, EXTERNAL

START_TIME TIMESTAMP Start time

END_TIME TIMESTAMP End time

START_MVCC_TIMESTAMP

BIGINT Internal MVCC timestamp of the transaction start time

660P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 661: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

END_MVCC_TIMESTAMP BIGINT Internal MVCC timestamp of the transaction end time

EXECUTED_STATEMENT_COUNT

INTEGER Number of executed statements in the transaction

CREATED_VERSION_COUNT

INTEGER Number of created versions in the transaction

ALLOCATED_VERSION_SIZE

BIGINT Byte Allocated version size in the transaction

ACQUIRED_LOCK_COUNT

INTEGER Number of acquired locks in the transaction

LOCK_WAIT_COUNT INTEGER Number of lock waits in the transaction

LOCK_WAIT_TIME DOUBLE Second Accumulated lock wait time in the transaction

LOG_SIZE BIGINT Byte Generated log amount in the transaction

CURRENT_STATEMENT_ID

VARCHAR(256) Current statement ID

CURRENT_STATEMENT_SEQUENCE

INTEGER Sequence number of the currently executed statement

ALLOCATED_MEMORY_SIZE

BIGINT Byte Memory size occupied by the transaction

ACQUIRED_METALOCK_INDEX

INTEGER Index of acquired metalock

LOG_PARTITION_ID SMALLINT Log partition ID of the transaction

REDO_LOG_AMOUNT BIGINT Size of redo log amount generated by the transaction

UNDO_LOG_AMOUNT BIGINT Size of undo log amount generated by the transaction

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 661

Page 662: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

MIN_MVCC_SNAPSHOT_TIMESTAMP

BIGINT Logical timestamp of the first executed statement in the transaction

LAST_COMMIT_ID BIGINT Last commit ID of the transaction

ACTIVE_STATEMENT_COUNT

INTEGER Number of opened cursors in the transaction

ISOLATION_LEVEL VARCHAR(128) Isolation level of each transaction: READ UNCOMMITTED, READ COMMITTED, REPEATABLE READ, SERIALIZABLE

LOG_FLUSH_ENABLED VARCHAR(5) TRUE if logging is enabled for the transaction, FALSE otherwise

LOGGING_ENABLED VARCHAR(5) TRUE if logging is enabled for the transaction, FALSE otherwise

2.192 M_UNDO_CLEANUP_FILES

Information about undo files and cleanup files

Full description

Each undo or cleanup file in the system is represented by one row in this view. Undo files contain information needed for transaction rollback. These files are removed on transaction end. If data is deleted but must still be accessible because of MVCC isolation, the corresponding information is written to cleanup files. On transaction end cleanup files are passed to history management. Garbage collection uses the cleanup files to finally remove data. Undo files and cleanup files may be cached and reused because of performance issues. Cached files get assigned the type "FREE". Undo files for row store get the type "EXTERNALUNDO".

662P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 663: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Structure

Column name Data type Unit Description

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

VOLUME_ID INTEGER Persistence Volume ID

TYPE VARCHAR(16) File type (UNDO, CLEANUP, EXTERNALUNDO, FREE)

TID BIGINT TID Transaction ID

PAGE_COUNT BIGINT Counter Page count

RAW_SIZE BIGINT Byte Raw size

CLEANUP_MARK BIGINT Cleanup position mark

NESTED_SESSION_ID INTEGER Nested session ID

NESTED_SESSION_PARENT_ID

INTEGER Nested session parent ID

DEPENDENT_INDEX INTEGER Dependent index during redo

INDOUBT_FLAG VARCHAR(5) Indoubt flag for distributed transaction: 'TRUE', 'FALSE'

TENTATIVE_PRECOMMIT_POSITION

BIGINT Tentative precommit position

2.193 M_VERSION_MEMORY

Memory usage of row-store Multiversion Concurrency Control (MVCC) manager

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 663

Page 664: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Structure

Column name Data type Unit Description

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

ALLOCATED_MEMORY_SIZE

BIGINT Byte Size of memory allocated for row-store version space

USED_MEMORY_SIZE BIGINT Byte Size of memory actually used by row-store versions

RECLAIMED_VERSION_SIZE

BIGINT Byte Size of memory reclaimed by row-store version garbage collection

FREE_MEMORY_SIZE BIGINT Byte Size of memory freed and reusable in row-store version space

2.194 M_VOLUMES

Volumes used by SAP HANA servers

Structure

Column name Data type Description

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

SERVICE_NAME VARCHAR(256) Service name

VOLUME_ID INTEGER Volume ID

SUBPATH VARCHAR(512) Subpath appended to M_DISKS.PATH

664P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 665: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Description

LIVECACHE_STORE VARCHAR(10) Livecache is enabled

REMOVE_STATUS VARCHAR(16) Remove progress

2.195 M_VOLUME_FILES

Information about volume files

Full description

Information about files in the volume directories. All files in these directories will be shown, but only registered files (that is, files currently used by the database) have a file type. TOTAL_SIZE is the size as reported by the file system.

The meaning of USED_SIZE depends on the file type:

● DATA: Size of used and shadow pages in this data volume file● LOG: Used size equals TOTAL_SIZE● TRACE: Used size is zero for unused trace files and equals TOTAL_SIZE for used trace files

Structure

Column name Data type Description

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

VOLUME_ID INTEGER Volume ID

FILE_TYPE VARCHAR(16) Type of file (DATA, LOG, TRACER, ...)

FILE_NAME VARCHAR(256) File name

USED_SIZE BIGINT Size of used data within file

TOTAL_SIZE BIGINT Total file size

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 665

Page 666: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

2.196 M_VOLUME_IO_DETAILED_STATISTICS

File access detailed statisticsThis view has a resettable counterpart. This means, you can also see the values since the last reset in the dependent view M_VOLUME_IO_DETAILED_STATISTICS_RESET. To reset the values, use the SQL command: ALTER SYSTEM RESET MONITORING VIEW SYS.M_VOLUME_IO_DETAILED_STATISTICS_RESET or the management console command: monitor reset -n M_VOLUME_IO_DETAILED_STATISTICS_RESET

Full description

This view shows detailed I/O statistics for various buffer sizes. Each buffer size is a max. value. That is, buffer size 4k actually means <= 4k and buffer size 16k means 4k < buffer size <= 16k. The I/O time is the total time from starting a request until it finishes, including enqueue time. All measured times are periods of time between enqueueing and finishing a request. This means they contain wait times if the request cannot be started immediately. Enqueue time is measured separately to see how many requests are executed asynchronously and how many are synchronous or blocking. For overall I/O performance, see TOTAL_READ/WRITE_SIZE and TOTAL_IO_TIME in the monitoring view M_VOLUME_IO_TOTAL_STATISTICS.

Structure

Column name Data type Description

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

VOLUME_ID INTEGER Persistence Volume ID

PATH VARCHAR(512) Filesystem path

FILESYSTEM_TYPE VARCHAR(16) Filesystem type

TYPE VARCHAR(16) Type of contained files

CONFIGURATION VARCHAR(128) Configuration parameters

MAX_IO_BUFFER_SIZE BIGINT Max. I/O buffer size

APPEND_COUNT BIGINT Count of appends

ACTIVE_APPEND_COUNT BIGINT Count of active appends

MIN_APPEND_SIZE BIGINT Size of appended data (min)

666P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 667: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Description

AVG_APPEND_SIZE BIGINT Size of appended data (avg)

MAX_APPEND_SIZE BIGINT Size of appended data (max)

MIN_APPEND_TIME BIGINT Time for appends (min)

AVG_APPEND_TIME BIGINT Time for appends (avg)

MAX_APPEND_TIME BIGINT Time for appends (max)

WRITE_COUNT BIGINT Count of writes

ACTIVE_WRITE_COUNT BIGINT Count of active writes

MIN_WRITE_SIZE BIGINT Size of written data (min)

AVG_WRITE_SIZE BIGINT Size of written data (avg)

MAX_WRITE_SIZE BIGINT Size of written data (max)

MIN_WRITE_TIME BIGINT Time for writes (min)

AVG_WRITE_TIME BIGINT Time for writes (avg)

MAX_WRITE_TIME BIGINT Time for writes (max)

TRIGGER_ASYNC_WRITE_COUNT BIGINT Count of trigger asynchronous writes

ACTIVE_TRIGGER_ASYNC_WRITE_COUNT

BIGINT Count of active trigger asynchronous writes

MIN_TRIGGER_ASYNC_WRITE_SIZE

BIGINT Size of trigger asynchronous write data (min)

AVG_TRIGGER_ASYNC_WRITE_SIZE

BIGINT Size of trigger asynchronous write data (avg)

MAX_TRIGGER_ASYNC_WRITE_SIZE

BIGINT Size of trigger asynchronous write data (max)

MIN_TRIGGER_ASYNC_WRITE_TIME

BIGINT Time for trigger asynchronous writes (min)

AVG_TRIGGER_ASYNC_WRITE_TIME

BIGINT Time for trigger asynchronous writes (avg)

MAX_TRIGGER_ASYNC_WRITE_TIME

BIGINT Time for trigger asynchronous writes (max)

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 667

Page 668: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Description

READ_COUNT BIGINT Count of reads

ACTIVE_READ_COUNT BIGINT Count of active reads

MIN_READ_SIZE BIGINT Size of read data (min)

AVG_READ_SIZE BIGINT Size of read data (avg)

MAX_READ_SIZE BIGINT Size of read data (max)

MIN_READ_TIME BIGINT Time for reads (min)

AVG_READ_TIME BIGINT Time for reads (avg)

MAX_READ_TIME BIGINT Time for reads (max)

TRIGGER_ASYNC_READ_COUNT BIGINT Count of trigger asynchronous reads

ACTIVE_TRIGGER_ASYNC_READ_COUNT

BIGINT Count of active trigger asynchronous reads

MIN_TRIGGER_ASYNC_READ_SIZE BIGINT Size of trigger asynchronous read data (min)

AVG_TRIGGER_ASYNC_READ_SIZE BIGINT Size of trigger asynchronous read data (avg)

MAX_TRIGGER_ASYNC_READ_SIZE

BIGINT Size of trigger asynchronous read data (max)

MIN_TRIGGER_ASYNC_READ_TIME BIGINT Time for trigger asynchronous reads (min)

AVG_TRIGGER_ASYNC_READ_TIME

BIGINT Time for trigger asynchronous reads (avg)

MAX_TRIGGER_ASYNC_READ_TIME

BIGINT Time for trigger asynchronous reads (max)

2.197 M_VOLUME_IO_DETAILED_STATISTICS_RESETFile access detailed statistics (since last reset)This view contains values accumulated since the last reset of the main view M_VOLUME_IO_DETAILED_STATISTICS. Please refer to M_VOLUME_IO_DETAILED_STATISTICS for information about the structure and use of this view.In addition to the members mentioned in M_VOLUME_IO_DETAILED_STATISTICS, this view also contains a timestamp field RESET_TIME, which indicates the last time the data was reset.

668P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 669: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

2.198 M_VOLUME_IO_PERFORMANCE_STATISTICS

Deprecated. Please use M_VOLUME_IO_TOTAL_STATISTICS insteadThis view has a resettable counterpart. This means, you can also see the values since the last reset in the dependent view M_VOLUME_IO_PERFORMANCE_STATISTICS_RESET. To reset the values, use the SQL command: ALTER SYSTEM RESET MONITORING VIEW SYS.M_VOLUME_IO_PERFORMANCE_STATISTICS_RESET or the management console command: monitor reset -n M_VOLUME_IO_PERFORMANCE_STATISTICS_RESET

Full description

This view shows information about I/O operations for various buffer sizes

Resetting this view implicitly resets M_VOLUME_IO_DETAILED_STATISTICS and M_VOLUME_IO_RETRY_STATISTICS.

The following table shows the differences between M_VOLUME_IO_PERFORMANCE_STATISTICS and M_VOLUME_IO_DETAILED/RETRY_STATISTICS. Columns that are only valid in M_VOLUME_IO_DETAILED/RETRY_STATISTICS are not shown.

M_VOLUME_IO_PERFORMANCE_STATISTICS

M_VOLUME_IO_DETAILED_STATISTICS

M_VOLUME_IO_RETRY_STATISTICS

Change

HOST HOST HOST none

PORT PORT PORT none

VOLUME_ID VOLUME_ID VOLUME_ID none

PATH PATH PATH none

FILESYSTEM_TYPE FILESYSTEM_TYPE FILESYSTEM_TYPE none

TYPE TYPE TYPE none

MAX_IO_BUFFER MAX_IO_BUFFER MAX_IO_BUFFER none

READ_SYNC READ_COUNT + ACTIVE_READ_COUNT

derived

WRITE_SYNC WRITE_COUNT + ACTIVE_WRITE_COUNT

derived

READ_REQUESTS TRIGGER_ASYNC_READ_COUNT + ACTIVE_TRIGGER_ASYNC_READ_COUNT

derived

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 669

Page 670: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

M_VOLUME_IO_PERFORMANCE_STATISTICS

M_VOLUME_IO_DETAILED_STATISTICS

M_VOLUME_IO_RETRY_STATISTICS

Change

WRITE_REQUESTS TRIGGER_ASYNC_WRITE_COUNT + ACTIVE_TRIGGER_ASYNC_WRITE_COUNT

derived

READ_COMPLETIONS TRIGGER_ASYNC_READ_COUNT

renamed

FAILED_READS FAILED_READS none

WRITE_COMPLETIONS TRIGGER_ASYNC_WRITE_COUNT

renamed

FAILED_WRITES FAILED_WRITES none

FULL_RETRY_READS FULL_RETRY_READS none

FULL_RETRY_WRITES FULL_RETRY_WRITES none

SHORT_READS SHORT_READS none

SHORT_WRITES SHORT_WRITES none

DELAYED_READ_REQUESTS

removed

DELAYED_WRITE_REQUESTS

removed

DEQUEUED_DELAYED_REQUESTS

removed

RESUBMITTED_DELAYED_REQUESTS

removed

RESUBMITTED_DELAYED_REQUESTS_DELAYED_AGAIN

removed

ITEMS_IN_DELAY_QUEUE removed

MAX_ITEMS_IN_DELAY_QUEUE

removed

LAST_READ_SYNC_TIME removed

MAX_READ_SYNC_TIME MAX_READ_TIME renamed

MIN_READ_SYNC_TIME MIN_READ_TIME renamed

670P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 671: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

M_VOLUME_IO_PERFORMANCE_STATISTICS

M_VOLUME_IO_DETAILED_STATISTICS

M_VOLUME_IO_RETRY_STATISTICS

Change

SUM_READ_SYNC_TIME removed

AVG_READ_SYNC_TIME AVG_READ_TIME renamed

LAST_WRITE_SYNC_TIME removed

MAX_WRITE_SYNC_TIME MAX_WRITE_TIME renamed

MIN_WRITE_SYNC_TIME MIN_WRITE_TIME renamed

SUM_WRITE_SYNC_TIME removed

AVG_WRITE_SYNC_TIME AVG_WRITE_TIME renamed

LAST_READ_TIME removed

MAX_READ_TIME MAX_READ_TIME none

MIN_READ_TIME MIN_READ_TIME none

SUM_READ_TIME removed

AVG_READ_TIME AVG_READ_TIME renamed

LAST_WRITE_TIME removed

MAX_WRITE_TIME MAX_WRITE_TIME none

MIN_WRITE_TIME MIN_WRITE_TIME none

SUM_WRITE_TIME removed

AVG_WRITE_TIME AVG_WRITE_TIME none

LAST_READ_ENQUEUE_TIME

removed

MAX_READ_ENQUEUE_TIME

removed

MIN_READ_ENQUEUE_TIME

removed

SUM_READ_ENQUEUE_TIME

removed

AVG_READ_ENQUEUE_TIME

removed

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 671

Page 672: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

M_VOLUME_IO_PERFORMANCE_STATISTICS

M_VOLUME_IO_DETAILED_STATISTICS

M_VOLUME_IO_RETRY_STATISTICS

Change

LAST_WRITE_ENQUEUE_TIME

removed

MAX_WRITE_ENQUEUE_TIME

removed

MIN_WRITE_ENQUEUE_TIME

removed

SUM_WRITE_ENQUEUE_TIME

removed

AVG_WRITE_ENQUEUE_TIME

removed

LAST_READ_SIZE removed

MAX_READ_SIZE MAX_READ_SIZE none

MIN_READ_SIZE MIN_READ_SIZE none

SUM_READ_SIZE removed

AVG_READ_SIZE AVG_READ_SIZE none

LAST_WRITE_SIZE removed

MAX_WRITE_SIZE MAX_WRITE_SIZE none

MIN_WRITE_SIZE MIN_WRITE_SIZE none

SUM_WRITE_SIZE removed

AVG_WRITE_SIZE AVG_WRITE_SIZE none

LAST_READ_SYNC_SIZE removed

MAX_READ_SYNC_SIZE MAX_READ_SIZE renamed

MIN_READ_SYNC_SIZE MIN_READ_SIZE renamed

SUM_READ_SYNC_SIZE removed

AVG_READ_SYNC_SIZE AVG_READ_SIZE renamed

LAST_WRITE_SYNC_SIZE removed

MAX_WRITE_SYNC_SIZE MAX_WRITE_SIZE renamed

672P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 673: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

M_VOLUME_IO_PERFORMANCE_STATISTICS

M_VOLUME_IO_DETAILED_STATISTICS

M_VOLUME_IO_RETRY_STATISTICS

Change

MIN_WRITE_SYNC_SIZE MIN_WRITE_SIZE renamed

SUM_WRITE_SYNC_SIZE removed

AVG_WRITE_SYNC_SIZE AVG_WRITE_SIZE renamed

Structure

Column name Data type Description

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

VOLUME_ID INTEGER Persistence Volume ID

PATH VARCHAR(512) Filesystem path

FILESYSTEM_TYPE VARCHAR(16) Filesystem type

TYPE VARCHAR(16) Type of contained files

MAX_IO_BUFFER BIGINT Max. I/O buffer size

READ_SYNC BIGINT Count of synchronous reads

WRITE_SYNC BIGINT Count of synchronous writes

READ_REQUESTS BIGINT Count of read requests

WRITE_REQUESTS BIGINT Count of write requests

READ_COMPLETIONS BIGINT Count of read completions

FAILED_READS BIGINT Count of failed reads

WRITE_COMPLETIONS BIGINT Count of write completions

FAILED_WRITES BIGINT Count of failed writes

FULL_RETRY_READS BIGINT Count of full retry reads

FULL_RETRY_WRITES BIGINT Count of full retry writes

SHORT_READS BIGINT Count of short reads

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 673

Page 674: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Description

SHORT_WRITES BIGINT Count of short writes

DELAYED_READ_REQUESTS BIGINT Count of delayed read requests

DELAYED_WRITE_REQUESTS BIGINT Count of delayed write requests

DEQUEUED_DELAYED_REQUESTS BIGINT Count of dequeued delayed requests

RESUBMITTED_DELAYED_REQUESTS

BIGINT Count of resubmitted delayed requests

RESUBMITTED_DELAYED_REQUESTS_DELAYED_AGAIN

BIGINT Count of resubmitted delayed requests delayed

ITEMS_IN_DELAY_QUEUE BIGINT Count of items in delay queue

MAX_ITEMS_IN_DELAY_QUEUE BIGINT Maximum size of delay queue

LAST_READ_SYNC_TIME BIGINT Time for synchronous reads (last)

MAX_READ_SYNC_TIME BIGINT Time for synchronous reads (max)

MIN_READ_SYNC_TIME BIGINT Time for synchronous reads (min)

SUM_READ_SYNC_TIME BIGINT Time for synchronous reads (total)

AVG_READ_SYNC_TIME BIGINT Time for synchronous reads (avg)

LAST_WRITE_SYNC_TIME BIGINT Time for synchronous writes (last)

MAX_WRITE_SYNC_TIME BIGINT Time for synchronous writes (max)

MIN_WRITE_SYNC_TIME BIGINT Time for synchronous writes (min)

SUM_WRITE_SYNC_TIME BIGINT Time for synchronous writes (total)

AVG_WRITE_SYNC_TIME BIGINT Time for synchronous writes (avg)

LAST_READ_TIME BIGINT Time for read events (last)

MAX_READ_TIME BIGINT Time for read events (max)

MIN_READ_TIME BIGINT Time for read events (min)

SUM_READ_TIME BIGINT Time for read events (total)

AVG_READ_TIME BIGINT Time for read events (avg)

LAST_WRITE_TIME BIGINT Time for write events (last)

674P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 675: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Description

MAX_WRITE_TIME BIGINT Time for write events (max)

MIN_WRITE_TIME BIGINT Time for write events (min)

SUM_WRITE_TIME BIGINT Time for write events (total)

AVG_WRITE_TIME BIGINT Time for write events (avg)

LAST_READ_ENQUEUE_TIME BIGINT Time for enqueuing read I/O events (last)

MAX_READ_ENQUEUE_TIME BIGINT Time for enqueuing read I/O events (max)

MIN_READ_ENQUEUE_TIME BIGINT Time for enqueuing read I/O events (min)

SUM_READ_ENQUEUE_TIME BIGINT Time for enqueuing read I/O events (total)

AVG_READ_ENQUEUE_TIME BIGINT Time for enqueuing read I/O events (avg)

LAST_WRITE_ENQUEUE_TIME BIGINT Time for enqueuing write I/O events (last)

MAX_WRITE_ENQUEUE_TIME BIGINT Time for enqueuing write I/O events (max)

MIN_WRITE_ENQUEUE_TIME BIGINT Time for enqueuing write I/O events (min)

SUM_WRITE_ENQUEUE_TIME BIGINT Time for enqueuing write I/O events (total)

AVG_WRITE_ENQUEUE_TIME BIGINT Time for enqueuing write I/O events (avg)

LAST_READ_SIZE BIGINT Size of read data (last)

MAX_READ_SIZE BIGINT Size of read data (max)

MIN_READ_SIZE BIGINT Size of read data (min)

SUM_READ_SIZE BIGINT Size of read data (total)

AVG_READ_SIZE BIGINT Size of read data (avg)

LAST_WRITE_SIZE BIGINT Size of written data (last)

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 675

Page 676: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Description

MAX_WRITE_SIZE BIGINT Size of written data (max)

MIN_WRITE_SIZE BIGINT Size of written data (min)

SUM_WRITE_SIZE BIGINT Size of written data (total)

AVG_WRITE_SIZE BIGINT Size of written data (avg)

LAST_READ_SYNC_SIZE BIGINT Size of synchronously read data (last)

MAX_READ_SYNC_SIZE BIGINT Size of synchronously read data (max)

MIN_READ_SYNC_SIZE BIGINT Size of synchronously read data (min)

SUM_READ_SYNC_SIZE BIGINT Size of synchronously read data (total)

AVG_READ_SYNC_SIZE BIGINT Size of synchronously read data (avg)

LAST_WRITE_SYNC_SIZE BIGINT Size of synchronously written data (last)

MAX_WRITE_SYNC_SIZE BIGINT Size of synchronously written data (max)

MIN_WRITE_SYNC_SIZE BIGINT Size of synchronously written data (min)

SUM_WRITE_SYNC_SIZE BIGINT Size of synchronously written data (total)

AVG_WRITE_SYNC_SIZE BIGINT Size of synchronously written data (avg)

2.199 M_VOLUME_IO_PERFORMANCE_STATISTICS_RESET

Deprecated. Please use M_VOLUME_IO_TOTAL_STATISTICS instead (since last reset)This view contains values accumulated since the last reset of the main view M_VOLUME_IO_PERFORMANCE_STATISTICS. Please refer to M_VOLUME_IO_PERFORMANCE_STATISTICS for information about the structure and use of this view.In addition to the members mentioned in M_VOLUME_IO_PERFORMANCE_STATISTICS, this view also contains a timestamp field RESET_TIME, which indicates the last time the data was reset.

676P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 677: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

2.200 M_VOLUME_IO_RETRY_STATISTICS

File access retry statisticsThis view has a resettable counterpart. This means, you can also see the values since the last reset in the dependent view M_VOLUME_IO_RETRY_STATISTICS_RESET. To reset the values, use the SQL command: ALTER SYSTEM RESET MONITORING VIEW SYS.M_VOLUME_IO_RETRY_STATISTICS_RESET or the management console command: monitor reset -n M_VOLUME_IO_RETRY_STATISTICS_RESET

Full description

This view shows retry and error I/O statistics for various buffer sizes. Each buffer size is a max. value. That is, buffer size 4k actually means <= 4k and buffer size 16k means 4k < buffer size <= 16k. For overall I/O performance, see TOTAL_READ/WRITE_SIZE and TOTAL_IO_TIME in the monitoring view M_VOLUME_IO_TOTAL_STATISTICS.

Structure

Column name Data type Description

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

VOLUME_ID INTEGER Persistence Volume ID

PATH VARCHAR(512) Filesystem path

FILESYSTEM_TYPE VARCHAR(16) Filesystem type

TYPE VARCHAR(16) Type of contained files

CONFIGURATION VARCHAR(128) Configuration parameters

MAX_IO_BUFFER_SIZE BIGINT Max. I/O buffer size

TOTAL_APPEND_COUNT BIGINT Count of all appends

FAILED_APPEND_COUNT BIGINT Count of failed appends

TOTAL_WRITE_COUNT BIGINT Count of all writes

FAILED_WRITE_COUNT BIGINT Count of failed writes

SHORT_WRITE_COUNT BIGINT Count of short writes

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 677

Page 678: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Description

REQUESTS_WITH_SHORT_WRITES_COUNT

BIGINT Count of requests with short writes

AVG_SHORT_WRITES_PER_REQUEST_COUNT

BIGINT Count of short writes per request with short writes (avg)

MAX_SHORT_WRITES_PER_REQUEST_COUNT

BIGINT Count of short writes per request (max)

FULL_RETRY_WRITE_COUNT BIGINT Count of full retry writes

REQUESTS_WITH_FULL_RETRY_WRITES_COUNT

BIGINT Count of requests with full retry writes

AVG_FULL_RETRY_WRITES_PER_REQUEST_COUNT

BIGINT Count of full retry writes per request with full retry writes (avg)

MAX_FULL_RETRY_WRITES_PER_REQUEST_COUNT

BIGINT Count of full retry writes per request (max)

TOTAL_READ_COUNT BIGINT Count of all reads

FAILED_READ_COUNT BIGINT Count of failed reads

SHORT_READ_COUNT BIGINT Count of short reads

REQUESTS_WITH_SHORT_READS_COUNT

BIGINT Count of requests with short reads

AVG_SHORT_READS_PER_REQUEST_COUNT

BIGINT Count of short reads per request with short reads (avg)

MAX_SHORT_READS_PER_REQUEST_COUNT

BIGINT Count of short reads per request (max)

FULL_RETRY_READ_COUNT BIGINT Count of full retry reads

REQUESTS_WITH_FULL_RETRY_READS_COUNT

BIGINT Count of requests with full retry reads

AVG_FULL_RETRY_READS_PER_REQUEST_COUNT

BIGINT Count of full retry reads per request with full retry reads (avg)

MAX_FULL_RETRY_READS_PER_REQUEST_COUNT

BIGINT Count of full retry reads per request (max)

678P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 679: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

2.201 M_VOLUME_IO_RETRY_STATISTICS_RESET

File access retry statistics (since last reset)This view contains values accumulated since the last reset of the main view M_VOLUME_IO_RETRY_STATISTICS. Please refer to M_VOLUME_IO_RETRY_STATISTICS for information about the structure and use of this view.In addition to the members mentioned in M_VOLUME_IO_RETRY_STATISTICS, this view also contains a timestamp field RESET_TIME, which indicates the last time the data was reset.

2.202 M_VOLUME_IO_STATISTICS

Deprecated. Please use M_VOLUME_IO_TOTAL_STATISTICS insteadThis view has a resettable counterpart. This means, you can also see the values since the last reset in the dependent view M_VOLUME_IO_STATISTICS_RESET. To reset the values, use the SQL command: ALTER SYSTEM RESET MONITORING VIEW SYS.M_VOLUME_IO_STATISTICS_RESET or the management console command: monitor reset -n M_VOLUME_IO_STATISTICS_RESET

Full description

This view shows information about basic I/O operations on I/O subsystems (that is, paths). Please refer to M_VOLUME_IO_PERFORMANCE_STATISTICS for detailed information about read/write performance on various buffer sizes.

TOTAL_READ/WRITE _SIZE is aggregated from M_VOLUME_IO_PERFORMANCE_STATISTICS. Note that the column TOTAL_IO_TIME is only an approximation of real I/O times and should not be used to compute exact throughput ratios.

Resetting this view implicitly resets the dependent child views M_VOLUME_IO_DETAILED_STATISTICS and M_VOLUME_IO_RETRY_STATISTICS.

The following table shows the differences between M_VOLUME_IO_STATISTICS and M_VOLUME_IO_TOTAL_STATISTICS. Columns that are only valid in M_VOLUME_IO_TOTAL_STATISTICS are not shown.

M_VOLUME_IO_STATISTICS M_VOLUME_IO_TOTAL_STATISTICS

Change

HOST HOST none

PORT PORT none

PATH PATH none

FILESYSTEM_TYPE FILESYSTEM_TYPE none

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 679

Page 680: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

M_VOLUME_IO_STATISTICS M_VOLUME_IO_TOTAL_STATISTICS

Change

TYPE TYPE none

CONFIGURATION CONFIGURATION none

OPEN_CALL_COUNT removed

CLOSE_CALL_COUNT removed

EXISTS_CALL_COUNT removed

REMOVE_CALL_COUNT removed

RESIZE_CALL_COUNT removed

SYNC_CALL_COUNT removed

GETSIZE_CALL_COUNT removed

GETMODIFICATIONTIME_CALL_COUNT

removed

GETDEVICEID_CALL_COUNT removed

ENQUEUED_WRITE_REQUESTS removed

BLOCKED_WRITE_REQUESTS BLOCKED_WRITE_REQUESTS none

MAX_BLOCKED_WRITE_REQUESTS

MAX_BLOCKED_WRITE_REQUESTS

none

EOF_READS removed

TOTAL_SYNC_READS TOTAL_READS renamed

TOTAL_ASYNC_READS removed

TOTAL_TRIGGER_ASYNC_READS TOTAL_TRIGGER_ASYNC_READS none

TRIGGER_ASYNC_READ_RATIO TRIGGER_READ_RATIO renamed

TOTAL_SHORT_READS TOTAL_SHORT_READS none

TOTAL_FULL_RETRY_READS TOTAL_FULL_RETRY_READS none

TOTAL_FAILED_READS TOTAL_FAILED_READS none

TOTAL_READ_SIZE TOTAL_READ_SIZE none

TOTAL_READ_TIME TOTAL_READ_TIME none

680P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 681: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

M_VOLUME_IO_STATISTICS M_VOLUME_IO_TOTAL_STATISTICS

Change

TOTAL_APPENDS TOTAL_APPENDS none

TOTAL_SYNC_WRITES TOTAL_WRITES renamed

TOTAL_ASYNC_WRITES removed

TOTAL_TRIGGER_ASYNC_WRITES TOTAL_TRIGGER_ASYNC_WRITES none

TRIGGER_ASYNC_WRITE_RATIO TRIGGER_WRITE_RATIO renamed

TOTAL_SHORT_WRITES TOTAL_SHORT_WRITES none

TOTAL_FULL_RETRY_WRITES TOTAL_FULL_RETRY_WRITES none

TOTAL_FAILED_WRITES TOTAL_FAILED_WRITES none

TOTAL_WRITE_SIZE TOTAL_WRITE_SIZE none

TOTAL_WRITE_TIME TOTAL_WRITE_TIME none

TOTAL_IO_TIME TOTAL_IO_TIME none

Structure

Column name Data type Description

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

VOLUME_ID INTEGER Persistence Volume ID

PATH VARCHAR(512) Filesystem path

FILESYSTEM_TYPE VARCHAR(16) Filesystem type

TYPE VARCHAR(16) Type of contained files

CONFIGURATION VARCHAR(128) Configuration parameters

OPEN_CALL_COUNT BIGINT Count of open calls

CLOSE_CALL_COUNT BIGINT Count of close calls

EXISTS_CALL_COUNT BIGINT Count of exists calls

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 681

Page 682: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Description

REMOVE_CALL_COUNT BIGINT Count of remove calls

RESIZE_CALL_COUNT BIGINT Count of resize calls

SYNC_CALL_COUNT BIGINT Count of sync calls

GETSIZE_CALL_COUNT BIGINT Count of get size calls

GETMODIFICATIONTIME_CALL_COUNT

BIGINT Count of get modification time calls

GETDEVICEID_CALL_COUNT BIGINT Count of get DeviceID calls

ENQUEUED_WRITE_REQUESTS BIGINT Count of enqueued write requests (deprecated)

BLOCKED_WRITE_REQUESTS BIGINT Count of blocked write requests

MAX_BLOCKED_WRITE_REQUESTS

BIGINT Max. count of blocked write requests

EOF_READS BIGINT Count of EOF reads

TOTAL_SYNC_READS BIGINT Count of synchronous reads

TOTAL_ASYNC_READS BIGINT Count of asynchronous reads with waiting

TOTAL_TRIGGER_ASYNC_READS BIGINT Count of triggered asynchronous reads

TRIGGER_ASYNC_READ_RATIO DOUBLE Trigger-Ratio of asynchronous reads

TOTAL_SHORT_READS BIGINT Count of reads that read less bytes than requested

TOTAL_FULL_RETRY_READS BIGINT Count of full retry reads

TOTAL_FAILED_READS BIGINT Count of failed reads

TOTAL_READ_SIZE BIGINT Size of read data

TOTAL_READ_TIME BIGINT Total read time

TOTAL_APPENDS BIGINT Count of appends

TOTAL_SYNC_WRITES BIGINT Count of synchronous writes

682P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 683: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Description

TOTAL_ASYNC_WRITES BIGINT Count of asynchronous writes with waiting

TOTAL_TRIGGER_ASYNC_WRITES BIGINT Count of triggered asynchronous writes

TRIGGER_ASYNC_WRITE_RATIO DOUBLE Trigger-Ratio of asynchronous writes

TOTAL_SHORT_WRITES BIGINT Count of writes that wrote less bytes than requested

TOTAL_FULL_RETRY_WRITES BIGINT Count of full retry writes

TOTAL_FAILED_WRITES BIGINT Count of failed writes

TOTAL_WRITE_SIZE BIGINT Size of written data

TOTAL_WRITE_TIME BIGINT Total write time

TOTAL_IO_TIME BIGINT Total IO time

2.203 M_VOLUME_IO_STATISTICS_RESET

Deprecated. Please use M_VOLUME_IO_TOTAL_STATISTICS instead (since last reset)This view contains values accumulated since the last reset of the main view M_VOLUME_IO_STATISTICS. Please refer to M_VOLUME_IO_STATISTICS for information about the structure and use of this view.In addition to the members mentioned in M_VOLUME_IO_STATISTICS, this view also contains a timestamp field RESET_TIME, which indicates the last time the data was reset.

2.204 M_VOLUME_IO_TOTAL_STATISTICS

File access statisticsThis view has a resettable counterpart. This means, you can also see the values since the last reset in the dependent view M_VOLUME_IO_TOTAL_STATISTICS_RESET. To reset the values, use the SQL command: ALTER SYSTEM RESET MONITORING VIEW SYS.M_VOLUME_IO_TOTAL_STATISTICS_RESET or the management console command: monitor reset -n M_VOLUME_IO_TOTAL_STATISTICS_RESET

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 683

Page 684: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Structure

Column name Data type Unit Description

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

VOLUME_ID INTEGER Persistence Volume ID

PATH VARCHAR(512) Filesystem path

FILESYSTEM_TYPE VARCHAR(16) Filesystem type

TYPE VARCHAR(16) Type of contained files

CONFIGURATION VARCHAR(128) Configuration parameters

BLOCKED_WRITE_REQUESTS

BIGINT Counter Count of blocked write requests

MAX_BLOCKED_WRITE_REQUESTS

BIGINT Counter Max. count of blocked write requests

TOTAL_READS BIGINT Counter Count of synchronous reads

TOTAL_TRIGGER_ASYNC_READS

BIGINT Counter Count of triggered asynchronous reads

TRIGGER_READ_RATIO DOUBLE Percent Trigger-Ratio of asynchronous reads

TOTAL_SHORT_READS BIGINT Counter Count of reads that read less bytes than requested

TOTAL_FULL_RETRY_READS

BIGINT Counter Count of full retry reads

TOTAL_FAILED_READS BIGINT Counter Count of failed reads

TOTAL_READ_SIZE BIGINT Byte Size of read data

TOTAL_READ_TIME BIGINT Microsecond Total read time

TOTAL_APPENDS BIGINT Counter Count of appends

TOTAL_WRITES BIGINT Counter Count of synchronous writes

684P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 685: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

TOTAL_TRIGGER_ASYNC_WRITES

BIGINT Counter Count of triggered asynchronous writes

TRIGGER_WRITE_RATIO DOUBLE Percent Trigger-Ratio of asynchronous writes

TOTAL_SHORT_WRITES BIGINT Counter Count of writes that wrote less bytes than requested

TOTAL_FULL_RETRY_WRITES

BIGINT Counter Count of full retry writes

TOTAL_FAILED_WRITES BIGINT Counter Count of failed writes

TOTAL_WRITE_SIZE BIGINT Byte Size of written data

TOTAL_WRITE_TIME BIGINT Microsecond Total write time

TOTAL_IO_TIME BIGINT Microsecond Total IO time

2.205 M_VOLUME_IO_TOTAL_STATISTICS_RESET

File access statistics (since last reset)This view contains values accumulated since the last reset of the main view M_VOLUME_IO_TOTAL_STATISTICS. Please refer to M_VOLUME_IO_TOTAL_STATISTICS for information about the structure and use of this view.In addition to the members mentioned in M_VOLUME_IO_TOTAL_STATISTICS, this view also contains a timestamp field RESET_TIME, which indicates the last time the data was reset.

2.206 M_VOLUME_SIZES

Volume sizes used by SAP HANA servers

Structure

Column name Data type Unit Description

VOLUME_ID INTEGER Volume ID. See M_VOLUMES

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 685

Page 686: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Unit Description

DISK_ID INTEGER Disk ID. See M_DISKS

DATA_SIZE BIGINT Byte Data area size

LOG_SIZE BIGINT Byte Log area size

2.207 M_WORKLOAD

Database workload collected every minute

Structure

Column name Data type Description

HOST VARCHAR(64) Host name

PORT INTEGER Internal port

EXECUTION_COUNT BIGINT Total count of all executed statements for data manipulation, data definition, and system control

COMPILATION_COUNT BIGINT Number of statement preparation

UPDATE_TRANSACTION_COUNT BIGINT Number of update transactions

COMMIT_COUNT BIGINT Number of transaction commits

ROLLBACK_COUNT BIGINT Number of transaction rollbacks

CURRENT_EXECUTION_RATE DOUBLE Current statement execution count per minute

PEAK_EXECUTION_RATE DOUBLE Peak statement execution count per minute

CURRENT_COMPILATION_RATE DOUBLE Current statement preparation count per minute

PEAK_COMPILATION_RATE DOUBLE Peak statement preparation count per minute

686P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 687: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Description

CURRENT_UPDATE_TRANSACTION_RATE

DOUBLE Current update transaction count per minute

PEAK_UPDATE_TRANSACTION_RATE

DOUBLE Peak update transaction count per minute

CURRENT_TRANSACTION_RATE DOUBLE Current transaction count per minute

PEAK_TRANSACTION_RATE DOUBLE Peak transaction count per minute

CURRENT_COMMIT_RATE DOUBLE Total number of commits per minute

PEAK_COMMIT_RATE DOUBLE Peak commit counts per minute

CURRENT_ROLLBACK_RATE DOUBLE Total number of rollbacks per minute

PEAK_ROLLBACK_RATE DOUBLE Peak rollback count per minute

CURRENT_MEMORY_USAGE_RATE DOUBLE Total size of used memory per minute

PEAK_MEMORY_USAGE_RATE DOUBLE Peak size of used memory per minute

2.208 M_XS_APPLICATIONS

Applications deployed and running in SAP HANA XS

Structure

Column name Data type Description

APPLICATION_NAME NVARCHAR(256) Name of the application

DELIVERY_UNIT NVARCHAR(256) Name of the delivery unit that this application belongs to

VENDOR NVARCHAR(256) Vendor of the delivery unit

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 687

Page 688: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Description

VERSION NVARCHAR(256) Version information of the delivery unit

VERSION_SP NVARCHAR(16) SP version information of the delivery unit

VERSION_PATCH NVARCHAR(16) Patch version information of the delivery unit

2.209 M_XS_APPLICATION_ISSUES

Issues related to applications in SAP HANA XS

Structure

Column name Data type Description

APPLICATION_NAME NVARCHAR(256) Name of the application

ERROR_MESSAGE VARCHAR(1024) Textual description of the issue

2.210 OBJECTS

Available objects

Structure

Column name Data type Description

OBJECT_CATEGORY VARCHAR(1) Object category of the object (default = null)

SCHEMA_NAME NVARCHAR(256) Schema name of the object

688P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 689: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Description

OBJECT_NAME NVARCHAR(256) Object name

OBJECT_TYPE VARCHAR(32) Object type

OBJECT_OID BIGINT Object ID

2.211 OBJECT_DEPENDENCIES

Dependencies between objects, for example, views which refer to a specific table

Structure

Column name Data type Description

BASE_SCHEMA_NAME NVARCHAR(256) Schema name of the base object

BASE_OBJECT_NAME NVARCHAR(256) Object name of the base object

BASE_OBJECT_TYPE VARCHAR(32) Type of the base object

DEPENDENT_SCHEMA_NAME NVARCHAR(256) Schema name of the dependent object

DEPENDENT_OBJECT_NAME NVARCHAR(256) Object name of the dependent object

DEPENDENT_OBJECT_TYPE VARCHAR(32) Type of the base dependent

DEPENDENCY_TYPE INTEGER Type of dependency between base and dependent object

2.212 OWNERSHIP

Ownership of available objects when users create any object in other users' schemas

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 689

Page 690: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Structure

Column name Data type Description

SCHEMA_NAME NVARCHAR(256) Schema name of the object

OWNER_NAME NVARCHAR(256) Name of the object owner

OBJECT_NAME NVARCHAR(256) Object name

OBJECT_TYPE VARCHAR(32) Object type

OBJECT_OID BIGINT Object ID

2.213 PRIVILEGES

Available privileges

Structure

Column name Data type Description

NAME NVARCHAR(256) Privilege name

TYPE VARCHAR(32) 'SYSTEMPRIVILEGE', 'OBJECTPRIVILEGE', 'PACKAGEPRIVILEGE', 'APPLICATIONPRIVILEGE'

2.214 PROCEDURES

Available stored procedures

690P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 691: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Structure

Column name Data type Description

SCHEMA_NAME NVARCHAR(256) Schema name of the stored procedure

PROCEDURE_NAME NVARCHAR(256) Name of the stored procedure

PROCEDURE_OID BIGINT Object ID of the stored procedure

DEFAULT_SCHEMA_NAME NVARCHAR(256) Schema name of the unqualified objects in the procedure

INPUT_PARAMETER_COUNT INTEGER Input type parameter count

OUTPUT_PARAMETER_COUNT INTEGER Output type parameter count

INOUT_PARAMETER_COUNT INTEGER In-out type parameter count

RESULT_SET_COUNT INTEGER Result set count

IS_UNICODE VARCHAR(5) Specifies whether the stored procedure contains Unicode or not: 'TRUE', 'FALSE'

DEFINITION NCLOB Query string of the stored procedure

PROCEDURE_TYPE VARCHAR(10) Type of the stored procedure

READ_ONLY VARCHAR(5) Specifies whether the procedure is read-only or not: 'TRUE', 'FALSE'

IS_VALID VARCHAR(5) Specifies whether the procedure is valid or not. This becomes 'FALSE' when its base objects are changed or dropped: 'TRUE', 'FALSE'

2.215 PROCEDURE_OBJECTS

Contains results of the system procedure GET_PROCEDURE_OBJECTS

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 691

Page 692: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Structure

Column name Data type Description

SCHEMA_NAME NVARCHAR(128) Schema name of the stored procedure

PROCEDURE_NAME NVARCHAR(128) Procedure name of the stored procedure

OBJECT_SCHEMA NVARCHAR(128) Schema name of the object in the stored procedure code

OBJECT_NAME NVARCHAR(128) Object name of the object in the stored procedure code

OBJECT_TYPE_ID INTEGER Type ID of the object in the stored procedure code

OBJECT_TYPE VARCHAR(32) Type of the object in the stored procedure code

START_POSITION INTEGER Start position of the object in the stored procedure code

END_POSITION INTEGER End position of the object in the stored procedure code

2.216 PROCEDURE_PARAMETERS

Parameters of stored procedures

Structure

Column name Data type Description

SCHEMA_NAME NVARCHAR(256) Schema name of the stored procedure

PROCEDURE_NAME NVARCHAR(256) Name of the stored procedure

PROCEDURE_OID BIGINT Object ID of the stored procedure

692P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 693: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Description

PARAMETER_NAME NVARCHAR(256) Parameter name

DATA_TYPE_ID SMALLINT Data type ID

DATA_TYPE_NAME VARCHAR(16) Data type name

LENGTH INTEGER Parameter length

SCALE INTEGER Scale of the parameter

POSITION INTEGER Ordinal position of the parameter

TABLE_TYPE_SCHEMA NVARCHAR(256) Schema name of table type if DATA_TYPE_NAME is TABLE_TYPE

TABLE_TYPE_NAME NVARCHAR(256) Name of table type if DATA_TYPE_NAME is TABLE_TYPE

PARAMETER_TYPE VARCHAR(7) Parameter mode: 'IN', 'OUT', 'INOUT'

HAS_DEFAULT_VALUE VARCHAR(5) Specifies whether the parameter has a default value or not: 'TRUE', 'FALSE'

IS_NULLABLE VARCHAR(5) Specifies whether the parameter accepts a null value: 'TRUE', 'FALSE'

2.217 QUERY_PLANS

Plans how to handle query execution

Structure

Column name Data type Description

PLAN_ID VARCHAR(256) Plan ID

OPERATOR_NAME VARCHAR(5000) Operator name

OPERATOR_DETAILS NCLOB Detailed information on operators in the query plan

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 693

Page 694: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Description

OBJECT_NAME NVARCHAR(256) Object name

SUBTREE_COST DOUBLE Subtree cost

INPUT_CARDINALITY DOUBLE Input cardinality

OUTPUT_CARDINALITY DOUBLE Output cardinality

OPERATOR_ID INTEGER Operator ID

PARENT_OPERATOR_ID INTEGER Parent operator ID

LEVEL INTEGER Level

POSITION INTEGER Position

TIMESTAMP TIMESTAMP Timestamp

HOST VARCHAR(256) Host where the plan operator is executed

PORT INTEGER Port where the plan operator is executed

2.218 REFERENTIAL_CONSTRAINTS

Referential constraints

Structure

Column name Data type Description

SCHEMA_NAME NVARCHAR(256) Schema name

TABLE_NAME NVARCHAR(256) Table name

COLUMN_NAME NVARCHAR(256) Column name

POSITION SMALLINT Column position in this constraint

CONSTRAINT_NAME NVARCHAR(256) Constraint name

694P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 695: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Description

REFERENCED_SCHEMA_NAME NVARCHAR(256) Schema name of the table referenced by this constraint

REFERENCED_TABLE_NAME NVARCHAR(256) Table name of the table referenced by this constraint

REFERENCED_COLUMN_NAME NVARCHAR(256) Name of column referenced by this column

REFERENCED_CONSTRAINT_NAME

NVARCHAR(256) Name of unique constraint referenced by this constraint

UPDATE_RULE VARCHAR(16) Update rule: 'CASCADE', 'SET NULL', 'SET DEFAULT', 'RESTRICT'

DELETE_RULE VARCHAR(16) Delete rule: 'CASCADE', 'SET NULL', 'SET DEFAULT', 'RESTRICT'

2.219 REMOTE_SOURCES

Remote sources

Structure

Column name Data type Description

REMOTE_SOURCE_NAME NVARCHAR(256) Remote source name

ADAPTER_NAME NVARCHAR(256) Adapter name

CONNECTION_INFO NVARCHAR(256) Connection information

2.220 REORG_OVERVIEW

Overview of landscape redistributions

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 695

Page 696: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Full description

This view contains information about table redistribution executions on this system. Each call to REORG_EXECUTE will be stored in this view. Execution duration, status of each table redistribution on this system can be determined.

NoteOnly executed plan information will be stored in this view. Calls of REORG_GENERATE without REORG_EXECUTE will not appear in this view.

The columns contain the following information "REORG_ID" the unique identifier for the executed reorg plan. "STATUS" Status of the plan execution. Status may be

● "STARTED" the plan execution was started● "FINSHED" the plan exection finished successfull● "FAILED" the plan exection was treated as failed "START_DATE" timestamp when the plan execution have

started "END_DATE" timestamp when plan execution has stopped. This field remains empty until the exection is running. in case of reboots during plan execution, this field remains empty. "USER" The user, that has executed the table redistribution "ALGORITHM_ID" the id of the algorithm for the table redistribution "PARAMETERS" the parameters given for the table redistribution call

Structure

Column name Data type Description

REORG_ID INTEGER Reorg ID

STATUS VARCHAR(32) Status message

START_DATE TIMESTAMP Start date

END_DATE TIMESTAMP End date

USER VARCHAR(256) User

ALGORITHM_ID INTEGER Algorithm ID

PARAMETERS VARCHAR(1024) Parameter values for algorithm

2.221 REORG_PLAN

Current plan for landscape reorganization

696P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 697: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Full description

This view contains the last table redistribution plan generated with this database connection. The contens is session temporary stored and will be deleted when the connection is closed.

Structure

Column name Data type Description

STEP_ID INTEGER Step ID

SCHEMA_NAME NVARCHAR(256) Table name

TABLE_NAME NVARCHAR(256) Schema name

NEW_PARTITION_SPEC NCLOB New partition specification

OLD_PARTITION_SPEC NCLOB Old partition specification

PARTITION INTEGER Partition ID

NEW_HOST VARCHAR(64) Host where the table/partition is moved to

NEW_PORT INTEGER Port where the table/partition is moved to

OLD_HOST VARCHAR(64) Host where the table/partition was located

OLD_PORT INTEGER Port where the table/partition was located

2.222 REORG_PLAN_INFOS

Additional informations about current landscape reorganization plan

Full description

This view contains information about the last table redistribution plan generation with this database connection. The contens is session temporary stored and will be deleted when the connection is closed. The following describes the contents of the individual lines of this view (VALUE), as identified by KEY:

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 697

Page 698: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

MOVE_PHYSICALIndicates that all move operations during plan execution will be executed as physical moves. Possible Values are '0' or '1'

ALGORITHM_IDThe ID of the reorg algorithm used for generating the corresponding table redistribution plan.

PARAMETERSthe parameter information of the last table redist plan generation call.

Structure

Column name Data type Description

KEY VARCHAR(256) Key

VALUE VARCHAR(1024) Value

2.223 REORG_STEPS

Details of landscape redistribution

Full description

This view contains the executed or to be exected table redistribution plan items.

Structure

Column name Data type Description

REORG_ID INTEGER Reorg ID

STEP_ID INTEGER Step ID

SCHEMA_NAME NVARCHAR(256) Table name

698P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 699: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Description

TABLE_NAME NVARCHAR(256) Schema name

NEW_PARTITION_SPEC NCLOB New partition specification

OLD_PARTITION_SPEC NCLOB Old partition specification

PARTITION INTEGER Partition ID

NEW_HOST VARCHAR(64) Host where the table/partition is moved to

NEW_PORT INTEGER Port where the table/partition is moved to

OLD_HOST VARCHAR(64) Host where the table/partition was located

OLD_PORT INTEGER Port where the table/partition was located

STATUS VARCHAR(32) Status message

ERROR VARCHAR(1024) Error message

START_DATE TIMESTAMP Start date

END_DATE TIMESTAMP End date

2.224 ROLES

Shows available roles

Structure

Column name Data type Description

ROLE_NAME NVARCHAR(256) Role name

ROLE_ID BIGINT Role ID

ROLE_MODE VARCHAR(5) Mode of the role: 'LOCAL'

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 699

Page 700: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Description

GLOBAL_IDENTITY NVARCHAR(256) Identity specified for role with ROLE_MODE GLOBAL

CREATOR NVARCHAR(256) Name of user who created the role

CREATE_TIME TIMESTAMP Time the role was created

2.225 SAML_PROVIDERS

Shows available SAML provider

Structure

Column name Data type Description

SAML_PROVIDER_NAME NVARCHAR(256) Provider name

SUBJECT_NAME NVARCHAR(512) Subject of the X.509 certificate of the SAML provider

ISSUER_NAME NVARCHAR(512) Issuer of the X.509 certificate of the SAML provider

2.226 SAML_USER_MAPPINGS

Shows the SAML providers known for each user

Structure

Column name Data type Description

USER_NAME NVARCHAR(256) User name

SAML_PROVIDER_NAME NVARCHAR(256) Provider name

700P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 701: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Description

EXTERNAL_IDENTITY NVARCHAR(256) Name of the user known to the provider

2.227 SCHEMAS

Shows available schemas

Structure

Column name Data type Description

SCHEMA_NAME NVARCHAR(256) Schema name

SCHEMA_OWNER NVARCHAR(256) Schema owner

HAS_PRIVILEGES VARCHAR(5) Shows if user is schema owner or has any privilege for the schema or any object within the schema: 'TRUE', 'FALSE'

2.228 SEARCH_RULE_SETS

Shows information about available search rule sets

Structure

Column name Data type Description

SEARCH_RULE_SET_PACKAGE_ID NVARCHAR(256) Name of the repository package of the search rule set

SEARCH_RULE_SET_NAME NVARCHAR(256) Name of the search rule set

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 701

Page 702: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Description

SEARCHED_SCHEMA_NAME NVARCHAR(256) Schema name of the catalog object that is searched by the given search rule set

SEARCHED_OBJECT_NAME NVARCHAR(256) Name of the catalog object that is searched by the given search rule set

SEARCHED_REPOSITORY_PACKAGE_ID

NVARCHAR(256) Name of the repository package of the repository object that is searched by the given search rule set

SEARCHED_REPOSITORY_OBJECT_NAME

NVARCHAR(256) Name of the repository object that is searched by the given search rule set

2.229 SEARCH_RULE_SET_CONDITIONS

Shows conditions to available search rule sets

Structure

Column name Data type Description

SEARCH_RULE_SET_PACKAGE_ID NVARCHAR(256) Name of the repository package of the search rule set

SEARCH_RULE_SET_NAME NVARCHAR(256) Name of the search rule set

RULE_NUMBER INTEGER Number of the rule that contains the column

RULE_ID NVARCHAR(256) Unique ID/name of the rule that contains the column

SEARCHED_COLUMN_NAME NVARCHAR(256) Name of a column that is used by a search rule set

SEARCHED_COLUMN_CONDITION NVARCHAR(20) The condition. Possible values are EQUALS, NOT EMPTY, MISSING

702P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 703: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Description

SEARCHED_COLUMN_VALUE NVARCHAR(5000) The value the user input is compared to, if condition is EQUALS

SEARCHED_COLUMN_VALUE_REPLACED_BY

NVARCHAR(5000) The user input is replaced by this value if the action is REPLACE

ACTION NVARCHAR(20) Action that is done when the condition is true. Possible values are SKIP COLUMN, SKIP RULE, REPLACE

2.230 SEQUENCES

Available sequences

Structure

Column name Data type Description

SCHEMA_NAME NVARCHAR(256) Schema name of the sequence

SEQUENCE_NAME NVARCHAR(256) Name of the sequence

SEQUENCE_OID BIGINT Object ID of the sequence

START_NUMBER BIGINT Start number

MIN_VALUE BIGINT Minimum value of the sequence

MAX_VALUE BIGINT Maximum value of the sequence

INCREMENT_BY BIGINT Incremental value

IS_CYCLED VARCHAR(5) Specifies whether the sequence will start with MIN_VALUE after having reached MAX_VALUE in case of INCREMENT_BY greater than 0 or start with MAX_VALUE after having reached MIN_VALUE in case of INCREMENT_BY less than 0: 'TRUE', 'FALSE'

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 703

Page 704: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Description

RESET_BY_QUERY NCLOB Reset by query string for the sequence

CACHE_SIZE SMALLINT Cache size of the sequence

2.231 SESSION_COOKIES

Shows information about available session cookies

Structure

Column name Data type Description

USER_NAME NVARCHAR(256) Name of the user this session cookie was created for

CLIENT_HOST NVARCHAR(64) Host name of client machine

CLIENT_PID BIGINT Client Process ID

CREATE_TIME TIMESTAMP The time the session cookie was created

LAST_CONNECT_TIME TIMESTAMP The last time the session cookie was used for successful re-connection

SESSION_END_TIME TIMESTAMP The time the main connection has ended

2.232 SQLSCRIPT_TRACE

Contains the names of the local temporary tables created by the SQLScript TRACE operator

704P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 705: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Structure

Column name Data type Description

TRACE_TIMESTAMP TIMESTAMP Timestamp generated when a TRACE is performed

TRANSACTION_ID INTEGER Transaction object ID

STATEMENT_ID BIGINT Logical ID of the outmost user statement, which triggers the procedure execution (direct or indirect)

PROCEDURE_OID BIGINT The procedure object ID

VARIABLE_NAME NVARCHAR(256) The internal variable name used for the variable to which the TRACE operator is assigned

TABLE_NAME NVARCHAR(256) The name of the local temporary table containing the table result

2.233 STATISTICS

Stores a histogram of tables. The histogram can be used by query optimizer to calculate size of an intermediate result

Structure

Column name Data type Description

SCHEMA_NAME NVARCHAR(256) Schema name

TABLE_NAME NVARCHAR(256) Table name

COLUMN_NAME NVARCHAR(256) Column name

POSITION SMALLINT Ordinal position of the column in the table

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 705

Page 706: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Description

MINVALUE DOUBLE Min value of the column. The value is manipulated into the Double type value

MINVALUE_STR NVARCHAR(256) String representation of the column

MAXVALUE DOUBLE Max value of the column. The value is manipulated into the Double type value

MAXVALUE_STR NVARCHAR(256) String representation of the column

COUNT DOUBLE Number of not null value of the column

DCOUNT DOUBLE Number of distinct value of the column

NULLCOUNT DOUBLE Number of null values of the column

2.234 STRUCTURED_PRIVILEGES

Available structured privileges

Structure

Column name Data type Description

STRUCTURED_PRIVILEGE_ID BIGINT Object ID of the structured privilege

STRUCTURED_PRIVILEGE_NAME NVARCHAR(256) Name of the structured privilege

RESTRICTION_TYPE NVARCHAR(256) Type of the restriction: 'CUBERESTRICTION', 'ACTIVITYRESTRICTION', 'VALIDITYRESTRICTION', 'DIMENSIONRESTRICTION'

DIMENSION_ATTRIBUTE NVARCHAR(256) Name of the dimension attribute

706P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 707: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Description

FILTER_ID BIGINT Number of filter to be able to combine all operators/ operands belonging to one filter

FILTER_TYPE VARCHAR(16) Type of filter: 'STATIC', 'DYNAMIC'

NEGATED VARCHAR(5) Operator was negated in filter; 'TRUE', 'FALSE'

OPERATOR VARCHAR(16) Type of operator: 'CONTAINS PATTERN', 'BETWEEN', 'EQUAL', 'IN', 'LESS THAN', 'LESS EQUAL', 'GREATER THAN', 'GREATER EQUAL'

OPERAND_ORDER INTEGER Sequence of operands per filter ID

OPERAND NVARCHAR(513) Value the operator will be compared to

2.235 SYNONYMS

Available synonyms

Structure

Column name Data type Description

SCHEMA_NAME NVARCHAR(256) Schema name of the synonym

SYNONYM_NAME NVARCHAR(256) Name of the synonym

SYNONYM_OID BIGINT Object ID of the synonym

OBJECT_SCHEMA NVARCHAR(256) Schema name of the referenced object

OBJECT_NAME NVARCHAR(256) Name of the referenced object

OBJECT_TYPE VARCHAR(32) Type of the referenced object

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 707

Page 708: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Description

IS_COLUMN_OBJECT VARCHAR(5) Specifies whether this view is a column object or not: 'TRUE', 'FALSE'

IS_VALID VARCHAR(5) Specifies whether the synonym is valid or not. This becomes 'FALSE' when its base object is dropped: 'TRUE', 'FALSE'

2.236 TABLES

Available tables

Structure

Column name Data type Description

SCHEMA_NAME NVARCHAR(256) Schema name

TABLE_NAME NVARCHAR(256) Table name

TABLE_OID BIGINT Object ID of the table

COMMENTS NVARCHAR(5000) Table description

FIXED_PART_SIZE SMALLINT Fixed part size of the table

IS_LOGGED VARCHAR(5) Specifies whether or not logging was on for the table at last restart time: 'TRUE', 'FALSE'

IS_SYSTEM_TABLE VARCHAR(5) Deprecated: only used internally. Possible values: 'TRUE', 'FALSE'. Cannot be used to distinguish customer tables from predefined tables

IS_COLUMN_TABLE VARCHAR(5) Specifies whether the table is a column table: 'TRUE', 'FALSE'

TABLE_TYPE VARCHAR(16) Specifies type of the table: 'ROW', 'COLUMN', 'HYBRID'

708P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 709: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Description

IS_INSERT_ONLY VARCHAR(5) Specifies whether the table is an 'insert only' table: 'TRUE', 'FALSE'

IS_TENANT_SHARED_DATA VARCHAR(5) Specifies whether the table can be shared among other instances: 'TRUE', 'FALSE'

IS_TENANT_SHARED_METADATA VARCHAR(5) Specifies whether the table is a global table: 'TRUE', 'FALSE'

SESSION_TYPE VARCHAR(7) Session type: 'NONE', 'SIMPLE', 'HISTORY'. For 'HISTORY', time travel is possible

IS_TEMPORARY VARCHAR(5) Specifies whether the table is a temporary table: 'TRUE', 'FALSE'

TEMPORARY_TABLE_TYPE VARCHAR(10) Temporary table type

IS_USER_DEFINED_TYPE VARCHAR(5) 'TRUE' if user defined table type, 'FALSE' otherwise

HAS_PRIMARY_KEY VARCHAR(5) 'TRUE' if the table has a primary key, else 'FALSE'. Only valid for column store tables

PARTITION_SPEC NCLOB Detail specification of table partitioning. Only valid for column store tables

USES_EXTKEY VARCHAR(5) 'TRUE' if the table uses an external key, else 'FALSE'. Only valid for column store tables

AUTO_MERGE_ON VARCHAR(5) 'TRUE' if automatic delta table merge is activated for the table, else 'FALSE'. Only valid for column store tables

USES_DIMFN_CACHE VARCHAR(5) 'TRUE' if DimFunctionCache feature is used by the table, else 'FALSE'. Only valid for column store tables

IS_PUBLIC VARCHAR(5) 'TRUE' if the table is public, else 'FALSE'. Only valid for column store tables

AUTO_OPTIMIZE_COMPRESSION_ON

VARCHAR(5) 'TRUE' if automatic optimize compression is activated for the

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 709

Page 710: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Description

table, else 'FALSE'. Only valid for column store tables

COMPRESSED_EXTKEY VARCHAR(5) 'TRUE' if the table uses a compressed external key, else 'FALSE'. Only valid for column store tables

HAS_TEXT_FIELDS VARCHAR(5) 'TRUE' if the table has at least one column of type TEXT, else 'FALSE'. Only valid for column store tables

USES_QUEUE_TABLE VARCHAR(5) 'TRUE' if the table uses a queue table, else 'FALSE'. Only valid for column store tables

IS_PRELOAD VARCHAR(5) 'TRUE' if the table uses preloading, else 'FALSE'. Only valid for column store tables

IS_PARTIAL_PRELOAD VARCHAR(5) 'TRUE' if the table uses partial preloading, else 'FALSE'. Only valid for column store tables

UNLOAD_PRIORITY TINYINT Specifies unload priority of the table: 0 - 9. 0 means not unloadable, 1 means latest unload, and 9 means earliest unload

HAS_SCHEMA_FLEXIBILITY VARCHAR(5) 'TRUE' if the table has schema flexibility, else 'FALSE'. Only valid for column store tables

2.237 TABLE_COLUMNS

Available table columns

710P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 711: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Structure

Column name Data type Description

SCHEMA_NAME NVARCHAR(256) Schema name

TABLE_NAME NVARCHAR(256) Table name

TABLE_OID BIGINT Object ID of the table

COLUMN_NAME NVARCHAR(256) Name of the column

POSITION INTEGER Ordinal position of the column in a record

DATA_TYPE_ID SMALLINT SQL data type ID of the column

DATA_TYPE_NAME VARCHAR(16) SQL data type name of the column

OFFSET SMALLINT Offset of the column in the record

LENGTH INTEGER Number of chars for char types, number of max digits for numeric types; number of chars for datetime types, number of bytes for LOB types

SCALE INTEGER Numeric types: the maximum number of digits to the right of the decimal point; time, timestamp: the decimal digits are defined as the number of digits to the right of the decimal point in the second's component of the data

IS_NULLABLE VARCHAR(5) Specifies whether the column is allowed to accept null value: 'TRUE', 'FALSE'

DEFAULT_VALUE NVARCHAR(5000) Default value of the column

COLLATION NVARCHAR(256) Collation used for this column

COMMENTS NVARCHAR(5000) Description for this column

MAX_VALUE NVARCHAR(5000) Maximum value

MIN_VALUE NVARCHAR(5000) Minimum value

CS_DATA_TYPE_ID INTEGER Column store data type ID

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 711

Page 712: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Description

CS_DATA_TYPE_NAME VARCHAR(16) Column store data type name

DDIC_DATA_TYPE_ID INTEGER DDIC data type ID

DDIC_DATA_TYPE_NAME VARCHAR(7) DDIC data type name

COMPRESSION_TYPE VARCHAR(9) Type of compression: 'DEFAULT', 'PREFIXED', 'SPARSE', 'CLUSTERED', 'INDIRECT', 'RLE'. Columns in TABLE_COLUMNS show the default value which can be specified during table creation. They can also be updated using an 'ALTER TABLE' statement.

INDEX_TYPE VARCHAR(4) Type of index: 'NONE', 'FULL'

COLUMN_ID BIGINT ID of the column

PRELOAD VARCHAR(5) Specifies if column is preloaded: 'TRUE', 'FALSE'

GENERATED_ALWAYS_AS NVARCHAR(1000) Specifies the expression of the column created by GENERATED ALWAYS AS

HAS_SCHEMA_FLEXIBILITY VARCHAR(5) Specifies if column has schema flexibility: 'TRUE', 'FALSE'

FUZZY_SEARCH_INDEX VARCHAR(5) Specifies if column has fuzzy search index: 'TRUE', 'FALSE'

FUZZY_SEARCH_MODE VARCHAR(16) Specifies fuzzy search mode

MEMORY_THRESHOLD INTEGER Specifies memory threshold in bytes for LOB types

LOAD_UNIT VARCHAR(6) Specifies unit of column data loading: 'TABLE', 'COLUMN', 'PAGE'

2.238 TABLE_COLUMNS_ODBC

Available table columns

712P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 713: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Structure

Column name Data type Description

SCHEMA_NAME NVARCHAR(256) Schema name

TABLE_NAME NVARCHAR(256) Table name

TABLE_OID BIGINT Object ID of the table

COLUMN_NAME NVARCHAR(256) Name of the column

DATA_TYPE_ID SMALLINT SQL data type ID of the column

DATA_TYPE_NAME VARCHAR(16) SQL data type name of the column

COLUMN_SIZE INTEGER Total number of characters required to display the value when it is converted to characters

BUFFER_LENGTH INTEGER Length in bytes required to transfer the value

DECIMAL_DIGITS INTEGER Total number of significant digits to the right of the decimal point

NUM_PREC_RADIX INTEGER For numeric data types either 10 or 2. Specifies how to interpret columns COLUMN_SIZE and DECIMAL_DIGITS

NULLABLE VARCHAR(5) Specifies whether the column is allowed to accept null value: 'TRUE', 'FALSE'

COLUMN_DEF NVARCHAR(5000) Default value of the column

SQL_DATA_TYPE SMALLINT SQL data type ID of the column

SQL_DATETIME_SUB SMALLINT Subtype code for datetime data types

CHAR_OCTET_LENGTH INTEGER Maximum length in bytes of a character or binary data type column

POSITION INTEGER Ordinal position of the column in a record

COMMENTS NVARCHAR(5000) Description for this column

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 713

Page 714: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

2.239 TABLE_GROUPS

Overview of table groups relations

Structure

Column name Data type Description

SCHEMA_NAME NVARCHAR(256) Schema name

TABLE_NAME NVARCHAR(256) Table name

GROUP_TYPE NVARCHAR(256) Group type

SUBTYPE NVARCHAR(256) Subtype

GROUP_NAME NVARCHAR(256) Group name

2.240 TRANSACTION_HISTORY

Committed transactions and their users

Structure

Column name Data type Description

COMMIT_TIME TIMESTAMP Timestamp

COMMIT_ID BIGINT ID of the committed transaction

APP_USER NVARCHAR(256) User that used the transaction

2.241 TRIGGERS

Triggers defined for tables

714P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 715: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Structure

Column name Data type Description

SCHEMA_NAME NVARCHAR(256) Schema name of the trigger

TRIGGER_NAME NVARCHAR(256) Trigger name

TRIGGER_OID BIGINT Object ID of the trigger

OWNER_NAME NVARCHAR(256) Name of the trigger owner

OWNER_OID BIGINT Object ID of the trigger owner

SUBJECT_TABLE_SCHEMA NVARCHAR(256) Schema name of the table, the trigger is defined for

SUBJECT_TABLE_NAME NVARCHAR(256) Table name of the table, the trigger is defined for

TRIGGER_ACTION_TIME VARCHAR(10) Time the trigger is executed: 'BEFORE', 'AFTER', 'INSTEAD OF' the specified event

TRIGGER_EVENT VARCHAR(20) Event, the trigger is defined for: combination of 'DELETE', 'INSERT', 'UPDATE'

TRIGGERED_ACTION_LEVEL VARCHAR(9) Level of the event, where the triggered action will happen: 'ROW', 'STATEMENT'

DEFINITION NCLOB Query string of the trigger

IS_VALID VARCHAR(5) Specifies whether the trigger is valid or not. This becomes 'FALSE' when its base objects are changed or dropped: 'TRUE', 'FALSE'

IS_ENABLED VARCHAR(5) Specifies whether the trigger is enabled or not: 'TRUE', 'FALSE'

2.242 USERS

All users

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 715

Page 716: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Structure

Column name Data type Description

USER_NAME NVARCHAR(256) Name of the user

USER_ID BIGINT ID of the user

USER_MODE VARCHAR(8) Mode of the user: 'LOCAL', 'GLOBAL', 'EXTERNAL'

EXTERNAL_IDENTITY NVARCHAR(256) External identity of the user

CREATOR NVARCHAR(256) Creator of the user

CREATE_TIME TIMESTAMP Creation time

VALID_FROM TIMESTAMP Start time of user's validity

VALID_UNTIL TIMESTAMP End time of user's validity

LAST_SUCCESSFUL_CONNECT TIMESTAMP Time of the last successful connect of the user

LAST_INVALID_CONNECT_ATTEMPT

TIMESTAMP Time of the last invalid connect attempt

INVALID_CONNECT_ATTEMPTS INTEGER Number of invalid connect attempts since last successful connect

ADMIN_GIVEN_PASSWORD VARCHAR(5) Specifies if the password was given by administrator or by the user himself: 'TRUE', 'FALSE'

PASSWORD_CHANGE_TIME TIMESTAMP Time of last password change, NULL, if password-lifetime will not be checked for this user

PASSWORD_CHANGE_NEEDED VARCHAR(5) Specifies if user is forced to change his password himself: 'TRUE', 'FALSE'

USER_DEACTIVATED VARCHAR(5) Specifies if user is dectivated: 'TRUE', 'FALSE'

DEACTIVATION_TIME TIMESTAMP Time given with explicit deactivation command for this user

IS_PASSWORD_ENABLED VARCHAR(5) Authentication using password is enabled: 'TRUE', 'FALSE'

716P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 717: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Description

IS_KERBEROS_ENABLED VARCHAR(5) Authentication using KERBEROS is enabled: 'TRUE', 'FALSE'

IS_SAML_ENABLED VARCHAR(5) Authentication using SAML is enabled: 'TRUE', 'FALSE'

IS_X509_ENABLED VARCHAR(5) Authentication using an X.509 certificate is enabled: 'TRUE', 'FALSE'

2.243 USER_PARAMETERS

All parameters and their values, which have been assigned to users in the system (using CREATE USER ... SET PARAMETER or ALTER USER ... SET PARAMETER)

Structure

Column name Data type Description

USER_NAME NVARCHAR(256) Name of the user

PARAMETER NVARCHAR(256) Parameter name: CLIENT

VALUE NVARCHAR(256) Parameter value

2.244 VIEWS

Available views

Structure

Column name Data type Description

SCHEMA_NAME NVARCHAR(256) Schema name

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 717

Page 718: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Description

VIEW_NAME NVARCHAR(256) View name

VIEW_OID BIGINT Object ID of the view

IS_UNICODE VARCHAR(5) Specifies whether the query string contains Unicode: 'TRUE', 'FALSE'

IS_READ_ONLY VARCHAR(5) Specifies whether this view is read-only or updatable: 'TRUE', 'FALSE'

HAS_CHECK_OPTION VARCHAR(5) Specifies whether this view has an updatable view condition: 'TRUE', 'FALSE'

HAS_COLUMN_ALIASES VARCHAR(5) Specifies whether the view has a columns alias : 'TRUE', 'FALSE'

DEFINITION NCLOB View definition

COMMENTS NVARCHAR(5000) View description

IS_COLUMN_VIEW VARCHAR(5) Specifies whether this view is a column view or not: 'TRUE', 'FALSE'

VIEW_TYPE VARCHAR(16) Type of view : 'ROW', 'OLAP', 'JOIN', 'HIERARCHY', 'CALC'

IS_TENANT_SHARED_METADATA VARCHAR(5) Specifies whether the table is a global table or not: 'TRUE', 'FALSE'

IS_VALID VARCHAR(5) Specifies whether the view is valid or not. This becomes 'FALSE' when its base objects are changed or dropped: 'TRUE', 'FALSE'

2.245 VIEW_COLUMNS

Available view columns

718P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 719: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Structure

Column name Data type Description

SCHEMA_NAME NVARCHAR(256) Schema name

VIEW_NAME NVARCHAR(256) View name

VIEW_OID BIGINT Object ID of the view

COLUMN_NAME NVARCHAR(256) View column name

POSITION INTEGER Ordinal position of the view column

DATA_TYPE_ID SMALLINT Data type ID

DATA_TYPE_NAME VARCHAR(16) Data type name

OFFSET SMALLINT Offset of the column in a record

LENGTH INTEGER Number of chars for character types; max number of digits for numeric types; number of chars for datetime types; number of bytes for LOB types

SCALE INTEGER Numeric types: the maximum number of digits to the right of the decimal point; time, timestamp: the decimal digits are defined as the number of digits to the right of the decimal point in the second's component of the data

IS_NULLABLE VARCHAR(5) Specifies whether the column is allowed to accept null value: 'TRUE', 'FALSE'

DEFAULT_VALUE NVARCHAR(5000) Default value

COLLATION NVARCHAR(256) Collation

COMMENTS NVARCHAR(5000) Description for this column

MAX_VALUE NVARCHAR(5000) Maximum value

MIN_VALUE NVARCHAR(5000) Minimum value

CS_DATA_TYPE_ID INTEGER Column store data type ID

CS_DATA_TYPE_NAME VARCHAR(16) Column store data type name

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 719

Page 720: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Description

DDIC_DATA_TYPE_ID INTEGER DDIC data type ID

DDIC_DATA_TYPE_NAME VARCHAR(7) DDIC data type name

COMPRESSION_TYPE VARCHAR(9) Type of compression: 'DEFAULT', 'PREFIXED', 'SPARSE', 'CLUSTERED', 'INDIRECT', 'RLE'

INDEX_TYPE VARCHAR(4) Type of index: 'NONE', 'FULL'

COLUMN_ID BIGINT ID of the column

PRELOAD VARCHAR(5) Specifies if column is preloaded: 'TRUE', 'FALSE'

GENERATED_ALWAYS_AS NVARCHAR(1000) Specifies the expression of the column created by GENERATED ALWAYS AS

HAS_SCHEMA_FLEXIBILITY VARCHAR(5) Specifies if column has schema flexibility: 'TRUE', 'FALSE'

FUZZY_SEARCH_INDEX VARCHAR(5) Specifies if column has fuzzy search index: 'TRUE', 'FALSE'

FUZZY_SEARCH_MODE VARCHAR(16) Specifies fuzzy search mode

MEMORY_THRESHOLD INTEGER Specifies memory threshold in bytes for LOB types

LOAD_UNIT VARCHAR(1) Specifies unit of column data loading: 'TABLE', 'COLUMN', 'PAGE'

2.246 VIRTUAL_COLUMNS

Virtual columns

Structure

Column name Data type Description

SCHEMA_NAME NVARCHAR(256) Schema name

720P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 721: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Description

TABLE_NAME NVARCHAR(256) Table name

COLUMN_NAME NVARCHAR(256) Column name

DATA_TYPE_NAME VARCHAR(16) SQL data type name of the column

LENGTH INTEGER Number of chars for char types, number of max digits for numeric types; number of chars for datetime types, number of bytes for LOB types

SCALE INTEGER Numeric types: the maximum number of digits to the right of the decimal point; time, timestamp: the decimal digits are defined as the number of digits to the right of the decimal point in the second's component of the data

REMOTE_DATA_TYPE_NAME VARCHAR(32) Remote data type name

REMOTE_LENGTH INTEGER Remote column length

REMOTE_SCALE INTEGER Remote scale

2.247 VIRTUAL_TABLES

Virtual tables

Structure

Column name Data type Description

SCHEMA_NAME NVARCHAR(256) Schema name

TABLE_NAME NVARCHAR(256) Table name

REMOTE_SOURCE_NAME NVARCHAR(256) Remote source name

REMOTE_DB_NAME NVARCHAR(256) Remote database name

SAP HANA SQL and System Views ReferencesSystem Views Reference

P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved. 721

Page 722: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

Column name Data type Description

REMOTE_OWNER_NAME NVARCHAR(256) Remote owner name

REMOTE_OBJECT_NAME NVARCHAR(256) Remote object name

2.248 X509_USER_MAPPINGS

Shows the X.509 certificates known for each user

Structure

Column name Data type Description

USER_NAME NVARCHAR(256) User name

SUBJECT_NAME NVARCHAR(512) Subject of the X.509 certificate of the user

ISSUER_NAME NVARCHAR(512) Issuer of the X.509 certificate of the user

722P U B L I C© 2013 SAP AG or an SAP affiliate company. All rights reserved.

SAP HANA SQL and System Views ReferencesSystem Views Reference

Page 723: SAP_HANA_SQL_and_System_Views_Reference_en[1].pdf

www.sap.com/contactsap

© 2013 SAP AG or an SAP affiliate company. All rights reserved.No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of SAP AG. The information contained herein may be changed without prior notice.Some software products marketed by SAP AG and its distributors contain proprietary software components of other software vendors. National product specifications may vary.These materials are provided by SAP AG and its affiliated companies ("SAP Group") for informational purposes only, without representation or warranty of any kind, and SAP Group shall not be liable for errors or omissions with respect to the materials. The only warranties for SAP Group products and services are those that are set forth in the express warranty statements accompanying such products and services, if any. Nothing herein should be construed as constituting an additional warranty.SAP and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP AG in Germany and other countries.Please see http://www.sap.com/corporate-en/legal/copyright/index.epx for additional trademark information and notices.