hive创建表、数据库、分区和分桶及其他语句

create table ts01(id int,name string);

hive (default)> create table ts02(id int,name string)row format delimited fields terminated by ','、

hive (default)> create table ts03(id int,name string)partitioned by(dt string) row format delimited fields terminated by ',';

hive (default)> create table ts04(id int,name string)partitioned by(dt string,Tm string) row format delimited fields terminated by ',';

注意,这里dt和tm是子父级的关系,
alter table ts04 add partition(dt='2018-06-03',tm='15-41');
 alter table ts04 add partition(dt='2018-06-03',tm='15-45');

赋值一个表的结构,注意只是重新创建了一个和之前表结构一样的表,但是不加载前一张表的数据,即新复制出来的表是一张空表
create table ts03 like ts02;

对一张表添加分桶
create table ts05(id int,name string)clustered by(id) into 3 buckets row format delimited fields terminated by ',';
对一张表里的一个分区添加分桶
create table ts05(id int,name string)partitioned by(dt string) clustered by(id) into 3 buckets row format delimited fields terminated by ',';

清空表中的数据
truncate table ts01;

count()统计某一列的个数。

hive (default)> select count(name) from ts02;

hive (default)> select distinct count(distinct name) from ts02;

转载于:https://my.oschina.net/u/3197158/blog/1823501

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值