简体   繁体   中英

Union tables in Vertica SQL where tables have different order of columns?

I have 2 tables in Vertica SQL and how can I union all these tables to create tables as in result? As you can see tables 1 and table 2 have different order of columns:

enter image description here

Just list the columns in the order you want them:

select col1, col2, col3
from table1
union all
select col2, col1, null
from table2;

Use SELECT INTO and UNION ALL would solve your problem

SELECT * INTO TEMP TABLE RESULT FROM TABLE1
UNION ALL 
SELECT * FROM TABLE2 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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