1.最基本的hive命令行;
Linux命令行直接hive 进入hive 命令行;

2.脚本运行方式(适用于生产环境)
hive -e "hive sql语句":执行结果在Linux控制台打印

hive -e “Sql">aaa:将结果重定向到指定文件:文件没有会自动创建;

hive -S -e “”>aaa :结果静默输出:与不加-S的区别在于没有打印hive中的提示信息;(OK,TimeTaken等)

hive -f file 执行指定文件中的命令:hiveshell2中的内容是
select * from psn limit 2

可以配合Linux中的crontab命令,来定时执行hive命令;新建一个文件,里面使用hive -f ,定时运行该文件;

网友评论