命令行模式,或者說目錄模式,可以使用hive 執行命令。
選項說明:
-e : 執行短命令
-f : 執行文件(適合腳本封裝)
-S : 安靜模式,不顯示MR的運行過程
-hivevar : 用於定義hive運行時的變量替換 ,專門提供給用戶自定義變量。
-hiveconf : 用於定義hive執行時的屬性,即配置參數,可覆蓋hive-site.xml中配置的hive全局變量。
egg:
hive -e查詢:
hive -S -e "use tv; select * from test;"
hive -f 執行文件:
hive -S -f test.hql
hive -hivevar設置參數:
hive -hivevar database -f test.hql
test.hql 中使用${database} or ${hivevar:database}
hive -hiveconf設置參數:
hive -hiveconf database -f test.hql
test.hql 中使用${hiveconf:database}
設置覆蓋hive配置參數:
hive -hiveconf "hive.merge.mapfiles=true" -f test.hql