create table t1 (val int) PROPERTIES('replication_num'='1'); create table t2 (id int, val int) unique key(id) DISTRIBUTED BY HASH (id) PROPERTIES('replication_num'='1');
insert into t1 values(1);
with cte1 as (select*from t1 where val <=3) insert intotable t2 select val+10, val+100from cte1;
select*from t2;
3.2 InsertOverwriteTableCommand
1 2 3 4 5 6 7 8 9 10 11 12
create database test; use test;
create table t1 (val int) PROPERTIES('replication_num'='1'); create table t2 (id int, val int) unique key(id) DISTRIBUTED BY HASH (id) PROPERTIES('replication_num'='1');
insert into t1 values(1);
with cte1 as (select*from t1 where val <=3) insert overwrite table t2 select val+10, val+100from cte1; insert overwrite table t2 select val+10, val+100from t1;
select*from t2;
1 2
insert overwrite table t1 partition(p2) select*from t2; with cte1 as (select4) insert overwrite table t1 partition(p2) select*from cte1;
1 2
insert overwrite table t1 partition(*) select*from t2; with cte1 as (select1) insert overwrite table t1 partition(*) select*from cte1;
3.3 BatchInsertIntoTableCommand
1 2 3 4 5 6 7 8 9 10 11
sql """begin""" sql """insert into $t1 select * from $t2""" sql """insert into $t1 select * from $t3""" sql "commit"
//sql """insert into $t1 values(1)""" //sql """insert into $t1 values(2)""" //sql """insert into $t1 values(3)""" //sql """with cte1 as (select 1) insert into $t1 select * from cte1""" //sql """with cte2 as (select 2) insert into $t1 select * from cte2""" //sql """with cte3 as (select 3) insert into $t1 select * from cte3"""