Copiar tabla de 1 BD a otra
Buenos dias!!
Tengo 2 BD oracle y quiero copiar tablas de 1 a otra. Antes lo hacia con el navigator de Oracle 8 para Win 98, pero me ha dejado de funcionar.
Lo q me interesa principalmente es q se copie la estructura, aunq si se copian los datos mejor q mejor.
Alguien puede echarme 1 cable? Estoy bastante deseserada :(
Tengo 2 BD oracle y quiero copiar tablas de 1 a otra. Antes lo hacia con el navigator de Oracle 8 para Win 98, pero me ha dejado de funcionar.
Lo q me interesa principalmente es q se copie la estructura, aunq si se copian los datos mejor q mejor.
Alguien puede echarme 1 cable? Estoy bastante deseserada :(
Como dice Mio, crea un dblink
create database link NOMBRE_DEL_LINK
connect to BBDD_DONDE_ESTA_LA_TABLA_QUE_QUIERES_COPIAR
identified by PASSWORD_DE_LA_BBDD_DONDE_ESTA_LA_TABLA_QUE_QUIERES_COPIAR
using USUARIO_DE_LA_BBDD_DONDE_ESTA_LA_TABLA_QUE_QUIERES_COPIAR
;
Despues desde la bbdd en donde quieres copiar la tabla un
CREATE TABLE NOMBRE_QUE_QUIERES_PARA_LA_TABLA
AS
SELECT * FROM NB_TABLA_QUE_QUIERES_COPIAR@NB_DEL_DBLINK;
create database link NOMBRE_DEL_LINK
connect to BBDD_DONDE_ESTA_LA_TABLA_QUE_QUIERES_COPIAR
identified by PASSWORD_DE_LA_BBDD_DONDE_ESTA_LA_TABLA_QUE_QUIERES_COPIAR
using USUARIO_DE_LA_BBDD_DONDE_ESTA_LA_TABLA_QUE_QUIERES_COPIAR
;
Despues desde la bbdd en donde quieres copiar la tabla un
CREATE TABLE NOMBRE_QUE_QUIERES_PARA_LA_TABLA
AS
SELECT * FROM NB_TABLA_QUE_QUIERES_COPIAR@NB_DEL_DBLINK;
Acabo de descubrir 茅ste en un libro llamado <<SQL*Plus User's Guide>>
SQL> copy from /@buscopy -
> to /@ddba -
> create andrew (today) -
> using select * from andrew
Array fetch/bind size is 15. (arraysize is 15)
Will commit when done. (copycommit is 0)
Maximum long size is 80. (long is 80)
Table ANDREW created.
1 rows selected from @buscopy.
1 rows inserted into ANDREW.
1 rows committed into ANDREW at @ddba.
SQL> conn /@ddba
Connected.
SQL> desc andrew
Name Null? Type
----------------------------------------- -------- ----------------------------
TODAY DATE
SQL>
Pero seg煤n Oracle, es mejor emplear el exp y imp o el database link.
SQL> copy from /@buscopy -
> to /@ddba -
> create andrew (today) -
> using select * from andrew
Array fetch/bind size is 15. (arraysize is 15)
Will commit when done. (copycommit is 0)
Maximum long size is 80. (long is 80)
Table ANDREW created.
1 rows selected from @buscopy.
1 rows inserted into ANDREW.
1 rows committed into ANDREW at @ddba.
SQL> conn /@ddba
Connected.
SQL> desc andrew
Name Null? Type
----------------------------------------- -------- ----------------------------
TODAY DATE
SQL>
Pero seg煤n Oracle, es mejor emplear el exp y imp o el database link.
Utiliza el comando EXP para exportar los objetos que necesitas, y luego en la otra base de datos utiliza el comando IMP para importarlos.
Dependiendo de la versi贸n que tengas el nombre del ejecutable varia.
Busca dentro de la carpeta donde esta la instalaci贸n del ORACLE una carpeta con el nombre de BIN, ah铆 adentro busca cualquier ejecutable uno con el nombre de IMP... y el otro EXP...
Creo recordar que en la versi贸n de oracle 8 los nombres de estos ejecutables tenian algun numero al final algo asi como EXP08.exe
Busca dentro de la carpeta donde esta la instalaci贸n del ORACLE una carpeta con el nombre de BIN, ah铆 adentro busca cualquier ejecutable uno con el nombre de IMP... y el otro EXP...
Creo recordar que en la versi贸n de oracle 8 los nombres de estos ejecutables tenian algun numero al final algo asi como EXP08.exe
Rodolfo tiene raz贸n pero si est谩s empleando UNIX el comando es exp, no EXP.
Aqu铆 est谩 un ejemplo:
Para empezar hay que crear una tabla en la primera base de datos:
BUSCOPY /usr/users/andrewr/misc > sqlplus /
SQL*Plus: Release 8.1.7.0.0 - Production on Tue Dec 6 17:17:04 2005
(c) Copyright 2000 Oracle Corporation. All rights reserved.
Connected to:
Oracle8i Enterprise Edition Release 8.1.7.4.0 - Production
JServer Release 8.1.7.4.0 - Production
SQL> create table andrew as select sysdate today from dual;
Table created.
SQL> exit
Disconnected from Oracle8i Enterprise Edition Release 8.1.7.4.0 - Production
JServer Release 8.1.7.4.0 - Production
BUSCOPY /usr/users/andrewr/misc >
Luego hay que utilizar exp:
BUSCOPY /usr/users/andrewr/misc > exp userid=/ tables=andrew file=andrew.dmp log=andrew.log
Export: Release 8.1.7.4.0 - Production on Tue Dec 6 17:19:19 2005
(c) Copyright 2000 Oracle Corporation. All rights reserved.
Connected to: Oracle8i Enterprise Edition Release 8.1.7.4.0 - Production
JServer Release 8.1.7.4.0 - Production
Export done in US7ASCII character set and WE8ISO8859P1 NCHAR character set
server uses WE8ISO8859P1 character set (possible charset conversion)
About to export specified tables via Conventional Path ...
. . exporting table ANDREW 1 rows exported
Export terminated successfully without warnings.
BUSCOPY /usr/users/andrewr/misc >
Por fin se puede servirse de imp para poner la tabla en una otra base de datos:
BUSCOPY /usr/users/andrewr/misc > . oraenv
ORACLE_SID = [BUSCOPY] ? DDBA
ksh: unlimited: bad number
DDBA /usr/users/andrewr/misc > imp userid=/ fromuser=oracle touser=oracle file=andrew.dmp log=andrew.log1
Import: Release 9.2.0.5.0 - Production on Tue Dec 6 17:23:13 2005
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
Connected to: Oracle9i Enterprise Edition Release 9.2.0.5.0 - Production
With the Partitioning option
JServer Release 9.2.0.5.0 - Production
Export file created by EXPORT:V08.01.07 via conventional path
import done in US7ASCII character set and AL16UTF16 NCHAR character set
import server uses WE8ISO8859P1 character set (possible charset conversion)
export server uses WE8ISO8859P1 NCHAR character set (possible ncharset conversion)
. . importing table "ANDREW" 1 rows imported
Import terminated successfully without warnings.
DDBA /usr/users/andrewr/misc >
Buena suerte.
Andrew
Aqu铆 est谩 un ejemplo:
Para empezar hay que crear una tabla en la primera base de datos:
BUSCOPY /usr/users/andrewr/misc > sqlplus /
SQL*Plus: Release 8.1.7.0.0 - Production on Tue Dec 6 17:17:04 2005
(c) Copyright 2000 Oracle Corporation. All rights reserved.
Connected to:
Oracle8i Enterprise Edition Release 8.1.7.4.0 - Production
JServer Release 8.1.7.4.0 - Production
SQL> create table andrew as select sysdate today from dual;
Table created.
SQL> exit
Disconnected from Oracle8i Enterprise Edition Release 8.1.7.4.0 - Production
JServer Release 8.1.7.4.0 - Production
BUSCOPY /usr/users/andrewr/misc >
Luego hay que utilizar exp:
BUSCOPY /usr/users/andrewr/misc > exp userid=/ tables=andrew file=andrew.dmp log=andrew.log
Export: Release 8.1.7.4.0 - Production on Tue Dec 6 17:19:19 2005
(c) Copyright 2000 Oracle Corporation. All rights reserved.
Connected to: Oracle8i Enterprise Edition Release 8.1.7.4.0 - Production
JServer Release 8.1.7.4.0 - Production
Export done in US7ASCII character set and WE8ISO8859P1 NCHAR character set
server uses WE8ISO8859P1 character set (possible charset conversion)
About to export specified tables via Conventional Path ...
. . exporting table ANDREW 1 rows exported
Export terminated successfully without warnings.
BUSCOPY /usr/users/andrewr/misc >
Por fin se puede servirse de imp para poner la tabla en una otra base de datos:
BUSCOPY /usr/users/andrewr/misc > . oraenv
ORACLE_SID = [BUSCOPY] ? DDBA
ksh: unlimited: bad number
DDBA /usr/users/andrewr/misc > imp userid=/ fromuser=oracle touser=oracle file=andrew.dmp log=andrew.log1
Import: Release 9.2.0.5.0 - Production on Tue Dec 6 17:23:13 2005
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
Connected to: Oracle9i Enterprise Edition Release 9.2.0.5.0 - Production
With the Partitioning option
JServer Release 9.2.0.5.0 - Production
Export file created by EXPORT:V08.01.07 via conventional path
import done in US7ASCII character set and AL16UTF16 NCHAR character set
import server uses WE8ISO8859P1 character set (possible charset conversion)
export server uses WE8ISO8859P1 NCHAR character set (possible ncharset conversion)
. . importing table "ANDREW" 1 rows imported
Import terminated successfully without warnings.
DDBA /usr/users/andrewr/misc >
Buena suerte.
Andrew
