"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的基本用法。
# 进入hcatalog执行路径
cd /root/apache-hive-0.14.0-bin/hcatalog/bin
# 创建一个表
./hcat -e "create table t9(id int,name string);"
# 查看这张表
./hcat -e "show tables;"
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的过程。
原文:https://www.cnblogs.com/alichengxuyuan/p/12576903.html