Hive 读书笔记1:Getting Started

bin/hive --help

Usage ./hive --service serviceName
Service List: cli help hiveserver hwi jar lineage metastore rcfilecat(Hive支持的service)

对于某个具体的服务,要获取帮助的话,可以:

hive --help --service cli


hive中的变量和属性有这样四个名字空间:hivevar(可以读写),hiveconf(可以读写),system(可以读写),env(只读)。

1. --define key=value 选项等价于 --hivevar key=value,表示在hivevar名字空间下定义了这样一个变量。

2. 查看某个变量:hive> set env:HOME;

3. 查看全部变量:hive> set;

4. 查看具有某个特征的变量:

hive -S -e "set" | grep encoding

表示获取所以带有encoding的变量。-e后跟带引号的hive指令或者查询,-S去掉多余的输出。


hive执行查询或者指令的办法:

1. 用hive进入hive shell;

2. -e选项,例如:

hive -S -e "select * FROM mytable LIMIT 3" > /tmp/myquery

3. -f选项带一个文件,例如:

hive -f /path/to/file/withqueries.hql

如果已经在hive shell下了,用source命令执行:

hive> source /path/to/file/withqueries.hql;


Hive shell下执行Linux指令和Hadoop指令

Hive shell下执行Linux shell命令,加!即可(末尾加分号),不需要退出:

hive> ! pwd;

Hvie shell下执行hadoop的指令,直接用dfs即可,例如:

dfs -ls / ;


Hive的注释

加"--",其后的都被认为是注释。但主要CLI不解析注释。带有注释的文件只能通过这种方式执行:hive -f script_name。


打印查询头

需要显示设置:set hive.cli.print.header=true;


你可能感兴趣的:(Hadoop入门,Hive学习)