Oracle:如何在pl sql过程中避免表空间问题

时间:2016-02-23 09:14:18

标签: oracle performance stored-procedures plsql sql-update

我正在尝试update基于条件的5个表的列。表中的行数以百万计 和表空间是一个问题。我已经考虑过以下选项,并想知道哪个选项不会包含表空间问题或 表现明智哪个更好。

p_fetch_limit = 1000;

  1. 为循环内的所有5个表放置更新脚本。这已经过测试,我正面临着这种方法的表空间问题。
  2. 打开光标以更新1个表格。只需为第一个表放置更新语句。关闭光标。打开相同的光标。只需将update语句放在第二个表中即可。关闭光标。其余表继续执行相同的步骤。
  3. 打开光标。更新第一张表。承诺。更新第二个表。承诺。继续执行表格的其余部分
  4. OPEN cur_recs;
      LOOP
        FETCH cur_recs BULK COLLECT INTO someCounter LIMIT p_fetch_limit;
        IF (someCounter.COUNT > 0) THEN
                          BEGIN
                               FOR i IN 1 .. someCounter.count
                                 LOOP                            
                                   UPDATE table1 SET column1 = someDate WHERE column2 = someCounter.idValue and column1 between someDate1 and someDate2;
                                   UPDATE table2 SET column = someDate WHERE column2 = someCounter.idValue and column1 between someDate1 and someDate2;
                                   UPDATE table3 SET column1 = someDate WHERE column2 = someCounter.idValue and column1 between someDate1 and someDate2;
                       UPDATE table4 SET column1 = someDate WHERE column2 = someCounter.idValue and column1 between someDate1 and someDate2;
                    END LOOP; 
                          END;
                    COMMIT;
        END IF;
        EXIT WHEN cur_recs%NOTFOUND;
      END LOOP;
      CLOSE cur_recs;
    

    目前,我遇到了以下表空间问题。

    Error report:
    ORA-01688: unable to extend table mySchema.table1 partition SYS_P3531 by 1024 in tablespace someTableSpace
    01688. 00000 -  "unable to extend table %s.%s partition %s by %s in tablespace %s"
    *Cause:    Failed to allocate an extent for table segment in tablespace.
    *Action:   Use ALTER TABLESPACE ADD DATAFILE statement to add one or more
               files to the tablespace indicated.
    

0 个答案:

没有答案