hive复制分区表带数据

1.创建不带数据的表结构:create table new_table like old_table;

2.创建带数据的表但是没有分区结构:create new_table as select * from old_table;

3.创建带分区的表且包含数据:

  •   先复制表结构用第一条语句
  • 向表中插入数据:insert into new_table partition(sex = 'famle') select * from old_table where sex = 'famle'
  • 向表中动态插入分区数据:insert into new_table partition(sex) select * from old_table
  • 在动态插入的时候要将hive的严格分区参数设置更改,否则会报错,或者直接执行一次,报错会有提示更改参数信息;

猜你喜欢

转载自blog.csdn.net/bigdataprimary/article/details/82778019