问题
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?
回答1:
F9 executes only one statement. By default Toad will try to execute the statement wherever your cursor is or treat all the highlighted text as a statement and try to execute that. A ;
is not necessary in this case.
F5 is "Execute as Script" which means that Toad will take either the complete highlighted text (or everything in your editor if nothing is highlighted) containing more than one statement and execute it like it was a script in SQL*Plus. So, in this case every statement must be followed by a ;
and sometimes (in PL/SQL cases) ended with a /
.
回答2:
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.
回答3:
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?
回答4:
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.
回答5:
I prefer the Execute via SQL*Plus option. It's in the little down-arrow menu under the "Execute as script" toolbar button.
回答6:
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.
回答7:
Open multiple instances of Toad and execute.
回答8:
- Just finsih all of your queries with ;
- Select all queries you need (inserts, selects, ...).
- Push or F5 or F9 both Works.
Not necessary to execute as script
来源:https://stackoverflow.com/questions/9170792/toad-for-oracle-how-to-execute-multiple-statements