hive常用命令

1.创建hive表:
create table tabname(
id int,
name string
)partitioned by (year int,month int,day int)
row format delimited fields terminated by'\t'
lines terminated by'\n'
stored as textfile;
2.添加数据:
(1)从本地添加:
load data local inpath '/home/data/a.txt' into table a;
(2)从hdfs添加:
load data inpath 'x/x/x.log' overwrite into table a;
(3)从hive表结果数据添加:
insert into table a select * from b;
3.查看表中的分区:
show partitions tabname;
4.修改表名:
alter table a rename to b;
5.修改列名和类型:
alter table a change cloumn a b int after class;
6.增加列:
alter table a add cloumns(a int,b string);
7.替换列:
alter table a replace cloumns(a int,b string);
8.修改表属性:
alter table a set tblproperties('EXTERNAL'='true');外转内>关键字必须大写
9.赋权:
grant all on uri 'hdfs://nameservice//user/xxx/test/' to role USERGROUP;
grant 'user','RW','tablename'
10.批量执行hive脚本
$bin/hive -f test
hive> source /home/wyp/Documents/test;

转载于:https://www.cnblogs.com/lccyb/p/9488110.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值