Fixed Precision
Name |
Description |
Storage Space |
Value Range |
Literal |
---|---|---|---|---|
DECIMAL |
Decimal number with fixed precision. The maximum precision is 38 bits, but the precision with less than 18 bits can ensure the best performance. Decimal has two input parameters:
|
64 bits |
|
DECIMAL |
NUMERIC |
Same as DECIMAL |
128 characters |
|
NUMERIC |
Example: DECIMAL(10,3), DECIMAL(20)
Literal example: DECIMAL '10.3', DECIMAL '1234567890', 1.1
--Create a table containing DECIMAL data: CREATE TABLE decimal_t1 (dec_col1 DECIMAL(10,3)) ; – Insert data of the DECIMAL type: insert into decimal_t1 values (DECIMAL '5.325'); --View data. SELECT * FROM decimal_t1; dec_col1 --------- 5.325 (1 row) -- Negative example: The number of decimal places exceeds the defined length. As a result, the SQL statement fails to be executed. insert into decimal_t1 values (DECIMAL '5.3253'); Query 20201126_034601_00053_tq98i@default@HetuEngine failed: Insert query has mismatched column types: Table: [decimal(10,3)], Query: [decimal(5,4)] --Drop a table. DROP TABLE decimal_t1; --Create a NUMERIC type table. CREATE TABLE tb_numberic_hetu(col1 NUMERIC(9,7)); CREATE TABLE --Insert data. INSERT INTO tb_numberic_hetu values(9.12); INSERT: 1 row --View data. SELECT * FROM tb_numberic_hetu; col1 ------------ 9.1200000 (1 row)
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.