LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Creating link between two database (https://www.linuxquestions.org/questions/linux-newbie-8/creating-link-between-two-database-874803/)

smritisingh03 04-13-2011 11:04 AM

Creating link between two database
 
Hi

I need to copy tables from abc5/abc5@pqrXYZ1 to
jk8/jk8@pqrXYZ1.

For this I am trying to create a link between the 2 databases but not wkng.I am pasting here what I ve tried.Please let me know why isnt this wkng.


sqlplus jk8/jk8@pqrXYZ1

CREATE DATABASE LINK DB1.WORLD CONNECT TO abc5 IDENTIFIED BY abc5 USING 'DB1.WORLD';


please help!!!

jcalzare 04-13-2011 11:22 AM

Why don't you just use mysqldump if you just want to copy the tables?

mysqldump abc5 > abc5.sql
mysql jk8 < abc5.sql

You can just get certain tables if you don't want them all, just look at the documentation for mysqldump.

smritisingh03 04-13-2011 12:38 PM

but i need to first link the two databases and then do a COPY.

is mysqldump possible in oracle?

jcalzare 04-13-2011 02:33 PM

Oh, I didn't realize this was for Oracle. I'm afraid I'll be of no help then.

smritisingh03 04-13-2011 04:07 PM

i found the solution ans itz working.I ve posted the full script for others like me!!!



#!/bin/ksh



#echo "Please enter the userID: \c"

#read $1 #stores the uid

#echo "Please enter the password: \c"

#read $2 #stores the pwd

#echo "Please enter the database instance: \c"

#read $3 # stores the instance


#sqlplus -s $1/$2@$3 #connecting to the environment where the tables need to be copied

#set heading off feedback off pagesize 0 linesize 30000 trimout on;
#whenever sqlerror exit 1;
#whenever oserror exit 1;



sqlplus 1/2@3 <<EOF #id and pwd and istance of DB where u need to copy


create database link smriti connect to id IDENTIFIED BY pwd using 'instance'; #id and pwd and instance of DB1 from which u need to pick the tables



CREATE TABLE new_a AS SELECT * FROM DB1instance.a@smriti;
CREATE TABLE new_b AS SELECT * FROM DB1instance.b@smriti;
CREATE TABLE new_c AS SELECT * FROM DB1instance.c@smriti;



EOF


All times are GMT -5. The time now is 04:07 PM.