环境说明
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
来源:CSDN
作者:wanghuan524
链接:https://blog.csdn.net/wanghuan524/article/details/103465376