Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I create a table as a select from another database in Oracle?

Tags:

sql

oracle

Is it possible to create a table (in my dev db) using a SELECT from a different database?

I want something like:

create tmp_table as select * from prod_db.prod_schema.table

Is there syntax to do this, or do I need to create a database link first?

like image 696
chris Avatar asked Jul 30 '09 16:07

chris


2 Answers

You have to create a datalink first.

Oracle cannot query other databases unless a DB link is created. If a DB link exists, as you remarked, you have to do :

create tmp_table as select * from prod_schema.table@prod_db
like image 175
Steve Schnepp Avatar answered Sep 27 '22 20:09

Steve Schnepp


@Steve is correct that there has to be a DB Link, but the syntax is:

create tmp_table as select * from table@dblink
like image 27
chris Avatar answered Sep 27 '22 19:09

chris