Reputation: 165
I have a database db1 which contains tables tbl1, tbl2, and tbl3.
I also have an empty database db2.
Can I create a MERGE table mrg1 which merges the contents of tbl1, tbl2, and tbl3 from database db1, but is stored in database db2?
Upvotes: 0
Views: 536
Reputation: 11054
Yes, if your database is set up to allow you to run queries against multiple databases at once. I think it would look something like this,
INSERT INTO db2.mrg1 (colA,colB,ColC)
(
SELECT colA,colB,ColC
FROM db1.tbl1,db1.tbl2,db1.tbl3
WHERE [whatever joins your tables together]
)
Upvotes: 1