[英]Default precision scale data type in snowflake
I want to create a table with column as decimal and I dont want to specify any precision scale, it seems using number as dataType it create column as Number(38,0) by default.我想创建一个列为十进制的表,并且我不想指定任何精度比例,它似乎使用数字作为 dataType 它默认创建列为 Number(38,0)。 How can I get some default value for scale as well.
我怎样才能得到一些默认的比例值。 In other db like oracle numeric takes default scale and we are able to insert decimal values but the same is not happening in snowflake
在其他数据库中,如 oracle numeric 采用默认比例,我们能够插入十进制值,但雪花中没有发生同样的情况
You are right that it is defined as NUMBER(38,0) when you don't specify a scale.你是对的,当你没有指定比例时,它被定义为 NUMBER(38,0) 。 It's a popular request from Snowflake users, and there is already a project to improve the NUMBER data type.
这是 Snowflake 用户的一个流行请求,并且已经有一个改进 NUMBER 数据类型的项目。 Unfortunately, there is no ETA yet.
不幸的是,目前还没有预计到达时间。
You can create a table with data type FLOAT/DECIMAL/DOUBLE etc, all these data types use underlying precision/scale = 15/9.您可以创建数据类型为 FLOAT/DECIMAL/DOUBLE 等的表,所有这些数据类型都使用基础精度/比例 = 15/9。 It actually uses double data type internally.
它实际上在内部使用双数据类型。
You can try like CREATE OR REPLACE TABLE table_double ( Scale REAL );你可以试试 CREATE OR REPLACE TABLE table_double ( Scale REAL );
insert into table_double values
(103269015259.46179);
insert into table_double values
(10326901.461);
It will truncate after 15/9.它将在 15/9 之后截断。
Please refer to the documentation.请参阅文档。
https://docs.snowflake.com/en/sql-reference/data-types-numeric.html#data-types-for-floating-point-numbers https://docs.snowflake.com/en/sql-reference/data-types-numeric.html#data-types-for-floating-point-numbers
Regards, Sujan问候, 苏扬
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.