hive中快速对表结构数据进行复制

1. CREATE TABLE new_table LIKE old_table;

2. 使用Hadoop fs -cp 命令,把old_table对应的HDFS目录的文件夹全部拷贝到new_table对应的HDFS目录下;

3. 使用MSCK REPAIR TABLE new_table;修复新表的分区元数据;


  1. #当前没有partition元信息  
  2. hive> show partitions cr_cdma_bsi_mscktest;  
  3. OK  
  4. Time taken: 0.104 seconds  
  5. #创建两个分区目录  
  6. hive> dfs -mkdir /user/hive/warehouse/cr_cdma_bsi_mscktest/month=201603;  
  7. hive> dfs -mkdir /user/hive/warehouse/cr_cdma_bsi_mscktest/month=201604;  
  8. #使用MSCK修复分区  
  9. hive> msck repair table cr_cdma_bsi_mscktest;  
  10. OK  
  11. Partitions not in metastore:    cr_cdma_bsi_mscktest:month=201603  
  12. Partitions not in metastore:    cr_cdma_bsi_mscktest:month=201604  
  13. Repair: Added partition to metastore cr_cdma_bsi_mscktest:month=201603  
  14. Repair: Added partition to metastore cr_cdma_bsi_mscktest:month=201604  
  15. Time taken: 0.286 seconds, Fetched: 2 row(s)  
  16. #再次查看,发现已经成功更新元信息  
  17. hive> show partitions cr_cdma_bsi_mscktest;  
  18. OK  
  19. month=201603  
  20. month=201604  
  21. Time taken: 0.102 seconds, Fetched: 1 row(s)  

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值