Toad for Oracle..如何执行多条语句?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9170792/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Toad for Oracle..How to execute multiple statements?
提问by user1191463
I have some 800-1200 INSERT statements generated from an excel sheet. I want to run these in TOAD - Oracle db.
我有一些从 Excel 工作表生成的 800-1200 条 INSERT 语句。我想在 TOAD - Oracle db 中运行这些。
If I press F9, it runs only one line and F5gives me syntax issue and do not seem to work? What am I missing here?
如果我按F9,它只运行一行并出现F5语法问题并且似乎不起作用?我在这里缺少什么?
回答by John Doyle
F9executes 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.
F9只执行一条语句。默认情况下,Toad 将尝试在光标所在的任何位置执行语句,或者将所有突出显示的文本视为一条语句并尝试执行该语句。;
在这种情况下,A不是必需的。
F5is "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 /
.
F5是“作为脚本执行”,这意味着 Toad 将采用包含多个语句的完整突出显示文本(或编辑器中的所有内容,如果没有突出显示),并像 SQL*Plus 中的脚本一样执行它。因此,在这种情况下,每个语句都必须后跟 a;
并且有时(在 PL/SQL 情况下)以/
.
回答by CSQ
Wrap the multiple statements in a BEGIN END block to make them one statement and add a slash after the END; clause.
将多条语句包装在 BEGIN END 块中,使它们成为一条语句,并在 END 后添加斜杠;条款。
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.
这样,它只是 ctrl-a 然后 ctrl-enter 就可以了。
回答by nolt2232
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.
突出显示您要运行的所有内容并作为脚本运行。您可以通过单击菜单栏上看起来像带有闪电符号的文本文件的图标来执行此操作。这与按 F5 相同。因此,如果 F5 不起作用,您的脚本中可能有错误。
Do you have semicolons after each statement?
每条语句后是否有分号?
回答by user3068880
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.
像这样使用然后提交。
回答by Jeffrey Kemp
I prefer the Execute via SQL*Plusoption. It's in the little down-arrow menu under the "Execute as script" toolbar button.
我更喜欢Execute via SQL*Plus选项。它位于“作为脚本执行”工具栏按钮下的小向下箭头菜单中。
回答by skj
Open multiple instances of Toad and execute.
打开多个 Toad 实例并执行。
回答by Harshit
You can either go for f5 it will execute all the scrips on the tab.
您可以选择 f5 它将执行选项卡上的所有脚本。
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.
您可以创建一个sql文件并将所有插入语句放入其中,然后在sql plus中给出文件路径并执行。
回答by Dave
- Just finsih all of your queries with ;
- Select all queries you need (inserts, selects, ...).
- Push or F5 or F9 both Works.
- 只需完成您所有的查询;
- 选择您需要的所有查询(插入、选择、...)。
- 按或 F5 或 F9 都有效。
Not necessaryto execute as script
不需要作为脚本执行