Q
Manage Learn to apply best practices and optimize your operations.

How to use the UNION operator in Oracle to join two similar tables

Want to use the UNION operator in Oracle? Learn how to do so to join two different tables with the same number of columns and column names.

Is it possible to join two different tables with the same number of columns and column names with the UNION operator?
It sure is possible, as seen in the following example:

SELECT col1, col2, col3 FROM table1
UNION 
SELECT col1, col2, col3 FROM table2;

You can even use the UNION operator on two tables that have different numbers of columns, so long as you fill in the missing columns with NULL values as can be seen below:

SELECT col1, NULL as col2, col3 FROM table1
UNION
SELECT col1, col2, NULL as col3 FROM table2;

Dig Deeper on Oracle database design and architecture

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchDataManagement

SearchBusinessAnalytics

SearchSAP

SearchSQLServer

TheServerSide.com

SearchDataCenter

SearchContentManagement

SearchHRSoftware

Close