您的位置:首页 > 其它

Hive-3.hive 的 hql 语句

2016-01-27 11:33 363 查看
创建的hql主要包括以下内容

(1)表定义,创建表的时候使用

create table t

(2) 过滤数据,备份表,创建临时表

create table t_tmp as select * from t;

(3)已经存在表,向表中添加数据

load data [local] inpath 'data/a.txt' into table t;

(4)已经存在表定义,需要从其他表加载数据到表中

insert table t_1 select * from t;

(5)增加分区

alter table t add partition(provice='bj',city='haidian');

(6)case ... when 关键字使用

select case id when 1 then 'one' when 2 then 'two' else 'other' end from stu;

(7)实现单词计数

split explode

(8) 实现列转行

concat_ws

(9)实现行转列

split explode

(10)创建表

create table staff(id int,name string);

create table student(id int ,name string,birthday date,info map<string,string>);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: