搜索

HIVE换表加分区字段的步骤


发布时间: 2023-03-21 18:25:00    浏览次数:17 次

分享时间:2023-03-21 18:25:00
数据来源:网络
提取密码:在线浏览
文件类型:文章

换表加分区字段的步骤

0.统计总数,分区数,保存建表语句

select count(1) as num from table1
show partitions table1
show create table table1

1.复制原有结构,新建临时表

CREATE TABLE table2 like table1

2.复制原有表数据

SET hive.exec.dynamic.partition.mode=nonstrict;
INSERT OVERWRITE table2 partition(x)
select * from table1

3.删除原有表

drop table table1

4.新建新分区表 加上需要的分区字段

CREATE TABLE table1

5.插入临时表的数据到新建分区表

SET hive.exec.dynamic.partition.mode=nonstrict;
SET hive.exec.max.dynamic.partitions.pernode = 100000;
INSERT OVERWRITE table1 partition(x,xx)
select * from table2(有些要抽字段顺序)

6.统计总数,分区数 是否正常

select count(1) as num from table1
show partitions table1

7.删除临时表

drop table table2
免责声明 HIVE换表加分区字段的步骤,资源类别:文本, 浏览次数:17 次, 文件大小:-- , 由本站蜘蛛搜索收录2023-03-21 06:25:00。此页面由程序自动采集,只作交流和学习使用,本站不储存任何资源文件,如有侵权内容请联系我们举报删除, 感谢您对本站的支持。 原文链接:https://segmentfault.com/a/1190000043567039