Hive建表高阶语句和视图
Hive建表高阶语句(CTAS and WITH)
- CTAS – as select方式建表(会复制表结构和表数据)
create ctas_employee as select * from employee;
注:CTAS不能创建partition, external, bucket table
- CTE (CTAS with Common Table Expression)
create table jobs_detail as
with
tmp as (select jobs from employee_partition where info.gender='Male'),
t2 as (select jobs from employee_partition where info.gender='Female')
select tmp.jobs male_job,t2.jobs female_job from tmp,t2;
- Like(只复制表结构)