06 通过Hcatalog访问Hive

"HCatalog is a table and storage management layer for Hadoop that enables users with different data processing tools — Pig, MapReduce — to more easily read and write data on the grid",这段摘自官网的话表述了Hcatalog的作用,它就是一个更为方便的数据管理工具。本小节将介绍Hcatalog的基本用法。

1、前提约束

2、操作步骤

  • 执行以下命令
# 进入hcatalog执行路径
cd /root/apache-hive-0.14.0-bin/hcatalog/bin
# 创建一个表
./hcat -e "create table t9(id int,name string);"
# 查看这张表
./hcat -e "show tables;"
  • 假设/root/apache-hive-0.14.0-bin/hcatalog/bin路径下有一个info.dat,内容如下:
Nehru,2016-01-01
Dane,2016-01-01
Walter,2016-01-01
Gloria,2016-01-01
Clarke,2016-01-01
Madeline,2016-01-01
Kevyn,2016-01-01
Rebecca,2016-01-01
Calista,2016-01-01
Lana,2016-01-01
Phoebe,2016-01-01
Clayton,2016-01-01
Kimberly,2016-01-01
Drew,2016-01-01
Giselle,2016-01-01
Nolan,2016-01-01
Madeson,2016-01-01
Janna,2016-01-01
Raja,2016-01-01
Merrill,2016-01-01
  • 继续执行以下命令:
# 创建一张表
./hcat -e "create table if not exists t_login(name string,time string) comment 'login info' row format delimited fields terminated by ',' lines terminated by '\n' stored as textfile;"
# 加载info.dat
./hcat -e "load data local inpath 'info.dat' into table t_login"
# 查询t_login表
./hcat -e "select * from t_login;"

以上就是通过Hcatalog访问Hive的过程。

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值