我有两个具有相同列的表,并且想要创建包含表1和表2的所有记录的第3个表。我这样做。但它不起作用。请帮忙
select * into R5 from
(select
r.account_id as account_id,
r.dim_account_key as dim_account_key,
r.activation_date as activation_date,
r.serial_number as serial_number
from R5_1 r
union all
select
s.account_id as account_id,
s.dim_account_key as dim_account_key,
s.activation_date as activation_date,
s.serial_number as serial_number
from R5_2 s) R
答案 0 :(得分:0)
Hive没有任何" SELECT INTO"声明。我相信你的意思是" INSERT INTO TABLE"。所以你的查询就像:
INSERT INTO TABLE R5
SELECT * FROM
(select
r.account_id as account_id,
r.dim_account_key as dim_account_key,
r.activation_date as activation_date,
r.serial_number as serial_number
from R5_1 r
union all
select
s.account_id as account_id,
s.dim_account_key as dim_account_key,
s.activation_date as activation_date,
s.serial_number as serial_number
from R5_2 s) R
请记住, INSERT INTO TABLE 会将数据附加到表中,如果要覆盖,请将其替换为 INSERT OVERWRITE TABLE