Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Copying table in pl/sql 1000 rows at once.

624226Jul 20 2010 — edited Jul 23 2010
Hi everybody,

I have an PL/SQL procedure that does the following.

execute immediate 'create table ' || p_descination_table || ' as select * from ' || p_source_table || '; '

And this copies a table from one schema to another (the procedure is in a user that has create table anywhere privilege).

The problem is if the table is very big I want to copy 1000 rows at a time and do a commit between batches.

So I can do
execute immediate 'create table ' || p_descination_table || ' as select * from ' || p_source_table || ' where 1=0; '

To create the structure but how do I copy the rows 1000 at a time.

Lastly does anyone have code that generates the create index commands so I can also create the indexes on the target table.

Ben
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 20 2010
Added on Jul 20 2010
57 comments
7,070 views