create table ts01(id int,name string);orm
hive (default)> create table ts02(id int,name string)row format delimited fields terminated by ','、string
hive (default)> create table ts03(id int,name string)partitioned by(dt string) row format delimited fields terminated by ',';it
hive (default)> create table ts04(id int,name string)partitioned by(dt string,Tm string) row format delimited fields terminated by ',';io
注意,這裏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');table
賦值一個表的結構,注意只是從新建立了一個和以前表結構同樣的表,可是不加載前一張表的數據,即新複製出來的表是一張空表
create table ts03 like ts02;form
對一張表添加分桶
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 ',';select
清空表中的數據
truncate table ts01;im
count()統計某一列的個數。統計
hive (default)> select count(name) from ts02;數據
hive (default)> select distinct count(distinct name) from ts02;