Numeric literals specify the values of fixed-point and floating-point numbers. This topic describes integer literals, number literals, and floating-point literals.
Integer literals
When an integer appears in an expression, condition, SQL function, or SQL statement, you must use an integer literal to specify the value.
An integer literal can store up to 38 digits.
The following examples show valid integer literals.
8
+186
-15
Number and floating-point literals
When a number appears in an expression, condition, SQL function, or SQL statement, you must use a number literal or a floating-point literal to specify the value.
The following examples show valid number literals.
12
+6.87
0.5
25e-03
-9
The following examples show valid floating-point literals.
25f
+6.34F
0.5d
-1D
A number literal can store up to 38 digits. If the precision required by the literal exceeds that of the NUMBER, BINARY_FLOAT, or BINARY_DOUBLE data type, OceanBase Database truncates the value. If the value of the literal exceeds the range supported by the NUMBER, BINARY_FLOAT, or BINARY_DOUBLE data type, OceanBase Database returns an error.
The decimal point in a numeric literal is always a period ( . ). If you specify a text literal in a context where a numeric literal is expected, the text literal is converted to a numeric literal.
The following example calculates the values of 2 multiplied by the numeric literal 2.2 and 2 multiplied by the text literal '3.3'.
obclient> SELECT 2*2.2, 2*'3.3' FROM DUAL;
+-------+---------+
| 2*2.2 | 2*'3.3' |
+-------+---------+
| 4.4 | 6.6 |
+-------+---------+
1 row in set
