生产中Hive静态和动态分区表,该怎样抉择呢?
发表于:2024-10-21 作者:千家信息网编辑
千家信息网最后更新 2024年10月21日,一.需求按照不同部门作为分区,导数据到目标表二.使用静态分区表来完成1.创建静态分区表:create table emp_static_partition(empno int, ename strin
千家信息网最后更新 2024年10月21日生产中Hive静态和动态分区表,该怎样抉择呢?
一.需求
按照不同部门作为分区,导数据到目标表
二.使用静态分区表来完成
1.创建静态分区表:
create table emp_static_partition(empno int, ename string, job string, mgr int, hiredate string, sal double, comm double)PARTITIONED BY(deptno int)row format delimited fields terminated by '\t';
2.插入数据:
hive>insert into table emp_static_partition partition(deptno=10) select empno , ename , job , mgr , hiredate , sal , comm from emp where deptno=10;
3.查询数据:
hive>select * from emp_static_partition;
三.使用动态分区表来完成
1.创建动态分区表:
create table emp_dynamic_partition(empno int, ename string, job string, mgr int, hiredate string, sal double, comm double)PARTITIONED BY(deptno int)row format delimited fields terminated by '\t';
【注意】动态分区表与静态分区表的创建,在语法上是没有任何区别的
2.插入数据:
hive>insert into table emp_dynamic_partition partition(deptno) select empno , ename , job , mgr , hiredate , sal , comm, deptno from emp;
【注意】分区的字段名称,写在最后,有几个就写几个 与静态分区相比,不需要where
需要设置属性的值:
hive>set hive.exec.dynamic.partition.mode=nonstrict;
假如不设置,报错如下:
3.查询数据:
hive>select * from emp_dynamic_partition;
分区列为deptno,实现了动态分区
四.总结
在生产上我们更倾向是选择动态分区,
无需手工指定数据导入的具体分区,
而是由select的字段(字段写在最后,有几个写几个)自行决定导出到哪一个分区中, 并自动创建相应的分区,使用上更加方便快捷 ,在生产工作中用的非常多多。
分区表
数据
动态
静态
字段
生产
查询
不同
方便快捷
中用
倾向
名称
属性
手工
是由
目标
语法
部门
需求
工作
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
佛山市天迹网络技术有限公司
扬中网络安全
英雄联盟 换服务器
网络安全竞赛科普视频
信息基础设施安全与网络安全区别
国家数据库怎么下载
集中监控管理服务器怎么删除
中国广电网络技术部经理
web服务器的安全测试
网络安全法》第四章确立了
我的世界服务器管理隐身指令
黑客数据库有哪些
apex的服务器是哪个服
隔离网闸 数据库交换
知名的dns服务器租用公司
电力公司网络安全领导发言
爱数服务器地址是多少
网络安全 售前培训
青狼网络技术
软件开发开发票开什么项目
爱立信软件开发
新华三网络安全产品和方案
穿越火线生化有几个服务器
如何制作微信数据库
网络出现异常和服务器断开连接
Dell服务器列阵
服务器正在运行中 切换到
管家婆服务器安装
做游戏软件开发工作的都很忙吗
考勤管理系统需要服务器吗