hive 命令

创建表

create cite(citing int,cited int)                                                   
     ROW FORMAT DELIMITED FIELDS TERMINATED BY ' ';  //此处我本来写的分隔符是/t 但是就是一直null 后来改成' 'ok

导入hdfs数据

load data  inpath 'hdfs://master:54310/user/root/cite.txt'  overwrite into table cite;

导入本地

oad data  local inpath '/usr/local/hadoop/hive/cite.txt'  overwrite into table cite; 

// 这个是本地文档。。在服务器那边。。错了很多次。。不是我用的windows主机


将查询结果导入某表中

insert overwrite table cite_count
     select cited ,count(citing)
     from cite
     group by cited;

删除表

drop table +表名

查询表行数

select count(1) from+表名


创建分区列以及桶分布

create table page (vie int,useid int,ip string comment 'ip address of the use') comment 'this is the page view table'

partitioned by (dt string,country string)      //分区列 
clustered by (useid) into 32 buckets row format //桶
delimited fields terminated by ' ' lines terminated by '\n'  //读取条件 
STORED AS textfile;                                  //文本格式

导入数据

load data inpath 'hdfs://master:54310/user/root/page.txt' overwrite into table page 
partition (dt='2014.3.20',country='china');                 //分区条件

查询表

desc + 表名

更改表名

alter table page rename to pag;
OK

增加新的列

alter table page add columns (newcol string);

删除一个分区

alter table page drop partition (dt=‘2014.3.20’);


连接操作

SELECT abc.* FROM abc JOIN cite  ON (abc.aa = cite.citing); 


SELECT a.val, b.val, c.val FROM a JOIN b ON (a.key = b.key1) JOIN c ON (c.key = b.key2)  




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值