• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1371
  • Last Modified:

How to merge 2 Oracle tables?

How do I use the 'INSERT' or 'SELECT' SQL to copy all records from one table to another table, assuming the two tables have the same schema and I have all the privileges?
0
szetoa
Asked:
szetoa
1 Solution
 
frankrCommented:
If your second table is simply an exact copy of the first, the EASIEST way to do this is to issue a

CREATE TABLE new_table AS SELECT * FROM old_table;

You create the new table and copy all the data in one statement.

If the second table already has some data and the table structures are identical (i.e. column names in the two tables are identical in name, number, type, etc.), you can simply

INSERT INTO new_table SELECT * FROM old_table;

If the structures aren't identical, start adding explicit column lists to the new_table and the old_table.
0
 
szetoaAuthor Commented:
Thanks again.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now