当前位置:   article > 正文

hive复制表结构和数据的方法

hive复制表结构和数据

1、非分区表

1) 全同步

create table table_new as select * from table_old;
  • 1

2) 部分同步(同步name,age,sex三个字段的数据)

create table table_new as 
select
	name,
	age,
	sex
from table_old
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

2、分区表

1)复制表结构

create table table_new like table_old;
  • 1

2 )复制数据:

a. 第一种

insert overwrite table table_new partition(dt) select * from table_old;
  • 1

b. 第二种(数据量大,推荐)

dfs -cp /user/bigdata.db/table_old/* /user/bigdata/db/bigdata_new/;
-- 拷贝完,修复分区
msck repair table table_new;
  • 1
  • 2
  • 3
声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:【wpsshop博客】
推荐阅读
  

闽ICP备14008679号