Solved

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

Posted on 2008-10-25
5
452 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 500 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

How to Create User-Defined Aggregates in Oracle Before we begin creating these things, what are user-defined aggregates?  They are a feature introduced in Oracle 9i that allows a developer to create his or her own functions like "SUM", "AVG", and…
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

728 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