记一个Hive从文本文件导入生产库的操作案例

 
show create table tmp_dm_lomp.ori_fvp_route_ru;  #查看生产表结构准备先导入临时表

CREATE  TABLE  test5(  #新建临时表 把数据导入临时表
`sf_waybill_no` string COMMENT '顺丰运单号',
`opr_dept_code` string COMMENT '巴枪操作网点',
`bar_opr_code` string COMMENT '巴枪操作码',
`bar_opr_name` string COMMENT '巴枪操作名称',
`opr_emp_code` string COMMENT '巴枪操作员工',
`route_type_code` string COMMENT '路由类型代码',
`bar_upload_time` timestamp COMMENT '巴枪上传时间',
`bar_scan_time` timestamp COMMENT '巴枪扫描时间',
`bar_upload_time_std` timestamp COMMENT '巴枪上传时间零时区',
`bar_scan_time_std` timestamp COMMENT '巴枪扫描时间零时区',
`create_time` timestamp COMMENT '创建时间',
`create_sys` string COMMENT '来源系统')
ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t'  #注意导入临时表的列分割符号是 \t 因为是excel复制出来的

 load data inpath '/user/01389470/upload/test.txt' into table test5; #导入
 
 select * from test5 limit 10; #查看导入数据情况
 
 insert overwrite table tmp_dm_lomp.ori_fvp_route_ru partition(inc_day='20200729') select * from test5; #检查无误后导入生产库
 
 drop table test5; #删除中间表
 
 select * from tmp_dm_lomp.ori_fvp_route_ru where inc_day='20200729' limit 5; #检查生产库

注意:OVERWRITE 表示是否覆盖表中数据(或指定分区的数据)(没有OVERWRITE 会直接APPEND,而不会滤重!)
本次 inc_day=‘20200729’ 是专门给这些临时添加的数据增设的分区

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值