Hive在启动时,会先执行Hiverc文件,例如每次都会使用的UDF UDAF等用户自定义函数,没必要每次都命名。能够直接写入hiverc文件。数据库
在${HIVE_HOME}/bin目录下有个.hiverc文件,它是隐藏文件,咱们能够用Linux的ls -a命令查看。咱们在启动Hive的时候会去加载这个文件中的内容,因此咱们能够在这个文件中配置一些经常使用的参数,以下: apache
#在命令行中显示当前数据库名 set hive.cli.print.current.db=true; #查询出来的结果显示列的名称 set hive.cli.print.header=true; #启用桶表 set hive.enforce.bucketing=true; #压缩hive的中间结果 set hive.exec.compress.intermediate=true; #对map端输出的内容使用BZip2编码/解码器 set mapred.map.output.compression.codec=org.apache.hadoop.io.compress.BZip2Codec; #压缩hive的输出 set hive.exec.compress.output=true; #对hive中的MR输出内容使用BZip2编码/解码器 set mapred.output.compression.codec=org.apache.hadoop.io.compress.BZip2Codec; #让hive尽可能尝试local模式查询而不是mapred方式 set hive.exec.mode.local.auto=true;
命令的运行方式:函数