hive分区视频资料:
hive的分区视频学习资料
1、hive表创建(生命周期1天、的外部表,扥分区名称是ds)
create external table test_external_location03 (
id string comment 'ID',
name string comment '名字'
)
comment '测试外部表location'
PARTITIONED BY (ds string)
ROW FORMAT DELIMITED FIELDS TERMINATED BY ','
location '/tmp/dkl/external_location'
lifecycle 1 ;
create external table test_external_location03 (
id string comment 'ID',
name string comment '名字'
)
comment '测试外部表location'
#这个是正常的创建表语句,comment是解释和说明
PARTITIONED BY (ds string)
#表示分区
ROW FORMAT DELIMITED FIELDS TERMINATED BY ','
#row类型的
location '/tmp/dkl/external_location'
#路径地址
create external table
#以external 这个关键字声明创建的表就是外部表。
lifecycle 1
#表示生命周期为1天
2、hive添加数据
#备注:测试过程中的坑,看网上帖子说 要进入到hive的外部路径下,写个txt文件,把内容push上去。
#这个不用这么弄啊
外部表和内部表加数据都是
insert into
INSERT INTO test_external_location03 PARTITION(ds='20211014') VALUES(14,'hhh'),(14,'hhh'),(14,'hhh'),(14,'hhh');
#这里ds='20211014' 这个是分区内容,要是创建的保持一致