1、用hive查询,而不进入hive cli,查询后的值可以保存到文件中
#使用参数-e
[hadoop@bigdata-senior01 ~]$ hive -e "select * from busdata.weather_count" OK
1990 900
1991 887
1992 909
1993 923
1994 873
1995 866
1996 987
1997 961
1998 853
1999 914
2000 927
Time taken: 3.221 seconds, Fetched: 11 row(s)
#加上静默开关-S,过滤ok和tim taken
[hadoop@bigdata-senior01 ~]$ hive -S -e "select * from busdata.weather_count"
1990 900
1991 887
1992 909
1993 923
1994 873
1995 866
1996 987
1997 961
1998 853
1999 914
2000 927
#结果导入到本地文件中
[hadoop@bigdata-senior01 ~]$ hive -S -e "select * from busdata.weather_count" > weather_max.txt
2、查找某个配置属性
[hadoop@bigdata-senior01 ~]$ hive -S -e "set" | grep warehouse
hive.metastore.warehouse.dir=/hive/warehouse
3、执行外部脚本
[hadoop@bigdata-senior01 ~]$ cat weather_query.hql
select * from busdata.weather_count;
select * from busdata.weather_max; [hadoop@bigdata-senior01 ~]$ hive -f /home/hadoop/weather_query.hql
#静默执行,然后结果导入文件
[hadoop@bigdata-senior01 ~]$ hive -S -f /home/hadoop/weather_query.hql >weather_mix.txt