Vertica SQL 中的联合表,其中表的列顺序不同?
Union tables in Vertica SQL where tables have different order of columns?
我在 Vertica SQL 中有 2 个 table,我如何联合所有这些 table 以创建 table 作为结果?如您所见,tables 1 和 table 2 具有不同的列顺序:
enter image description here
只需按您希望的顺序列出列即可:
select col1, col2, col3
from table1
union all
select col2, col1, null
from table2;
使用 SELECT INTO 和 UNION ALL 可以解决您的问题
SELECT * INTO TEMP TABLE RESULT FROM TABLE1
UNION ALL
SELECT * FROM TABLE2
我在 Vertica SQL 中有 2 个 table,我如何联合所有这些 table 以创建 table 作为结果?如您所见,tables 1 和 table 2 具有不同的列顺序:
enter image description here
只需按您希望的顺序列出列即可:
select col1, col2, col3
from table1
union all
select col2, col1, null
from table2;
使用 SELECT INTO 和 UNION ALL 可以解决您的问题
SELECT * INTO TEMP TABLE RESULT FROM TABLE1
UNION ALL
SELECT * FROM TABLE2