<bdo id='QXVan'></bdo><ul id='QXVan'></ul>

        <small id='QXVan'></small><noframes id='QXVan'>

      1. <legend id='QXVan'><style id='QXVan'><dir id='QXVan'><q id='QXVan'></q></dir></style></legend>

      2. <tfoot id='QXVan'></tfoot>
        <i id='QXVan'><tr id='QXVan'><dt id='QXVan'><q id='QXVan'><span id='QXVan'><b id='QXVan'><form id='QXVan'><ins id='QXVan'></ins><ul id='QXVan'></ul><sub id='QXVan'></sub></form><legend id='QXVan'></legend><bdo id='QXVan'><pre id='QXVan'><center id='QXVan'></center></pre></bdo></b><th id='QXVan'></th></span></q></dt></tr></i><div id='QXVan'><tfoot id='QXVan'></tfoot><dl id='QXVan'><fieldset id='QXVan'></fieldset></dl></div>

        在 Oracle 中删除大量数据

        时间:2023-11-02

          • <i id='uPGZW'><tr id='uPGZW'><dt id='uPGZW'><q id='uPGZW'><span id='uPGZW'><b id='uPGZW'><form id='uPGZW'><ins id='uPGZW'></ins><ul id='uPGZW'></ul><sub id='uPGZW'></sub></form><legend id='uPGZW'></legend><bdo id='uPGZW'><pre id='uPGZW'><center id='uPGZW'></center></pre></bdo></b><th id='uPGZW'></th></span></q></dt></tr></i><div id='uPGZW'><tfoot id='uPGZW'></tfoot><dl id='uPGZW'><fieldset id='uPGZW'></fieldset></dl></div>

              <small id='uPGZW'></small><noframes id='uPGZW'>

                • <bdo id='uPGZW'></bdo><ul id='uPGZW'></ul>
                  <legend id='uPGZW'><style id='uPGZW'><dir id='uPGZW'><q id='uPGZW'></q></dir></style></legend>
                • <tfoot id='uPGZW'></tfoot>
                    <tbody id='uPGZW'></tbody>
                • 本文介绍了在 Oracle 中删除大量数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  确切地说,我不是数据库人员,而且我的大部分数据库工作都与 MySQL 相关,所以如果这个问题中的某些内容非常幼稚,请原谅我.

                  I am not a database person, exactly, and most of my db work has been with MySQL, so forgive me if something in this question is incredibly nave.

                  我需要从大约有 1 亿行的 Oracle 表中删除 550 万行.我在临时表中拥有需要删除的行的所有 ID.如果只有几千行,我会这样做:

                  I need to delete 5.5 million rows from an Oracle table that has about 100 million rows. I have all the IDs of the rows I need to delete in a temporary table. If it were a just a few thousand rows, I'd do this:

                  DELETE FROM table_name WHERE id IN (SELECT id FROM temp_table);
                  COMMIT;
                  

                  有什么我需要注意和/或做不同的事情吗,因为它有 550 万行?我想过做一个循环,像这样:

                  Is there anything I need to be aware of, and/or do differently, because it's 5.5 million rows? I thought about doing a loop, something like this:

                  DECLARE
                    vCT NUMBER(38) := 0;
                  
                  BEGIN
                    FOR t IN (SELECT id FROM temp_table) LOOP
                      DELETE FROM table_name WHERE id = t.id;
                      vCT := vCT + 1;
                      IF MOD(vCT,200000) = 0 THEN
                        COMMIT;
                      END IF;
                    END LOOP;
                    COMMIT;
                  END;
                  

                  首先 - 这是否按照我的想法进行 - 一次批处理 200,000 次提交?假设是这样,我仍然不确定是生成550万条SQL语句,然后分批提交20万条,还是一条SQL语句一次全部提交.

                  First of all - is this doing what I think it is - batching commits of 200,000 at a time? Assuming it is, I'm still not sure if it's better to generate 5.5 million SQL statements, and commit in batches of 200,000, or to have one SQL statement and commit all at once.

                  想法?最佳做法?

                  EDIT:我运行了第一个选项,单个删除语句,在开发过程中只用了 2 个小时就完成了.基于此,它排队等待在生产中运行.

                  EDIT: I ran the first option, the single delete statement, and it only took 2 hours to complete in development. Based on that, it's queued to be run in production.

                  推荐答案

                  第一种方法更好,因为您可以让查询优化器清楚地了解您正在尝试做什么,而不是试图隐藏它.数据库引擎在内部删除 5.5m(或表的 5.5%)可能会采用与删除 200k(或 0.2%)不同的方法.

                  The first approach is better, because you give the query optimizer a clear picture of what you are trying to do, instead of trying to hide it. The database engine might take a different approach to deleting 5.5m (or 5.5% of the table) internally than to deleting 200k (or 0.2%).

                  这里还有一篇文章,关于 Oracle 中的大量 DELETE,您可能想阅读.

                  Here is also an article about massive DELETE in Oracle which you might want to read.

                  这篇关于在 Oracle 中删除大量数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:在 Oracle PL/SQL 中获取调用过程或函数的名称 下一篇:使用 utl_http &amp;12c 上的钱包:证书验证失败

                  相关文章

                • <tfoot id='YOdeV'></tfoot>
                  • <bdo id='YOdeV'></bdo><ul id='YOdeV'></ul>

                  <legend id='YOdeV'><style id='YOdeV'><dir id='YOdeV'><q id='YOdeV'></q></dir></style></legend>
                    <i id='YOdeV'><tr id='YOdeV'><dt id='YOdeV'><q id='YOdeV'><span id='YOdeV'><b id='YOdeV'><form id='YOdeV'><ins id='YOdeV'></ins><ul id='YOdeV'></ul><sub id='YOdeV'></sub></form><legend id='YOdeV'></legend><bdo id='YOdeV'><pre id='YOdeV'><center id='YOdeV'></center></pre></bdo></b><th id='YOdeV'></th></span></q></dt></tr></i><div id='YOdeV'><tfoot id='YOdeV'></tfoot><dl id='YOdeV'><fieldset id='YOdeV'></fieldset></dl></div>

                      <small id='YOdeV'></small><noframes id='YOdeV'>