繁体   English   中英

将数据从一个分区表复制到另一个新的分区表

[英]copy data from one partitioned table to another new partitioned table

需要将数据从一个分区表复制到另一个新的分区表尝试了这种方法但不起作用

create table if not exists box_db.table_1 partitioned by (sch_ky, at_ky, date) as select * from sand_db.table_2

也试过

create table box_db.table_1 (id bigint, sch_val int, at_val int) partitioned by (sch_ky int, at_ky int, date string)

并将数据插入其中

insert into box_db.table_1 select * from sand_db.table_2

但两者都不起作用

使用新的分区值创建表。 然后插入分区表,你需要 -

  1. 如果您要插入具有动态分区的表,请提及分区列。
insert into box_db.table_1 partition(id, sch_val, at_val) select ..., id,sch_val, at_val from sand_db.table_2 -- make sure  last columns matches to last columns in select clause

或 2. 如果您要使用 static 分区插入表中,请提及分区值。

insert into box_db.table_1 partition(id=1, sch_val=2, at_val=3) select ...  from sand_db.table_2 -- make sure  all columns in select matches to the columns in table

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM