--自動補全功能:tab鍵shell
--能夠把「設置系統屬性變量,增長hadoop分佈式內存,自定義hive擴展的jar包」放在「$HOME/.hiverc」文件中bash
--在hive的CLI中執行bash shell命令,只要在命令前加上!,而且以分號(;)結尾就能夠 ! /bin/echo 「what up dog」;分佈式
--在hive中使用hadoop的dfs命令 dfs -ls /;函數
--查看錶的存儲路徑 hive -S -e "set" | grep warehouse;oop
--開啓hadoop回收站功能 --刪除的數據被轉移到HDFS中的/user/$USER/.Trash目錄中 -- fs.trash.interval後面的整數是「回收站檢查點」的時間間隔,單位是分鐘 fs.trash.interval=1440 --24小時日誌
--注意謂語操做符,「A=B」和「A<=>B」的區別 A=B --A等於B,返回true,反之返回false A<=>B --若是A和B都爲null返回true,其餘的等號(=)同樣排序
--修改log級別 --默認的日誌存放路徑: /tmp/<user.name>/hive.log內存
--經過配置能夠指定Hive中log4j日誌配置文件的存放路徑 hive -hiveconf hive.log4j.file=/home/carl/hive-log4j.properties -hiveconf hive.log4j.exec.file=/home/carl/hive-exec-log4j.propertieshadoop
--臨時 hive --hiveconf hive.root.logger=DEBUG,console開發
--修改${HIVE_HOME}/conf/hive-log4j.properties文件(永久) hive.root.logger=DEBUG,console
--set hiveconf:hive.root.logger=DEBUG,console;是無效的,不能使用的。由於設定log的參數讀取在會話創建之前已經完成了。
--case ...when...then句式 select name,salary, case when salary < 50000.0 then ‘low’ when salary > 50000.0 and salary < 7000.0 then ‘middle’ else ‘high’ end as bracket from employees;
--浮點數儘可能使用double,對於已經使用float的要使用cast操做符 --和錢相關的都避免使用浮點數 cast(0.2 as float) --不過將浮點型轉換爲整數,推薦使用round()或floor(),而不是用cast。
--hive的join語句,只支持等值鏈接。(注:pig提供的交叉生成功能支持「非等值鏈接」) --hive目前不支持在join 的on子句中使用or。
--order by:全局排序 --sort by:局部排序 --若是hive.mapred.mode=strict;時候,由於order by 時間比較長。必須加上limit限制。
--distribute by來保證具備相同屬性值的記錄會分到同一個reduce中進行處理 select s.ymd,s.symbol,s.price_close from stocks s distribute by s.symbol sort by s.symbol ASC,s.ymd ASC;
--若是distribute by和sort by語句中涉及到的列徹底相同,並且採用的默認的升序排序方式。那麼在這種狀況下,可使用cluster by來代替。 --注意:使用distribute by和sort by語句 或者簡化版的cluster by語句會剝奪sort by的並行性,然而這樣能夠實現輸出文件的數據是全局排序的。
-- explain dependency語法:以JSON格式輸出table或partition信息 explain dependency select * from wyp;
-- TRUNCATE能夠刪除HDFS上面相關表存儲的數據,可是會保持表和metadata的完整性 truncate table p;
--在開發了hive的udf udaf udtf函數的jar文件後,須要將jar文件放入hive的環境中才可使用。 add jar path/test.jar;