hive的cli命令变量和属性

本文详细介绍了Hive中的set命令用法,包括如何设置和查看不同命名空间内的变量,如hivevar、hiveconf、system和env等。同时展示了如何通过hive命令行进行基本的数据操作,并提供了一些实用的配置选项。

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

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


# hive -S -e "set" | grep warehouse
hive.metastore.warehouse.dir=/hive
hive.warehouse.subdir.inherit.perms=false

//执行文件
# hive -f query.hql
hive>source query.hql

//在hive命令行执行shell命令 !xxxx;
hive (default)> ! pwd ;
/root

//在hive中执行hadoop命令
hive>dfs -hlep;
hive>dfs -ls /;

//常用设置放入.hiverc
# more .hiverc;
set hive.cli.print.current.db=true;
set hive.exec.mode.local.auto=true;
set hive.cli.print.header=true;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值