Hive交互操作命令

廉价感情. 提交于 2019-12-10 03:56:01

Hive交互操作命令

环境说明

OS : CentOs 6.4
mysql version : mysql-libs.zip 5.7.24
tips:Mysql和Hive安装在同一台Server上

操作命令

直接进去hive client 命令行窗口,执行SQL操作

bin/hive  

linux 命令行下 执行SQL语句 (数据库名+表名)
测试场景下使用较多


bin/hive -e "select count(*) from hive_test.u_data;";  

linux 命令行下 执行SQL语句文件 (数据库名+表名)
正式工作环境下使用,一般适用于复杂SQL编写执行

/opt/data目录下创建sql脚本,脚本内容为:select count(*) from hive_test.u_data ;
1.  touch /opt/data/hive.sql
执行SQL脚本
2.  bin/hive -f /opt/data/hive.sql 
SQL脚本结果输出待执行文件中
3. bin/hive -f /opt/data/hive.sql  > /opt/data/hive_result.txt 
查看结果
4. more /opt/data/hive_result.txt 

hive cli 命令窗口中如何查看hdfs文件系统

dfs -ls / ;

hive cli 命令窗口中如何查看本地文件系统

!ls /opt/app   路径没有提示 

** hive 命令帮助 **

bin/hive  -help

**查看hive历史命令 **

切换到home目录
1. cd ~
2. ls -al 
3. more .hivehistory
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!