本文為您介紹Union All變更的可相容性和不可相容性詳情。
可相容的變更
調整Union All的輸入Query的順序,對下遊有狀態運算元屬於完全相容變更。
create table MyTable2 (
a int,
b bigint,
c varchar,
d int
);
-- 原始SQL。
select a, sum(b), max(c) from (
select a, b, c from MyTable union all select a, b, c from MyTable2
) group by a;
--調整Union All的輸入Query的順序,該修改屬於完全相容修改。
select a, sum(b), max(c) from (
select a, b, c from MyTable2 union all select a, b, c from MyTable
) group by a;
不相容的變更
添加或刪除Union All的輸入Query,對下遊有狀態運算元屬於不相容性變更。
create table MyTable2 (
a int,
b bigint,
c varchar,
d int
);
-- 原始SQL。
select a, sum(b), max(c) from (
select a, b, c from MyTable union all select a, b, c from MyTable2
) group by a;
create table MyTable3 (
a int,
b bigint,
c varchar,
d int
);
-- 添加Union All的輸入Query,該修改屬於不相容修改。
select a, sum(b), max(c) from (
select a, b, c from MyTable
union all
select a, b, c from MyTable2
union all
select a, b, c from MyTable3
) group by a;