<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 中删除大量数据

        Deleting a LOT of data in Oracle(在 Oracle 中删除大量数据)

          • <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 中删除大量数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  ibtmp1是非压缩的innodb临时表的独立表空间,通过innodb_temp_data_file_path参数指定文件的路径,文件名和大小,默认配置为ibtmp1:12M:autoextend,也就是说在文件系统磁盘足够的情况下,这个文件大小是可以无限增长的。 为了避免ibtmp1文件无止境的暴涨导致
                  SQL query to group by day(按天分组的 SQL 查询)
                  What does SQL clause quot;GROUP BY 1quot; mean?(SQL 子句“GROUP BY 1是什么意思?意思是?)
                  MySQL groupwise MAX() returns unexpected results(MySQL groupwise MAX() 返回意外结果)
                  MySQL SELECT most frequent by group(MySQL SELECT 按组最频繁)
                  Include missing months in Group By query(在 Group By 查询中包含缺失的月份)
                • <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>
                            <tbody id='YOdeV'></tbody>

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