?
Solved

Conditional data-transfer of a large table from one machine to another using Oracle

Posted on 2008-10-25
5
Medium Priority
?
454 Views
Last Modified: 2013-12-18
A large table with over two million records has to be conditionally transferred from one Oracle user to another Oracle user in different machines.  We have to filter only the records created after a specified date, with another field beginning with a particular string, and with another field greater than a particular number.  The specified date, string and number are parameters, so can vary, and are not yet known.  It's a one-shot transfer, so this technique will be applied only one time.

Please describe your solution in two cases:

a) You can create a DBLink;
b) You aren't allowed to create a DBLink.
0
Comment
Question by:hc2342uhxx3vw36x96hq
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 1

Author Comment

by:hc2342uhxx3vw36x96hq
ID: 22807241
UP
0
 
LVL 10

Expert Comment

by:dbmullen
ID: 22810134
assuming the table doesn't have a LOB, fastest way to move the data is to just insert it over a link.

what is the SIZE of the table?
select bytes from dba_segments where owner = 'xxx' and segment_name = 'yyyyy';

now..  some are going to tell you to use export/import or data pump or pl/sql procedure with cursor or "oracle copy"
all of those will work fine..  but, for 2 million rows one time..  just insert the rows over the link.

with db_link
connect to target database
CREATE DATABASE LINK source_link CONNECT TO source_user IDENTIFIED BY 'pass'  USING 'SOURCE'; 
insert into target_table select * from source_table@source_link where......
;
commit;
 
without db_link
assume username/password are same on target/source
connect to target database
insert into owner.target_table select * from owner.source_table@source where......
;
commit;

Open in new window

0
 
LVL 1

Author Comment

by:hc2342uhxx3vw36x96hq
ID: 22815500
The size is the following: 190000000

(I've approximated the value, of course).

The table contains about 2 million records: with the where condition, they will become 1,75 million records.

With a simple insert statement you cannot do it.  With a cursor is it possible?

declare cursor cxxx is select * from source_table@source_link where date_field >= to_date (.....)

Is theren't a fastest way to copy?
0
 
LVL 10

Accepted Solution

by:
dbmullen earned 2000 total points
ID: 22815577
190mb is pretty small...
With a simple insert statement you cannot do it.  
why not?  is there a CLOB/LOB/BLOG or something
the fastest way to move the data is to just INSERT it over a link..  try the "oracle copy command"  only thing about COPY, you have to put the select on ONE line so use the "_" if want to make it look pretty.
 

connect username/password@target_db
set arraysize 100
set copycommit 50
set long 4000
truncate table target_table;
COPY FROM username/password@source_db _
       TO username/password@target_db _
       insert target_table _
       USING  _
       SELECT * _
       FROM source_table _
       where.... _
       ;

Open in new window

0
 
LVL 1

Author Closing Comment

by:hc2342uhxx3vw36x96hq
ID: 31509915
OK, thanks!
0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
This video shows how to recover a database from a user managed backup
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question