hive数据表定义

分隔符
CREATE TABLE emp(
userid bigint,
emp_name array,
emp_date map,
other_info struct)
ROW FORMAT DELIMITED
FIELDS TERMINATED BY '\t'
COLLECTION ITEMS TERMINATED BY ','
MAP KEYS TERMINATED BY ':';

FIELDS TERMINATED BY '\t'                             --字段之间的分隔符为制表符('\t')

COLLECTION ITEMS TERMINATED BY ','         --集合项之间的分隔符为逗号(',')

MAP KEYS TERMINATED BY ':'                         --MAP中每个键值对由冒号分隔

如:birth date:1953-11-07,from date:1990-01-22


分区表 
create table dept_partition(  
deptno int, dname string, loc string) 
partitioned by (day string) 
row format delimited fields terminated by '\t'; 

查询分区表中数据

select * from dept_partition where day='20200401'; 

增加分区

alter table dept_partition add partition(day='20200404');

alter table dept_partition add partition(day='20200405') partition(day='20200406'); 

删除分区

alter table dept_partition drop partition (day='20200406'); 

alter table dept_partition drop partition (day='20200404'), partition(day='20200405');  
 二级分区
create table dept_partition2(
deptno int, dname string, loc string ) 
partitioned by (day string, hour string)
row format delimited fields terminated by '\t'; 

你可能感兴趣的:(hive,hadoop,数据仓库)