Skip to Main Content
  • Questions
  • How to insert multiple insert stmt to a table

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question, Dinesh.

Asked: March 07, 2017 - 4:43 pm UTC

Last updated: March 09, 2017 - 1:51 am UTC

Version: 11.2

Viewed 1000+ times

You Asked

Hi Team,
I've a script where i have 100K insert into stmts , i need to execute these inserts,
Please suggest me a faster way to insert

Insert
insert
insert
insert ......soo on 100k records

Thanks Dnesh.

and Connor said...

Typically these things run slowly because

a) each statement contains literals
b) the tool you are using wants to give feedback

So try this in SQL Plus

set feedback off
alter session set cursor_sharing = force;
@my_script_with_inserts.sql
commit;
alter session set cursor_sharing = exact;
set feedback on

and see how you go. If its still slow, let us know and we'll suggest other ways

Rating

  (1 rating)

Is this answer out of date? If it is, please let us know via a Comment

Comments

Dinesh Kumar, March 08, 2017 - 6:28 am UTC

Hi Connor,
Thanks for the resolution but i have to use any of the tool like SQL Developer or PL/SQL Developer.
Please suggest me a resolution which will work in any of the above tool.

RDB.
Connor McDonald
March 09, 2017 - 1:51 am UTC

The example I gave will work fine with SQL Developer

If you are sending this across a network, then less trips will also help, so you could batch up statements into blocks, eg

insert into t values (...);
insert into t values (...);
insert into t values (...);
insert into t values (...);
insert into t values (...);
insert into t values (...);
insert into t values (...);
insert into t values (...);
insert into t values (...);

becomes

begin
insert into t values (...);
insert into t values (...);
insert into t values (...);
insert into t values (...);
end;
/

begin
insert into t values (...);
insert into t values (...);
insert into t values (...);
insert into t values (...);
end;
/


Just dont make them too large