Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Q: emulating SQLPLUS COPY

Q: emulating SQLPLUS COPY

From: Malcolm Dew-Jones <yf110_at_vtn1.victoria.tc.ca>
Date: 5 Apr 2002 16:51:33 -0800
Message-ID: <3cae4695@news.victoria.tc.ca>


Hello...

I can use SQL PLus COPY command to copy a large table (with no constraints or indexes) and it takes about 35 minutes.

I want to do the same thing via PL/SQL, but it takes much longer (ten hours).

My PL/SQL code has the following very simple outline. Initially the local table is empty, and has no constraints or indexes.

        cursor C is select * from remote_table

        one_row local_table%rowtype; -- both tables have same layout

	open C
	loop
		fetch C into one_row
		exit when end of data

		insert into local_table values
		( one_row.col1 ,
		  one_row.col2 ,
		  ... ,
		  one_row.col67 
		);

	end loop
	close C

As you can see it's very simple. It just loops over the remote table rows, and for each row it does an insert into the local table.

However, as I said, this is *much* slower than the COPY command. What is the trick to speed this up?

I need to use a procedure (not the COPY command) because eventually I need to do some additional processing of each row.

Suggestions welcome, thanks. Received on Fri Apr 05 2002 - 18:51:33 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US