tags:

views:

166

answers:

3

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?

+2  A: 

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
Steve Schnepp
A: 

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

create tmp_table as select * from table@dblink
chris
Oops... got bitten (Didn't have an Oracle DB at hand to test). Corrected my answer, thx...
Steve Schnepp
A: 

Don't forget to create your indexes. You can get this for all the tables in your schema with a query like this:

SELECT DBMS_METADATA.GET_DDL('INDEX',u.index_name)
     FROM USER_INDEXES u;
Mark Harrison
I'll leave that for the dba :)
chris
lol, if you're going to do that you can just ask your dba to EXP/IMP the schema directly, it will be much faster.
Mark Harrison