[oracle] Toad for Oracle..How to execute multiple statements?

I have some 800-1200 INSERT statements generated from an excel sheet. I want to run these in TOAD - Oracle db.

If I press F9, it runs only one line and F5 gives me syntax issue and do not seem to work? What am I missing here?

This question is related to oracle toad

The answer is


Highlight everything you want to run and run as a script. You can do that by clicking the icon on the menu bar that looks like a text file with a lightning bolt on it. That is the same as hitting F5. So if F5 doesn't work you probably have an error in your script.

Do you have semicolons after each statement?


Open multiple instances of Toad and execute.


You can either go for f5 it will execute all the scrips on the tab.

Or

You can create a sql file and put all the insert statements in it and than give the file path in sql plus and execute.


If you have Multiple Insert Statements then Toad has a simple Way to execute all the Insert Statements.

Right Click On the Highlighted Insert Statements --> Select Execute Menu --> Execute Script

This will automatically start running the Insert Statements


I prefer the Execute via SQL*Plus option. It's in the little down-arrow menu under the "Execute as script" toolbar button.


Wrap the multiple statements in a BEGIN END block to make them one statement and add a slash after the END; clause.

BEGIN
  insert into books
  (id, title, author)
  values
  (books_seq.nextval, 'The Bite in the Apple', 'Chrisann Brennan');

  insert into books
  (id, title, author)
  values
  (books_seq.nextval, 'The Restaurant at the End of the Universe', 'Douglas Adams');
END;
/

That way, it is just ctrl-a then ctrl-enter and it goes.


begin

insert into fiscal_year values(2001,'01-jan-2001','31-dec-2001');
insert into fiscal_year values(2002,'01-jan-2002','31-dec-2002');
insert into fiscal_year values(2003,'01-jan-2003','31-dec-2003');
insert into fiscal_year values(2004,'01-jan-2004','31-dec-2004');

end;

Use like this and then commit.


  1. Just finsih all of your queries with ;
  2. Select all queries you need (inserts, selects, ...).
  3. Push or F5 or F9 both Works.

Not necessary to execute as script