hive学习 hive基本功

hive的基本用法:

(1)help命令

hadoop@hadoop-Lenovo-IdeaPad-Y470:~$ <span style="background-color: rgb(192, 192, 192);">hive --help</span><span style="color:#FF0000;">//help选项</span>
Usage ./hive <parameters> --service serviceName <service parameters>
<span style="color:#FF0000;">Service List: beeline cli help hiveserver2 hiveserver hwi jar lineage metastore metatool orcfiledump rcfilecat schemaTool</span>//可用的服务 
Parameters parsed:
  --auxpath : Auxillary jars 
  --config : Hive configuration directory
  --service : Starts specific service/component. cli is default
Parameters used:
  HADOOP_HOME or HADOOP_PREFIX : Hadoop install directory
  HIVE_OPT : Hive options
For help on a particular service:
  <span style="color:#FF0000;">./hive --service serviceName --help//service帮助</span>
Debug help:  ./hive --debug --help

---------service    serviceName    --help例子:

<span style="background-color: rgb(153, 153, 153);">hive --service cli --help</span>
usage: hive
 -d,--define <key=value>          Variable subsitution to apply to hive
                                  commands. e.g. -d A=B or --define A=B
    --database <databasename>     Specify the database to use
 -e <quoted-query-string>         SQL from command line
 -f <filename>                    SQL from files
 -H,--help                        Print help information
 -h <hostname>                    connecting to Hive Server on remote host
    --hiveconf <property=value>   Use value for given property
    --hivevar <key=value>         Variable subsitution to apply to hive
                                  commands. e.g. --hivevar A=B
 -i <filename>                    Initialization SQL file
 -p <port>                        connecting to Hive Server on port number
 -S,--silent                      Silent mode in interactive shell
 -v,--verbose                     Verbose mode (echo executed SQL to the
                                  console)

(2)变量的命名空间:

1.hivevar(用户变量设置的地方)     2.hiveconf       3.system   可读可写  4.env  只读

2-1变量的生命:

set hivevar:变量名=值
例子:

set hivevar:zhu=ming; 
create table test( ${hivevar:zhu} string ); 
describe test;
drop table test;

*注:hive中的“一次性”查询

hive -e ”select * from test;select * from test1“  >>/home/hadoop/out
进行两次查询,并将输出结果重定向


(3)hive中的查询方式:

3-1:从文件中载入命令查询:

方法一:
hive -f  /home/hadoop/test.hql
方法二(在hive的cli中):
 source /home/hadoop/test.hql
3-2:加载数据:

load  data  local inpath '/home/hadoop/testdata' into table test;

3-3:使cli在启动的时候进行一些预先操作:

hive --service cli -i//使用-i参数的时候,hive会自动在”/home/用户名/.hiverc"文件 并执行其中的命令

(4)cli的其他一些介绍:

4-1:在cli中使用shell命令:

<span style="color:#FF0000;">!</span> pwd
4-2:在cli中执行hadoop命令:

dfs -ls /


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值