hive的cli命令变量和属性
set -------打印出命名空间hivevar,hiveconf,system,env所有的变量 set -v + hadoop定义的属性,例如HDFS和MapReduce的属性
$ hive --define foo=bar; | $hive --hivevar foo=bar;
hive>set foo; foo=bar
hive>set hivevar:foo hivevar:foo=bar
//显示当前数据库名 $ hive --hiveconf hive.cli.print.current.db=true hive (default) >set hiveconf:hive.cli.print.current.db hiveconf:hive.cli.print.current.db=true
//显示字段名称 hive>set hive.cli.print.header=true;
system命名空间可读写,env命名空间只可读
hive> set system:user.name; system:user.name=root hive> set system:user.name=jsh; hive> set system:user.name; system:user.name=jsh
hive> set env:HOME; env:HOME=/root hive> set env:HOME=AA; env:* variables can not be set.
//直接在外面执行hive命令 $ hive -e "load data local inpath 't1' into table t1" $ hive -S -e "select * from t1 limit 3" > temp
[root@hadoop test]# hive -S -e "set" | grep warehouse hive.metastore.warehouse.dir=/hive hive.warehouse.subdir.inherit.perms=false
//执行文件 [root@hadoop test]# hive -f query.hql hive>source query.hql
//在hive命令行执行shell命令 !xxxx; hive (default)> ! pwd ; /root
//在hive中执行hadoop命令 hive>dfs -hlep; hive>dfs -ls /;
//常用设置放入.hiverc [root@hadoop ~]# more .hiverc; set hive.cli.print.current.db=true; set hive.exec.mode.local.auto=true; set hive.cli.print.header=true;