5
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Oracle UNDO表領域を一時的に作業用切替えた時のメモ

Last updated at Posted at 2015-04-06

内容

大量データ投入作業によるUNDO表領域の肥大化が懸念されたため、一時的に作業用UNDO表領域を作成し切替えた時の作業メモ

手順

  1. 現在の状況確認

    SQL> SELECT TABLESPACE_NAME, FILE_NAME,BYTES/1024/1024 MBYTES 
    FROM DBA_DATA_FILES 
    WHERE TABLESPACE_NAME IN (
    SELECT TABLESPACE_NAME FROM DBA_TABLESPACES WHERE CONTENTS='UNDO');
    
    TABLESPACE_NAME FILE_NAME                                              MBYTES
    --------------- -------------------------------------------------- ----------
    UNDOTBS1        /u01/app/oracle/oradata/TEST01/undotbs01.dbf               100
    
    
  2. 作業用UNDO表領域(UNDOTBS_TEMP サイズ1G)を作成

    SQL> CREATE UNDO TABLESPACE UNDOTBS_TEMP DATAFILE '/u01/app/oracle/oradata/TEST01/undotbs_temp.dbf' SIZE 1G AUTOEXTEND ON;
    
    表領域が作成されました。
    
    SQL> SELECT TABLESPACE_NAME, FILE_NAME,BYTES/1024/1024 MBYTES
    FROM DBA_DATA_FILES
    WHERE TABLESPACE_NAME IN (
    SELECT TABLESPACE_NAME FROM DBA_TABLESPACES WHERE CONTENTS='UNDO');
    
    TABLESPACE_NAME FILE_NAME                                              MBYTES
    --------------- -------------------------------------------------- ----------
    UNDOTBS1        /u01/app/oracle/oradata/TEST01/undotbs01.dbf               100
    UNDOTBS_TEMP    /u01/app/oracle/oradata/TEST01/undotbs_temp.dbf           1024
    
    
  3. UNDO表領域を作業用に切替

    SQL> SELECT NAME,VALUE FROM V$PARAMETER WHERE NAME='undo_tablespace';
    
    NAME                 VALUE
    -------------------- --------------------
    undo_tablespace      UNDOTBS1
    
    SQL> ALTER SYSTEM SET UNDO_TABLESPACE='UNDOTBS_TEMP';
    
    システムが変更されました。
    
    SQL> SELECT NAME,VALUE FROM V$PARAMETER WHERE NAME='undo_tablespace';
    
    NAME                 VALUE
    -------------------- --------------------
    undo_tablespace      UNDOTBS_TEMP
    
    SQL> ALTER TABLESPACE UNDOTBS1 OFFLINE;
    
    表領域が変更されました。
    
    SQL> SELECT TABLESPACE_NAME,STATUS FROM DBA_TABLESPACES WHERE CONTENTS='UNDO';
    
    TABLESPACE_NAME STATUS
    --------------- ---------------------------
    UNDOTBS1        OFFLINE
    UNDOTBS_TEMP    ONLINE
    
    
  4. 大量データの投入作業

  5. UNDO表領域を元に戻す

    SQL> ALTER TABLESPACE UNDOTBS1 ONLINE;
    
    システムが変更されました。
    
    SQL> ALTER SYSTEM SET UNDO_TABLESPACE='UNDOTBS1';
    
    システムが変更されました。
    
    SQL> ALTER TABLESPACE UNDOTBS_TEMP OFFLINE;
    
    表領域が変更されました。
    
    SQL> SELECT TABLESPACE_NAME,STATUS FROM DBA_TABLESPACES WHERE CONTENTS='UNDO';
    
    TABLESPACE_NAME STATUS
    --------------- ---------------------------
    UNDOTBS1        ONLINE
    UNDOTBS_TEMP    OFFLINE
    
    
  6. 作業用UNDO表領域の削除

    SQL> DROP TABLESPACE UNDOTBS_TEMP INCLUDING CONTENTS AND DATAFILES ;
    
    表領域が削除されました。
    
    SQL> SELECT TABLESPACE_NAME, FILE_NAME,BYTES/1024/1024 MBYTES 
    FROM DBA_DATA_FILES 
    WHERE TABLESPACE_NAME IN (
    SELECT TABLESPACE_NAME FROM DBA_TABLESPACES WHERE CONTENTS='UNDO');
    
    TABLESPACE_NAME FILE_NAME                                              MBYTES
    --------------- -------------------------------------------------- ----------
    UNDOTBS1        /u01/app/oracle/oradata/TEST01/undotbs01.dbf               100
    
5
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?