简体   繁体   English

雪花中的默认精度比例数据类型

[英]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.

相关问题 检测Oracle数字数据类型的实际精度和小数位数 - Detect actual precision and scale for Oracle number data type 如果数据库中的数据类型为数字,如何使用Java检查其精度和小数位数 - If a data type is numeric in database how to check it's precision and scale using java 如何通过JDBC获取Teradata数字类型的精度和小数位数 - How can I get precision and scale of Teradata's number type through JDBC 使用 jdbc 插入数据时将 WKT 转换为雪花中的地理数据类型时出错 - Error while converting WKT to Geography data type in snowflake while using jdbc to insert data 当UCanAccess加载数据库时,HSQLDB“精度或范围超出范围”错误 - HSQLDB “precision or scale out of range” error when UCanAccess loads database 通过Java API获得NUMBER列的小数位数和精度? - Get scale and precision of a NUMBER column through Java API? Oracle DB使用JDBC返回负缩放和0精度 - Oracle DB returning negative scale and 0 precision using JDBC 使用JDBC向Snowflake插入数据 - Inserting data into Snowflake using JDBC 如何指定Oracle数字的精度/小数位JDBC元数据? - How to specify the precision/scale JDBC metadata of Oracle numbers? 为什么数字列的规模和/或精度在JDBC和Oracle 10之间有所不同? - Why would number columns' scale and/or precision differ in JDBC from Oracle 10 to 11?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM