建立基表
– 建表时请尽量不要指定LOCATION,防止错误的指向已存在的表路径!
USE Tmp_UbtDb;
CREATE TABLE tableNameDemo (
field1 STRING COMMENT 'field1 comment',
field2 STRING COMMENT 'field2 comment')
COMMENT 'table comment'
PARTITIONED BY(d STRING COMMENT 'date')
STORED AS ORC;
建立分区表
–增量分区(只保留当天数据)
SET hive.exec.max.dynamic.partitions=1000;
SET hive.exec.max.dynamic.partitions.pernode=1000;
use products_fg; - - 选择库
INSERT overwrite TABLE products.sgy_daily_product
partition(d='${zdt.format("yyyy-MM-dd")}')
select
–全量分区(保留全量数据)
set hive.exec.dynamic.partition.mode=nonstrict;
SET hive.exec.max.dynamic.partitions=1000;
SET hive.exec.max.dynamic.partitions.pernode=1000;
use products_fg;
INSERT overwrite TABLE products.sgy_daily_product_whole
partition(d='${zdt.format("yyyy-MM-dd")}')
select *
from products.sgy_daily_product
where d >= '2020-01-01';
插表
use products_fg;
insert overwrite table
select *
from products_fg.T
2173

被折叠的 条评论
为什么被折叠?



