hive -e
“-e”不进入hive的交互窗口执行sql语句
bin/hive -e "select id from student;"
hive -f
“-f”执行脚本中sql语句
(1)在/export/servers/datas目录下创建hive.sql文件
touch hive.sql
文件中写入正确的sql语句
select *from student;
(2)执行文件中的sql语句
bin/hive -f /export/servers/datas/hive.sql
(3)执行文件中的sql语句并将结果写入文件中
bin/hive -f /export/servers/datas/hivef.sql > /export/servers/datas/hive_result.txt