1. 程式人生 > >hive中建立表命令

hive中建立表命令

情況1:設定分割槽:

DROP TABLE IF EXISTS adm_investor_activity;
CREATE TABLE IF NOT EXISTS adm_investor_activity(
    	investor_id		bigint	comment	'投資人id'
    ,	score			double  comment '投資人活躍度評分'
)
comment 'adm投資人活躍度表'
partitioned by (ds string comment '時間分割槽')
stored as parquet;

情況2:不設定分割槽:

drop table if exists student_info;


create table if not exists student_info (
    id bigint comment 'ID',
    name string comment '姓名',
    age bigint comment '年齡',
    weight bigint comment '體重(kg)'
) comment '學生基本資訊' row format delimited fields terminated by ',' lines terminated by '\n' stored as textfile;

情況三:建立臨時表

create temporary view tv_invest_history as
select
*
from
	dwd_rsc_invest_history_dd
where
	ds = ‘條件’; 

hive表中load資料命令

load data local inpath '地址' overwrite into table demo_dim_address_city;