SAP HANA SQL and System Views Reference En

download SAP HANA SQL and System Views Reference En

If you can't read please download the document

description

SAP HANA

Transcript of SAP HANA SQL and System Views Reference En

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

    SAP HANA SQL and System Views References

  • 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

  • 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

  • 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

  • 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

  • 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

  • 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

  • 2.210 OBJECTS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6882.211 OBJECT_DEPENDENCIES. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6892.212 OWNERSHIP. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6892.213 PRIVILEGES. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6902.214 PROCEDURES. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6902.215 PROCEDURE_OBJECTS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6912.216 PROCEDURE_PARAMETERS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6922.217 QUERY_PLANS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6932.218 REFERENTIAL_CONSTRAINTS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6942.219 REMOTE_SOURCES. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6952.220 REORG_OVERVIEW. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6952.221 REORG_PLAN. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6962.222 REORG_PLAN_INFOS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6972.223 REORG_STEPS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6982.224 ROLES. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6992.225 SAML_PROVIDERS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7002.226 SAML_USER_MAPPINGS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7002.227 SCHEMAS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7012.228 SEARCH_RULE_SETS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7012.229 SEARCH_RULE_SET_CONDITIONS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7022.230 SEQUENCES. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7032.231 SESSION_COOKIES. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7042.232 SQLSCRIPT_TRACE. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7042.233 STATISTICS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7052.234 STRUCTURED_PRIVILEGES. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7062.235 SYNONYMS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7072.236 TABLES. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7082.237 TABLE_COLUMNS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7102.238 TABLE_COLUMNS_ODBC. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7122.239 TABLE_GROUPS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7142.240 TRANSACTION_HISTORY. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7142.241 TRIGGERS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7142.242 USERS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7152.243 USER_PARAMETERS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7172.244 VIEWS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7172.245 VIEW_COLUMNS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7182.246 VIRTUAL_COLUMNS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7202.247 VIRTUAL_TABLES. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7212.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

  • 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

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

    ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9

    ::= a | b | c | d | e | f | g | h | i | j | k | l | m | n | o | p | q | r | s | t | u | v | w | x | y | z | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z ::= _

    ::= #

    ::= $

    !!= any character.

    ::= '

    ::= " ::= |

    ::= { | } [{ | | | | }...]

    ::=

    ::=

    = { | }...

    ::= { | }...

    ::= { | }...

    ::= { | }[{ | | | - }...]

    ::=

    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

  • ::= + | -

    ::= .

    ::= ...

    ::= []

    ::= []

    ::= |

    ::= [[]] |

    ::= E

    ::=

    ::=

    ::=

  • 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: Double hyphens "--". Everything after the double hyphen until the end of a line is ignored by the SQL parser. "/*" and "*/". This style of commenting is used to place comments on multiple lines. All text between the opening "/*" and closing "*/" is ignored by the SQL parser.

    Identifiers

    Syntax:

    ::= |

    ::= {|} [{ | | | | }...]

    ::=

    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

  • 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 WordsALL 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

  • 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 typesClassification 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

  • 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 FormatsThe 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 DateFormat Description Examples

    YYYY-MM-DD Default format INSERT INTO my_tbl VALUES ('1957-06-13');

    YYYY/MM/DDYYYY/MM-DDYYYY-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

  • 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 TimeFormat 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

  • 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 TimestampFormat 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 DatetimeFormat 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

  • 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

  • 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

  • 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. VARCHAR

    The 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 ( )

    ::= [{, }...]

    ::= | 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

  • 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. BLOB

    The BLOB data type is used to store large binary data. CLOB

    The CLOB data type is used to store large ASCII character data. NCLOB

    The NCLOB data type is used to store a large Unicode character object. TEXT

    The 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

    ::= [{, }...]

    ::= | [SYNC[HRONOUS] | [ASYNC[HRONOUS] FLUSH [QUEUE] | EVERY MINUTES [[OR] AFTER DOCUMENTS] ]

    Syntax-rules common to TEXT and SHORTTEXT

    ::= LANGUAGE COLUMN | LANGUAGE DETECTION '(' ')' | MIME TYPE COLUMN | FUZZY SEARCH INDEX [ON|OFF] | PHRASE INDEX RATIO [ON|OFF] | CONFIGURATION | 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

  • 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

  • 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 ExamplesInput 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

  • Table 8: Table 9a: Data type conversion tableTarget/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

  • 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

  • Table 9: Table 9b: Data type conversion tableTarget/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 tableTarget/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

  • 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

  • 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

  • Highest TIMESTAMP

    SECONDDATE

    DATE

    TIME

    DOUBLE

    REAL

    DECIMAL

    SMALLDECIMAL

    BIGINT

    INTEGER

    SMALLINT

    TINYINT

    NCLOB

    NVARCHAR

    CLOB

    VARCHAR

    BLOB

    Lowest VARBINARY

    BLOB

    Lowest VARBINARY

    Typed ConstantA constant is a symbol that represents a specific fixed data value. Character string contant

    A 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

  • 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.234e2A 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

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

    1.4.1 Comparison Predicates

    Syntax

    ::= { = | != | | > | < | >= |

  • 1.4.2 Range Predicate

    Syntax

    ::= [NOT] BETWEEN AND

    Syntax Elements

    ::= ::= ::=

    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 is not in the range of values specified between and .

    Description

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

    The range predicate returns true if is within the range specified by and .

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

    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

  • 1.4.3 In Predicate

    Syntax

    ::= [NOT] IN { | }

    Syntax Elements

    ::= ::= [{, }...]

    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 is not in the set of values specified by or the .

    Description

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

    1.4.4 Exists Predicate

    Syntax

    ::= [NOT] 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. 33

  • Syntax Elements

    NOT

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

    For information on subqueries, see Subquery

    Description

    Returns true if the returns a result set that is not empty and returns false if the returns an empty result set.

    1.4.5 LIKE Predicate

    Syntax

    ::= [NOT] LIKE [ESCAPE ]

    Syntax Elements

    ::= ::= ::=

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

  • Description

    The LIKE predicate performs string comparisons. is tested for a pattern contained in . Wildcard characters ( % ) and ( _ ) can be used in the comparison string . 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 , 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

    ::= IS [NOT] NULL

    Syntax Elements

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

    IS NOT NULL

    Returns true if the value of 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

  • 1.4.7 CONTAINS Predicate

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

    ::= CONTAINS '(' ',' ')' | CONTAINS '(' ',' ',' ')' ::= '*' | | '(' ')' ::= ::= | ::= empty | ::= | | ::= | ',' := | ::= EXACT ::= FUZZY | FUZZY '(' ')' | FUZZY '(' ',' ')' ::= LINGUISTIC ::= WEIGHT '(' ')' :: LANGUAGE '(' ')' ::=

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

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

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

    FUZZYFUZZY 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

  • 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

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

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

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

  • 1.5 Operators

    Unary and Binary Operators Operator Precedence Arithmetic Operators String Operators Comparsion Operators Logical Operators Set OperatorsYou 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 operatorsOperator 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

  • 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 precedencePrecedence 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 operatorsOperator Description

    - Negation. If the expression is the NULL value, the result is NULL.

    + Addition. If either expression is the NULL value, the result is NULL.

    - Subtraction. If either expression is the NULL value, the result is NULL.

    * Multiplication. If either expression is NULL, the result is NULL.

    / 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

  • String Operators

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

    Table 14: Table 13. Concatenation operatorsOperator Description

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

    ::=

    Table 15: Table 14. Comparison operatorsOperator 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;

  • 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 operatorsOperator 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 operatorsOperator 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

  • 1.6 Expressions

    Case Expressions Function Expressions Aggregate Expressions Subqueries in ExpressionsAn expression is a clause that can be evaluated to return values.

    Syntax

    ::= | | | ( ) | ( ) | - | | | | [.]

    Case Expressions

    A case expression allows the user to use IF - THEN - ELSE logic without using procedures in SQL statements.Syntax

    ::= |

    ::= CASE WHEN THEN [{ WHEN THEN }] [ ELSE ] END

    > ::= CASE WHEN THEN [{ WHEN THEN }] [ ELSE ] END

    ::= OR | AND | NOT | ( ) |

    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

  • 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

    ::= ( [{, }...] )

    Aggregate Expressions

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

    ::= COUNT(*) | ( [ ALL | DISTINCT ] ) ::= 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() 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

  • 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

    ::= ()

    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

  • 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

  • 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

  • 1.7.1.3 TO_BIGINT

    Syntax

    TO_BIGINT (va