HIVE-执行命令的几种方式 和 hive -e 和hive -f的使用

时间:2025-04-11 14:01:21

第一种,在bash中直接通过hive -e命令,并用 > 输出流把执行结果输出到制定文件

hive -e "select * from test.hour_rate2 where year='2019'" > /tmp/output_1.txt

第二种,在bash中直接通过hive -f命令,执行文件中一条或者多条sql语句。并用 > 输出流把执行结果输出到制定文件

hive -f /tmp/  > /tmp/output_3.txt

 文件内容
use test;
select * from hour_rate2 where year = '2018';
select count(*) from hour_rate2;

第三种,进入hive环境中输入hive-sql语句

以上是三种,包含了3执行hive-sql的方法。
前两种都属于linxu BASH自带的方法。第三种才是HIVE本身的方法.