(7-2)hive参数配置使用

本文介绍了Hive中不同类型的参数配置及其使用方法,包括通过${...}

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >


hive参数配置使用


在代码中引用时使用${...}

命名空间	使用权限	描述
	
hivevar		可读写		$hive -d name=baozi;

hiveconf	可读写		$hive --hiveconf hive.cli.print.current.db=true;
				$hive --hiveconf hive.cli.print.header=true;

system		可读写		Java定义的配置属性,如system:user.name
	
env		只读		shell环境变量,如env.USER

----------------------------------------------------------------------1--------------------------------------------------------
[root@i-love-you hive-0.14.0]# bin/hive -d name=baozi;

Logging initialized using configuration in jar:file:/usr/local/hive-0.14.0/lib/hive-common-0.14.0.jar!/hive-log4j.properties
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/usr/local/hadoop/share/hadoop/common/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/usr/local/hive-0.14.0/lib/hive-jdbc-0.14.0-standalone.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
hive> create table t1(id int,${name} string);
OK
Time taken: 2.359 seconds
hive> desc t1;
OK
id                      int
baozi                   string
Time taken: 0.461 seconds, Fetched: 2 row(s)
hive> describe t1;
OK
id                      int
baozi                   string
Time taken: 0.218 seconds, Fetched: 2 row(s)
hive>


----------------------------------------------------------------------2--------------------------------------------------------
会显示默认使用default数据库:
[root@i-love-you hive-0.14.0]# bin/hive --hiveconf hive.cli.print.current.db=true;

Logging initialized using configuration in jar:file:/usr/local/hive-0.14.0/lib/hive-common-0.14.0.jar!/hive-log4j.properti            
es
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/usr/local/hadoop/share/hadoop/common/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/Static            
LoggerBinder.class]
SLF4J: Found binding in [jar:file:/usr/local/hive-0.14.0/lib/hive-jdbc-0.14.0-standalone.jar!/org/slf4j/impl/StaticLoggerB            
inder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
hive (default)> use baozi;
OK
Time taken: 0.074 seconds
hive (baozi)>



空表会显示:表名.字段
[root@i-love-you hive-0.14.0]# bin/hive --hiveconf hive.cli.print.header=true;

Logging initialized using configuration in jar:file:/usr/local/hive-0.14.0/lib/hive-common-0.14.0.jar!/hive-log4j.properties
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/usr/local/hadoop/share/hadoop/common/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/usr/local/hive-0.14.0/lib/hive-jdbc-0.14.0-standalone.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
hive> select * from t1;
OK
t1.id   t1.baozi
Time taken: 1.751 seconds
hive>


普通登陆不会显示:表名.字段
[root@i-love-you hive-0.14.0]# bin/hive

Logging initialized using configuration in jar:file:/usr/local/hive-0.14.0/lib/hive-common-0.14.0.jar!/hive-log4j.properties
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/usr/local/hadoop/share/hadoop/common/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/usr/local/hive-0.14.0/lib/hive-jdbc-0.14.0-standalone.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
hive> select * from t1;
OK
Time taken: 1.413 seconds
hive>


----------------------------------------------------------------------3--------------------------------------------------------

[root@i-love-you hive-0.14.0]# bin/hive --hiveconf hive.cli.print.header=true;

Logging initialized using configuration in jar:file:/usr/local/hive-0.14.0/lib/hive-common-0.14.0.jar!/hive-log4j.properties
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/usr/local/hadoop/share/hadoop/common/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/usr/local/hive-0.14.0/lib/hive-jdbc-0.14.0-standalone.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
hive> select * from t2;
OK
t2.id
Time taken: 1.781 seconds
hive> create table t3(name string,${system:user.name} string);
OK
Time taken: 0.688 seconds
hive> select * from t3;
OK
t3.name t3.root
Time taken: 0.17 seconds
hive>



----------------------------------------------------------------------4--------------------------------------------------------



hive> create table t4(name string,${env:USER} string);
OK
Time taken: 0.209 seconds
hive> select * from t4;
OK
t4.name t4.root
Time taken: 0.118 seconds
hive>







附env命令显示:
[root@i-love-you hadoop]# env
HOSTNAME=i-love-you
SELINUX_ROLE_REQUESTED=
TERM=xterm
SHELL=/bin/bash
HADOOP_HOME=/usr/local/hadoop
HISTSIZE=1000
SSH_CLIENT=192.168.1.1 53096 22
SELINUX_USE_CURRENT_RANGE=
QTDIR=/usr/lib64/qt-3.3
OLDPWD=/usr/local
QTINC=/usr/lib64/qt-3.3/include
SSH_TTY=/dev/pts/0
JRE_HOME=/usr/local/jdk/jre
USER=root
LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:b                                                                   d=40;33;01:cd=40;33;01:or=40;31;01:mi=01;05;37;41:su=37;41:sg=30;43                                                                   :ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;                                                                   31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.t                                                                   xz=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lz                                                                   =01;31:*.xz=01;31:*.bz2=01;31:*.tbz=01;31:*.tbz2=01;31:*.bz=01;31:*                                                                   .tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.rar=01;31:*.ace=01;                                                                   31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpe                                                                   g=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35                                                                   :*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png                                                                   =01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35                                                                   :*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.ogm=01;35:*.mp4                                                                   =01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:                                                                   *.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=0                                                                   1;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xw                                                                   d=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35                                                                   :*.ogv=01;35:*.ogx=01;35:*.aac=01;36:*.au=01;36:*.flac=01;36:*.mid=                                                                   01;36:*.midi=01;36:*.mka=01;36:*.mp3=01;36:*.mpc=01;36:*.ogg=01;36:                                                                   *.ra=01;36:*.wav=01;36:*.axa=01;36:*.oga=01;36:*.spx=01;36:*.xspf=0                                                                   
1;36:
MAIL=/var/spool/mail/root
PATH=/usr/local/jdk/bin:/usr/local/jdk/jre/bin:/usr/local/zookeeper                                                                   
/bin:/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bi                                                                   n:/usr/sbin:/usr/bin:/usr/local/hadoop/bin:/root/bin
PWD=/usr/local/hadoop
JAVA_HOME=/usr/local/jdk
LANG=zh_CN.UTF-8
ZOOKEEPER_HOME=/usr/local/zookeeper
SELINUX_LEVEL_REQUESTED=
SSH_ASKPASS=/usr/libexec/openssh/gnome-ssh-askpass
HISTCONTROL=ignoredups
SHLVL=1
HOME=/root
LOGNAME=root
QTLIB=/usr/lib64/qt-3.3/lib
CVS_RSH=ssh
CLASSPATH=.:/usr/local/jdk/lib:/usr/local/jdk/jre/lib
SSH_CONNECTION=192.168.1.1 53096 192.168.1.10 22
LESSOPEN=|/usr/bin/lesspipe.sh %s
G_BROKEN_FILENAMES=1
_=/bin/env
[root@i-love-you hadoop]#




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值