hive常用小常识(持续更新中)

1、hive函数:http://www.cnblogs.com/end/archive/2012/06/18/2553682.html

2、hive QL语言:https://cwiki.apache.org/Hive/languagemanual-ddl.html#LanguageManualDDL-Create%252FDropTable

3、creat  [EXTERNAL] table   ...... location '/***/***/'    无论创建外部还是内部表,若是不指定具体的表空间路径,则会在默认的路径下创建一个表明相同的文件夹作为表空间 。但是在drop table时候,若是外部表,则不删除任何数据 。

4、 alter table tablename add partition (dt='******')  location '' ;  若是指定路径,则使用指定路径下的文件夹作为该partition的存储空间,若是不指定,则在表空间下创建dt='******' 文件夹  。 location可以使相对路径,相对于表空间路径  。

5、alert table tablename drop partition ,这个针对内部表,会删除该partition的文件夹 ,但是对于EXTERNAL表不做任何操作 。

6、hive执行语句分为plain语句时间,和执行mapreduce时间 ,hive会缓存每个hql语句的plain ,所以同类型的语句 ,such as :select  *  from dingdongchao_hive_data  where dt='2012-07-27' ;  和 select  *  from dingdongchao_hive_data  where dt='2012-07-26' ;  执行第二个语句会比第一个耗时更短,主要是在plain上几乎没有时间  。这一条在实际操作经验中得出 ,具体还有待验证 。

7、hive 的cli (默认的hive启动的程序 )程序参数意义 :

Usage: hive [-hiveconf x=y]* [<-i filename>]* [<-f filename>|<-e query-string>] [-S] 
-i <filename> Initialization Sql from file (executed automatically and silently before any other commands)
在hive cli 执行前的任何命令之前,以静默方式执行此命令 。
-e 'quoted query string' Sql from command line
执行后面跟着的命令行语句 。
-f <filename> Sql from file
执行sql file中的语句 。
-S Silent mode in interactive shell where only data is emitted
以静默的方式执行hql语句,只显示数据,不显示一系列的控制语句 ,例如:耗时、map、reduce执行过程、sql调用mapredu的相关设置信息等 。
-hiveconf x=y Use this to set hive/hadoop configuration variables.
设置属性,相当于hadoop-site.xml hive-site.xml中的key-value值对
-e and -f cannot be specified together. In the absence of these options, interactive shell is started. However, -i can be used with any other options. To see this usage help, run hive -h

8、hive在做操作group时候,可以优化的地方:将map端group打开,增加reduce数量  。

 

原文地址:https://www.cnblogs.com/serendipity/p/2695447.html