Tibero  SQL Reference Guide

Tibero 6


Restricted Rights Legend

All TmaxData Software (Tibero®) and documents are protected by copyright laws and international convention. TmaxData software and documents are made available under the terms of the TmaxData License Agreement and this document may only be distributed or copied in accordance with the terms of this agreement. No part of this document may be transmitted, copied, deployed, or reproduced in any form or by any means, electronic, mechanical, or optical, without the prior written consent of TmaxData Co., Ltd. Nothing in this software document and agreement constitutes a transfer of intellectual property rights regardless of whether or not such rights are registered) or any rights to TmaxData trademarks, logos, or any other brand features.

This document is for information purposes only. The company assumes no direct or indirect responsibilities for the contents of this document, and does not guarantee that the information contained in this document satisfies certain legal or commercial conditions. The information contained in this document is subject to change without prior notice due to product upgrades or updates. The company assumes no liability for any errors in this document.

Trademarks

Tibero® is a registered trademark of TmaxData Co., Ltd. Other products, titles or services may be registered trademarks of their respective companies.

Open Source Software Notice

Some modules or files of this product are subject to the terms of the following licenses. : OpenSSL, RSA Data Security, Inc., Apache Foundation, Jean-loup Gailly and Mark Adler, Paul Hsieh's hash

Detailed Information related to the license can be found in the following directory : ${INSTALL_PATH}/license/oss_licenses

Document Information

Title: Tibero  SQL Reference Guide

Publication Date: 2020-03-13

Software Version: Tibero 6 (FixSet07)

Edition: v2.1.7.4


Table of Contents

About This Document
1. Introduction to SQL
1.1. Overview
1.2. SQL Standard
1.3. SQL Statement Types
1.3.1. Data Definition Language
1.3.2. Data Manipulation Language
1.3.3. Transaction and Session Management Language
2. SQL Elements
2.1. Data Types
2.1.1. String
2.1.2. Number
2.1.3. Datetime
2.1.4. Interval
2.1.5. Large Object
2.1.6. Embedded
2.1.7. User-Defined
2.2. Data Type Conversions
2.2.1. Explicit Type Conversion
2.2.2. Implicit Type Conversion
2.3. Literals
2.3.1. String
2.3.2. Numeric
2.3.3. Datetime
2.3.4. Interval
2.4. Format Strings
2.4.1. NUMBER Types
2.4.2. Datetime Types
2.4.3. Format Modifiers
2.5. Pseudo Columns
2.5.1. ROWID
2.5.2. ROWNUM
2.5.3. LEVEL
2.5.4. CONNECT_BY_ISLEAF
2.5.5. CONNECT_BY_ISCYCLE
2.6. NULL
2.6.1. NULL in SQL Functions
2.6.2. Comparison Condition for NULL
2.7. Comments
2.8. Hints
2.8.1. Query Transformations
2.8.2. Optimizer Modes
2.8.3. Access Modes
2.8.4. Join Orders
2.8.5. Join Modes
2.8.6. Parallel Processing
2.8.7. Materialized Views
2.8.8. Others
2.9. Schema Objects
2.9.1. Tables
2.9.2. Indexes
2.9.3. Views
2.9.4. Sequences
2.9.5. Synonyms
2.9.6. Schema Object Names
2.9.7. Syntax for Schema Objects
3. SQL Operations
3.1. Overview
3.2. Operators
3.2.1. General Operators
3.2.2. Operators Used in Conditional Expressions
3.3. Expressions
3.3.1. Expression Conversion
3.3.2. Simple Expressions
3.3.3. Compound Expressions
3.3.4. CASE Expressions
3.3.5. Functions
3.3.6. Subquery Expressions
3.3.7. Variables
3.3.8. List
3.4. Conditional Expressions
3.4.1. Simple Conditions
3.4.2. Group Conditions
3.4.3. Compound Conditions
3.4.4. BETWEEN Condition
3.4.5. EXISTS Condition
3.4.6. IN Condition
3.4.7. IS NULL Condition
3.4.8. LIKE Condition
3.4.9. REGEXP_LIKE Condition
4. Functions
4.1. Overview
4.1.1. Single Row Functions
4.1.2. Aggregate Functions
4.1.3. Analytic Functions
4.2. Function List
4.2.1. ABS
4.2.2. ACOS
4.2.3. ADD_MONTHS
4.2.4. AGGR_CONCAT
4.2.5. APPENDCHILDXML
4.2.6. ASCII
4.2.7. ASCIISTR
4.2.8. ASIN
4.2.9. ATAN
4.2.10. ATAN2
4.2.11. AVG
4.2.12. BITAND
4.2.13. CAST
4.2.14. CEIL
4.2.15. CHARTOROWID
4.2.16. CHR
4.2.17. COALESCE
4.2.18. COMPOSE
4.2.19. CONCAT
4.2.20. CONVERT
4.2.21. CORR
4.2.22. COS
4.2.23. COSH
4.2.24. COUNT
4.2.25. COVAR_POP
4.2.26. COVAR_SAMP
4.2.27. CUME_DIST
4.2.28. CURRENT_DATE
4.2.29. CURRENT_TIME
4.2.30. CURRENT_TIMESTAMP
4.2.31. DBTIMEZONE
4.2.32. DECODE
4.2.33. DECOMPOSE
4.2.34. DELETEXML
4.2.35. DENSE_RANK
4.2.36. DUMP
4.2.37. EMPTY_BLOB
4.2.38. EMPTY_CLOB
4.2.39. EXISTSNODE
4.2.40. EXP
4.2.41. EXTRACT
4.2.42. EXTRACT(XML)
4.2.43. EXTRACTVALUE
4.2.44. FIRST
4.2.45. FIRST_VALUE
4.2.46. FLOOR
4.2.47. FROM_TZ
4.2.48. GETBLOBVAL
4.2.49. GETCLOBVAL
4.2.50. GETROOTELEMENT
4.2.51. GETSTRINGVAL
4.2.52. GREATEST
4.2.53. GROUPING
4.2.54. GROUPING_ID
4.2.55. GROUP_ID
4.2.56. HEXTORAW
4.2.57. INET_ATON
4.2.58. INET_NTOA
4.2.59. INITCAP
4.2.60. INSERTCHILDXML
4.2.61. INSERTCHILDXMLAFTER
4.2.62. INSERTCHILDXMLBEFORE
4.2.63. INSERTXMLAFTER
4.2.64. INSERTXMLBEFORE
4.2.65. INSTR
4.2.66. ISFRAGMENT
4.2.67. KURT
4.2.68. LAG
4.2.69. LAST_DAY
4.2.70. LAST
4.2.71. LAST_VALUE
4.2.72. LEAD
4.2.73. LEAST
4.2.74. LENGTH
4.2.75. LISTAGG
4.2.76. LN
4.2.77. LNNVL
4.2.78. LOCALTIMESTAMP
4.2.79. LOG
4.2.80. LOWER
4.2.81. LPAD
4.2.82. LTRIM
4.2.83. MAX
4.2.84. MEDIAN
4.2.85. MIN
4.2.86. MOD
4.2.87. MONTHS_BETWEEN
4.2.88. NANVL
4.2.89. NEW_TIME
4.2.90. NEXT_DAY
4.2.91. NLSSORT
4.2.92. NLS_CHARSET_ID
4.2.93. NLS_INITCAP
4.2.94. NLS_LOWER
4.2.95. NLS_UPPER
4.2.96. NTILE
4.2.97. NULLIF
4.2.98. NUMTODSINTERVAL
4.2.99. NUMTOYMINTERVAL
4.2.100. NVL
4.2.101. NVL2
4.2.102. ORA_HASH
4.2.103. OVERLAPS
4.2.104. PERCENT_RANK
4.2.105. PERCENTILE_CONT
4.2.106. PERCENTILE_DISC
4.2.107. POWER
4.2.108. RANK
4.2.109. REGR_SLOPE
4.2.110. REGR_INTERCEPT
4.2.111. REGR_COUNT
4.2.112. REGR_R2
4.2.113. REGR_AVGX
4.2.114. REGR_AVGY
4.2.115. REGR_SXX
4.2.116. REGR_SXY
4.2.117. REGR_SYY
4.2.118. RATIO_TO_REPORT
4.2.119. RAWTOHEX
4.2.120. REGEXP_COUNT
4.2.121. REGEXP_INSTR
4.2.122. REGEXP_REPLACE
4.2.123. REGEXP_SUBSTR
4.2.124. REMAINDER
4.2.125. REPLACE
4.2.126. REVERSE
4.2.127. ROUND(number)
4.2.128. ROUND(date)
4.2.129. ROWIDTOCHAR
4.2.130. ROW_NUMBER
4.2.131. RPAD
4.2.132. RTRIM
4.2.133. SESSIONTIMEZONE
4.2.134. SIGN
4.2.135. SIN
4.2.136. SINH
4.2.137. SKEW
4.2.138. SQRT
4.2.139. STDDEV
4.2.140. STDDEV_POP
4.2.141. STDDEV_SAMP
4.2.142. SUBSTR
4.2.143. SUM
4.2.144. SYS_CONNECT_BY_PATH
4.2.145. SYS_CONTEXT
4.2.146. SYS_EXTRACT_UTC
4.2.147. SYS_GUID
4.2.148. SYSDATE
4.2.149. SYSTIME
4.2.150. SYSTIMESTAMP
4.2.151. TAN
4.2.152. TANH
4.2.153. TIMESTAMP_TO_TSN
4.2.154. TO_BINARY_DOUBLE
4.2.155. TO_BINARY_FLOAT
4.2.156. TO_BLOB
4.2.157. TO_CHAR(character)
4.2.158. TO_CHAR(datetime)
4.2.159. TO_CHAR(number)
4.2.160. TO_CLOB
4.2.161. TO_DATE
4.2.162. TO_DSINTERVAL
4.2.163. TO_LOB
4.2.164. TO_MULTI_BYTE
4.2.165. TO_NCHAR
4.2.166. TO_NUMBER
4.2.167. TO_SINGLE_BYTE
4.2.168. TO_TIME
4.2.169. TO_TIMESTAMP
4.2.170. TO_TIMESTAMP_TZ
4.2.171. TO_YMINTERVAL
4.2.172. TRANSLATE
4.2.173. TRIM
4.2.174. TRUNC(number)
4.2.175. TRUNC(date)
4.2.176. TSN_TO_TIMESTAMP
4.2.177. TZ_OFFSET
4.2.178. TZ_SHIFT
4.2.179. UID
4.2.180. UNISTR
4.2.181. UPDATEXML
4.2.182. UPPER
4.2.183. USER
4.2.184. USERENV
4.2.185. VAR_POP
4.2.186. VAR_SAMP
4.2.187. VARIANCE
4.2.188. VSIZE
4.2.189. XMLAGG
4.2.190. XMLCAST
4.2.191. XMLCDATA
4.2.192. XMLCOLATTVAL
4.2.193. XMLCOMMENT
4.2.194. XMLCONCAT
4.2.195. XMLELEMENT
4.2.196. XMLEXISTS
4.2.197. XMLFOREST
4.2.198. XMLPARSE
4.2.199. XMLPI
4.2.200. XMLQUERY
4.2.201. XMLROOT
4.2.202. XMLSERIALIZE
4.2.203. XMLSEQUENCE
4.2.204. XMLTABLE
4.2.205. XMLTRANSFORM
5. SQL Queries
5.1. SELECT
5.2. Joins
5.2.1. Join Conditions
5.2.2. Equi Joins
5.2.3. Self Joins
5.2.4. Inner Joins
5.2.5. Outer Joins
5.2.6. Anti-joins
5.2.7. Semi-joins
5.3. Subqueries
5.4. Set Operators
5.5. Hierarchical Queries
5.5.1. Hierarchical Query Operators
5.5.2. Conditional Expressions in a Hierarchical Query
5.5.3. How to Execute a Hierarchical Query
5.6. Parallel Query
5.7. Dual Table
6. Materialized Views
6.1. Refresh
6.1.1. Complete Refresh
6.1.2. Fast Refresh
6.2. Query Rewrite
6.2.1. Enabling Query Rewrite
6.2.2. Rewrite Methods
6.2.3. Cost-Based Optimization
6.3. Materialized View with Remote Storage
6.3.1. Tasks before Creating a Materialized View
6.3.2. Creating a Materialized View
6.3.3. Refreshing and Querying a Storage Table
6.3.4. Constraints
7. Data Definition Language
7.1. Common DDL Syntax Elements
7.1.1. Constraints
7.1.2. Constraint_state
7.1.3. Deferrable_option
7.1.4. Sgmt_attr
7.1.5. Storage_clause
7.2. ALTER DATABASE
7.3. ALTER DISKSPACE
7.4. ALTER FUNCTION
7.5. ALTER INDEX
7.6. ALTER MATERIALIZED VIEW
7.7. ALTER MATERIALIZED VIEW LOG
7.8. ALTER PACKAGE
7.9. ALTER PROCEDURE
7.10. ALTER PROFILE
7.11. ALTER ROLE
7.12. ALTER ROLLBACK SEGMENT
7.13. ALTER SEQUENCE
7.14. ALTER TABLE
7.15. ALTER TABLESPACE
7.16. ALTER TRIGGER
7.17. ALTER TYPE
7.18. ALTER USER
7.19. ALTER VIEW
7.20. AUDIT
7.21. COMMENT
7.22. CREATE CONTEXT
7.23. CREATE CONTROLFILE
7.24. CREATE DATABASE
7.25. CREATE DATABASE LINK
7.26. CREATE DIRECTORY
7.27. CREATE DISKSPACE
7.28. CREATE FUNCTION
7.29. CREATE INDEX
7.30. CREATE MATERIALIZED VIEW
7.31. CREATE MATERIALIZED VIEW LOG
7.32. CREATE OUTLINE
7.33. CREATE PACKAGE
7.34. CREATE PACKAGE BODY
7.35. CREATE PROCEDURE
7.36. CREATE PROFILE
7.37. CREATE ROLE
7.38. CREATE SEQUENCE
7.39. CREATE SYNONYM
7.40. CREATE TABLE
7.41. CREATE TABLESPACE
7.42. CREATE TYPE
7.43. CREATE TYPE BODY
7.44. CREATE TRIGGER
7.45. CREATE USER
7.46. CREATE VIEW
7.47. DROP DATABASE LINK
7.48. DROP DIRECTORY
7.49. DROP DISKSPACE
7.50. DROP FUNCTION
7.51. DROP INDEX
7.52. DROP MATERIALIZED VIEW
7.53. DROP MATERIALIZED VIEW LOG
7.54. DROP OUTLINE
7.55. DROP PACKAGE
7.56. DROP PROCEDURE
7.57. DROP PROFILE
7.58. DROP ROLE
7.59. DROP SEQUENCE
7.60. DROP SYNONYM
7.61. DROP TABLE
7.62. DROP TABLESPACE
7.63. DROP TRIGGER
7.64. DROP TYPE
7.65. DROP TYPE BODY
7.66. DROP USER
7.67. DROP VIEW
7.68. EXPLAIN PLAN
7.69. FLASHBACK TABLE
7.70. GRANT
7.71. LOCK TABLE
7.72. NOAUDIT
7.73. PURGE
7.74. RENAME
7.75. REVOKE
7.76. TRUNCATE TABLE
8. Data Manipulation Language
8.1. INSERT
8.2. UPDATE
8.3. DELETE
8.4. CALL
8.5. MERGE
8.6. Parallel DML
8.6.1. Execution Methods
8.6.2. Constraints
9. Transaction and Session Management Language
9.1. ALTER SESSION
9.2. ALTER SYSTEM
9.3. COMMIT
9.4. ROLLBACK
9.5. SAVEPOINT
9.6. SET ROLE
9.7. SET TRANSACTION
A. Reserved Words
A.1. A
A.2. B
A.3. C
A.4. D
A.5. E
A.6. F
A.7. G
A.8. H
A.9. I
A.10. L
A.11. M
A.12. N
A.13. O
A.14. P
A.15. R
A.16. S
A.17. T
A.18. U
A.19. V
A.20. W
Index

List of Figures

[Figure 2.1] ROWID Structure
[Figure 3.1] Example of a Syntax Diagram for an Expression
[Figure 5.1] EMP2 Table Hierarchy

List of Tables

[Table 2.1] Explicit Type Conversion (1)
[Table 2.2] Explicit Type Conversion (2)
[Table 2.3] Explicit Type Conversion (3)
[Table 2.4] Implicit Type Conversion (1)
[Table 2.5] Implicit Type Conversion (2)
[Table 2.6] Implicit Type Conversion (3)
[Table 2.7] Type Comparison (1)
[Table 2.8] Type Comparison (2)
[Table 2.9] Type Comparison (3)
[Table 2.10] Type Comparison (4)
[Table 2.11] Type Comparison (5)

List of Examples

[Example 2.1] EMP Table
[Example 2.2] DEPT Table