创建表
CREATE EXTERNAL TABLE test.user_info(id INT,uid STRING,item_id STRING,behavior_type INT,item_category STRING,visit_date DATE,province STRING)
COMMENT 'user information!'
ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t'
STORED AS TEXTFILE LOCATION '/bigdatacase/dataset';
创建分区表
create table tb_partition(id string, name string)
PARTITIONED BY (month string)
row format delimited fields terminated by '\t';
载入本地数据,常做测试用
create table test.user_partition(id string, name string)
PARTITIONED BY (month string)
row format delimited fields terminated by '\t';
load data local inpath '/home/sheldonwong/data/partition'
overwrite into table test.user_partition
partition(month='201709');
load data local inpath '/home/sheldonwong/data/partition2'
overwrite into table test.user_partition
partition(month='201708');
参考: