hive 加载gz_HIVE的sequenceFile的操作常用命令

sequencefile是一组Key和Value的健值对。在实际中HIVE创建表时,key是没有无意义的。它只根据value的格式进行切换数据。

0.登录容器并连接上hive

docker-compose -f docker-compose-hive.yml exec hive-server bash

/opt/hive/bin/beeline -u jdbc:hive2://localhost:10000

docker-compose -f docker-compose-hive.yml exec hive-server bash

/opt/hive/bin/beeline -u jdbc:hive2://localhost:10000

1.建表

create external table sfgz(

`idx` string,

`userid` string,

`flag` string,

`count` string,

`value` string,

`memo` string)

partitioned by (dt string)

row format delimited fields terminated by ','

stored as sequencefile

location '/user/sfgz';

create external table sfgz(

`idx` string,

`userid` string,

`flag` string,

`count` string,

`value` string,

`memo` string)

partitioned by (dt string)

row format delimited fields terminated by ','

stored as sequencefile

location '/user/sfgz';

2.分区加载

方法一:

hadoop fs -mkdir -p /user/sfgz/dt=2010-05-06/

hadoop fs -put /tools/mytest.txt.sf /user/sfgz/dt=2019-05-17

hadoop fs -put /tools/mytest.txt.sf /user/sfgz/dt=2010-05-04

这样是无法直接被hive所识别的,必须用alter table partition的命令把相应的分区表加入至数据库中,才能正常访问。

方法二,加载完就可以直接查询的:

load data local inpath ‘/tools/mytest.txt.sf’ into table sfgz partition(dt=’2009-03-01′);这种方法是可以直接查询了。

load data local inpath ‘/tools/mytest.gzip.sf’ into table sfgz partition(dt=’2000-03-02′);

3. 检查分区信息:

show partitions sfgz;

4. 添加分区

alter table sfgz add partition(dt=’2000-03-03′);

5. 插入一条记录:

insert into sfgz partition(dt='2019-05-16')values('idx3','uid6','5','6','34.7','uid3test2');

insert into sfgz partition(dt='2019-05-16')values('idx3','uid6','5','6','34.7','uid3test2');

6. 统计指令:

select count(*) from sfgz; 在KMR中不支持这种方式。

select count(idx) from sfgz; 在KMR中只支持这种方式。

6. 其它常见命令

show databases;

use database;

whow tables;

select * from sfgz where dt=’2000-03-03′;

msck repair table sfgz; 分区修复指令:

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值