在 Oracle SQL Developer 上同时运行 2 个查询?

发布于 2024-09-09 10:49:54 字数 124 浏览 5 评论 0原文

我需要从 Oracle DB 检索大量数据,为此我需要运行 20 多个查询。有没有办法在同一连接上一次运行多个查询?

我尝试使用 / 来分隔查询,但这只是打开多个选项卡,并且查询仍然按顺序运行,尽管我不必一一启动它们。

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?

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

枫以 2024-09-16 10:49:54

ctrl+shift+N 将打开一个新的非共享工作表,该工作表可以并行运行查询。在这种情况下,您必须在每个选项卡中粘贴查询并手动运行它们,但在仅测试几个查询时它很方便。

Pressing ctrl+shift+N will 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.

π浅易 2024-09-16 10:49:54

在 SqlDeveloper 首选项中: Tools >首选项>数据库>工作表选中新建工作表以使用非共享连接选项。这将允许您同时执行多个查询,每个查询都在每个选项卡中。另请参阅屏幕截图

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 screenshot too.

残龙傲雪 2024-09-16 10:49:54

不,每个查询都需要一个单独的会话。

No, you will need a separate session per query.

在你怀里撒娇 2024-09-16 10:49:54

假设您喜欢危险的生活,您可以使用编译指示 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;

Assuming you like to live dangerously, you can run multiple "threads" from one script using the pragma AUTONOMOUS_TRANSACTION. For example:

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;
疯了 2024-09-16 10:49:54

@Tony是正确的,每个查询必须在自己的会话中运行才能并行运行。您使用什么工具?在 PL/SQL Developer 中,我可以打开一个数据库连接,然后在该连接中打开多个会话并“并行”运行多个查询 - 我确实必须手动执行每个查询,但如果它们每个都需要很长时间,也许这会为您提供所需的东西,或在您使用的任何工具中提供类似的东西。

@Tony is correct, each query must run in its 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.

沫离伤花 2024-09-16 10:49:54

因此,最简单的解决方案是使用其余 Oracle 软件附带的 SQL Plus。这是一个笨重的工具,但可以满足我的需要,同时我可以自由地使用 SQL Developer 进行其他查询。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文