Hive常用命令
Posted 峰峰仔
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Hive常用命令相关的知识,希望对你有一定的参考价值。
quit和exit命令
[[email protected] bin]# hive WARNING: Use "yarn jar" to launch YARN applications. hive> quit; [[email protected] bin]# hive WARNING: Use "yarn jar" to launch YARN applications. hive> exit;
reset命令
hive> reset;
hive>
重置配置参数到默认的值,在hive控制台中,使用set命令或者-hiveconf设置的配置参数将会恢复到默认值。
reset命令并不应用在set命令中使用hiveconf:作为前缀的key名称
set命令
hive> set id = 1; hive> select * from employee where id = ${hiveconf:id}; OK Time taken: 0.124 seconds hive> set id = 16; hive> select * from employee where id = ${hiveconf:id}; OK 16 john 4000 USA Time taken: 0.104 seconds, Fetched: 1 row(s)
hive> set id;
id=16
hive> select ${hiveconf:id};
OK
16
Time taken: 0.197 seconds, Fetched: 1 row(s)
Add命令
Added [/home/hive/dufengHive-0.0.1-SNAPSHOT.jar] to class path Added resources: [/home/hive/dufengHive-0.0.1-SNAPSHOT.jar] hive> list jar; /home/hive/dufengHive-0.0.1-SNAPSHOT.jar hive> list jars; /home/hive/dufengHive-0.0.1-SNAPSHOT.jar hive> delete jars; Deleted [/home/hive/dufengHive-0.0.1-SNAPSHOT.jar] from class path hive> list jars;
List命令
hive> add jar /home/hive/dufengHive-0.0.1-SNAPSHOT.jar; Added [/home/hive/dufengHive-0.0.1-SNAPSHOT.jar] to class path Added resources: [/home/hive/dufengHive-0.0.1-SNAPSHOT.jar] hive> add file /home/hive/dufengHive-0.0.1-SNAPSHOT.jar; Added resources: [/home/hive/dufengHive-0.0.1-SNAPSHOT.jar] hive> add archive /home/hive/dufengHive-0.0.1-SNAPSHOT.jar; Added resources: [/home/hive/dufengHive-0.0.1-SNAPSHOT.jar] hive> list jars; /home/hive/dufengHive-0.0.1-SNAPSHOT.jar hive> list files; /home/hive/dufengHive-0.0.1-SNAPSHOT.jar hive> list archives; /home/hive/dufengHive-0.0.1-SNAPSHOT.jar
Delete命令
hive> delete jar; Deleted [/home/hive/dufengHive-0.0.1-SNAPSHOT.jar] from class path hive> delete file; hive> list files; hive> list archives; /home/hive/dufengHive-0.0.1-SNAPSHOT.jar hive> delete archives; hive> list archives;
Shell命令
hive> !ls -l; total 52 -rwxr-xr-x. 1 root root 1154 Apr 25 2016 beeline -rwxr-xr-x. 1 root root 1031 Apr 22 2016 beeline.distro drwxr-xr-x. 3 root root 4096 Sep 13 10:35 ext -rwxr-xr-x. 1 root root 675 Apr 25 2016 hcat -rwxr-xr-x. 1 root root 1151 Apr 25 2016 hive -rwxr-xr-x. 1 root root 1900 Apr 22 2016 hive-config.sh -rwxr-xr-x. 1 root root 8022 Apr 22 2016 hive.distro -rwxr-xr-x. 1 root root 1158 Apr 25 2016 hiveserver2 -rwxr-xr-x. 1 root root 885 Apr 22 2016 hiveserver2.distro -rwxr-xr-x. 1 root root 3064 Apr 22 2016 init-hive-dfs.sh -rwxr-xr-x. 1 root root 832 Apr 22 2016 metatool -rwxr-xr-x. 1 root root 884 Apr 22 2016 schematool
DFS命令
hive> dfs -ls /yandufeng; Found 6 items drwxr-xr-x - hive hive 0 2017-02-23 05:48 /yandufeng/date_partition drwxr-xr-x - hive hive 0 2017-02-23 06:14 /yandufeng/employee drwxr-xr-x - hive hive 0 2017-02-23 02:46 /yandufeng/external_weather -rw-r--r-- 3 root root 31 2016-11-27 05:23 /yandufeng/moving_data_to_hive.csv drwxr-xr-x - hive hive 0 2017-02-23 03:09 /yandufeng/partition_table drwxr-xr-x - hive hive 0 2017-02-23 06:43 /yandufeng/structured_table
查询命令
hive> select * from employee limit 5; OK 16 john 4000 USA 17 robert 2000 USA 18 andrew 4000 USA 19 katty 2000 USA 27 edward 4000 UK Time taken: 0.095 seconds, Fetched: 5 row(s)
执行脚本命令
hive> source /home/hive/query.hql; OK 16 john 4000 USA 17 robert 2000 USA 18 andrew 4000 USA 19 katty 2000 USA 27 edward 4000 UK 29 alan 3000 UK 31 kerry 4000 UK 34 tom 3000 UK 35 zack 2000 UK Time taken: 0.155 seconds, Fetched: 9 row(s)
以上是关于Hive常用命令的主要内容,如果未能解决你的问题,请参考以下文章