博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
hive精确数据类型
阅读量:7218 次
发布时间:2019-06-29

本文共 824 字,大约阅读时间需要 2 分钟。

hot3.png

hive也支持varchar,date,datetime,decaimal等类型,下面对这些类型与关系型数据库的差别进行探索。

```

create table test.type_tab(

    id bigint,
    col1 varchar(10),
    col2 date,
    col3 timestamp,
    col4 decimal(22,6)
);

insert into test.type_tab

select 100,'01234567890','2018-12-31','2018-12-31 12:30:00',2873.99834475755775;   

insert into test.type_tab
select 101,'01234567890123','2018-12-31','2018-12-31 12:30:00',2873.99834475755775;  

 

 

```

查看结果:

```

select * from test.type_tab;

type_tab.id |type_tab.col1 |type_tab.col2 |type_tab.col3       |type_tab.col4 |

------------|--------------|--------------|--------------------|--------------|
100         |0123456789    |2018-12-31    |2018-12-31 12:30:00 |2873.998345   |
101         |0123456789    |2018-12-31    |2018-12-31 12:30:00 |2873.998345   |

```

 

由此可见varchar指定字段长度,当字段超长则被自动截断。decaiml超过精度则财务四舍五入到目标精度。

转载于:https://my.oschina.net/huhaicool/blog/1861859

你可能感兴趣的文章
python try except, 异常处理
查看>>
字符串中的各种方法
查看>>
创建文件夹、新建txt文件
查看>>
js form表单 鼠标移入弹出提示功能
查看>>
LFS7.10——准备Host系统
查看>>
Redis.py客户端的命令总结【三】
查看>>
mac 安装secureCRT
查看>>
/var/adm/wtmp文件太大该怎么办?
查看>>
反应器模式 vs 观察者模式
查看>>
Algernon's Noxious Emissions POJ1121 zoj1052
查看>>
iOS-数据持久化-对象归档
查看>>
iOS开发UI篇—程序启动原理和UIApplication
查看>>
MUI 里js动态添加数字输入框后,增加、减少按钮无效
查看>>
python pip 更换国内安装源(windows)
查看>>
结对编程2后篇
查看>>
oracle exp 和 imp 数据和表结构互相独立导出导入
查看>>
iphone-common-codes-ccteam源代码 CCNSPredicate.m
查看>>
这次项目中应该注意的问题和应该保持的好习惯
查看>>
python-数据结构化与保存
查看>>
LeetCode - 551. Student Attendance Record I
查看>>