在 Oracle SQL Developer 上同时运行 2 个查询?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3237894/
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
Run 2 queries at the same time on Oracle SQL Developer?
提问by Sologoub
I need to retrieve quite a bit of data from our oracle DB and to do so I need to run 20+ queries. Is there any way to run more than one query at a time on the same connection?
我需要从我们的 oracle 数据库中检索相当多的数据,为此我需要运行 20 多个查询。有没有办法在同一个连接上一次运行多个查询?
I tried using / to separate the queries, but that simply opens multiple tabs and queries still run sequentially, although I don't have to start them one by one.
我尝试使用 / 来分隔查询,但这只是打开多个选项卡,查询仍然按顺序运行,尽管我不必一一启动它们。
采纳答案by Sologoub
So the simplest solution to this was to use SQL Plus that came with the rest of Oracle software. It's a clunky tool, but does what I needed, while I'm free to use SQL Developer for other queries.
因此,对此最简单的解决方案是使用 Oracle 软件的其余部分附带的 SQL Plus。这是一个笨重的工具,但可以满足我的需求,同时我可以自由地使用 SQL Developer 进行其他查询。
回答by wds
Pressing ctrl+shift+Nwill open a new unshared worksheet that can run queries in parallel. In that case you have to paste a query in each tab and run them manually though, but it is handy when just testing a few queries.
按ctrl+ shift+N将打开一个新的非共享工作表,可以并行运行查询。在这种情况下,您必须在每个选项卡中粘贴一个查询并手动运行它们,但这在测试几个查询时很方便。
回答by Edayan
In SqlDeveloper preferences: Tools > Preferences > Database > Worksheet
check the option for New Worksheet to use unshared connction
. This will allow you to execute multiple queries at the same time, each in each tab. See a screenshottoo.
在 SqlDeveloper 首选项中:Tools > Preferences > Database > Worksheet
选中New Worksheet to use unshared connction
. 这将允许您同时执行多个查询,每个查询都在每个选项卡中。也看截图。
回答by Tony Andrews
No, you will need a separate session per query.
不,每个查询都需要一个单独的会话。
回答by DCookie
@Tony is correct, each query must run in it's own session to run in parallel. What tool are you using? In PL/SQL Developer, I can open a DB connection, then open multiple sessions within that connection and run several queries in "parallel" - I do have to execute each one manually, but if they each take a long time, perhaps that will get you what you need, or something similar in whatever tool it is you're using.
@Tony 是正确的,每个查询必须在它自己的会话中运行才能并行运行。你在用什么工具?在 PL/SQL Developer 中,我可以打开一个数据库连接,然后在该连接中打开多个会话并“并行”运行多个查询——我必须手动执行每个查询,但如果它们每个都需要很长时间,也许这会得到你需要的东西,或者你正在使用的任何工具中的类似东西。
回答by Taldaugion
Assuming you like to live dangerously, you can run multiple "threads" from one script using the pragma AUTONOMOUS_TRANSACTION. For example:
假设您喜欢危险的生活,您可以使用编译指示 AUTONOMOUS_TRANSACTION 从一个脚本运行多个“线程”。例如:
DECLARE
PROCEDURE foo(i IN PLS_INTEGER) AS
PRAGMA AUTONOMOUS_TRANSACTION;
BEGIN
INSERT INTO qux
SELECT * FROM bar
WHERE baz = i;
COMMIT;
EXCEPTION WHEN OTHERS THEN ROLLBACK;
END;
BEGIN
foo(1);
foo(2);
foo(3);
END;