hive导入数据

删除文档的第一行,文件导出第一行为列名
sed -i '1d' <file>
取第一行为日期的
cat hall.log | grep '2017-' > 0928.txt

替换分隔符为\0 sed -i 's/\t/\x1/g;s/;/\x1/g' test1.txt gz压缩 gzip -r test1.txt 查看文件 hdfs dfs -ls /hive/warehouse/ods_jungle_ad.db/table1/dt=2016-12-15 导入文件
hive -i /data/app/offline_analyse/conf/hive/init_hive.sql 

use ods_db;
load data local inpath
'/home/hadoop/test/test1.txt.gz' into table table1 partition (dt = '2016-12-15')

 

create table muses_role_log
(
  table_name string,
  id int,
  type string,
  big_date string
)
partitioned by (dt string)

 

 关键字[INTO]意思是追加到表,[OVERWRITE]意思是是覆盖原表里的数据。
 关键字[LOCAL]是指你加载文件的来源为本地文件,不写则为hdfs的文件。

 

如果是用程序接口直接写hdfs,需要执行如下语句hive才能访问

alter table ods_log.bigtable_log add partition (dt='2017-01-09',game_id='test');

  删除错误数据。直接删除分区(删除分区后需要添加分区,不让HIVE没法显示数据)

alter table tlog_bigtable drop partition(dt='2017-11-28' , game_id = 'gz_m')

全表删除

truncate table gz_m

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值