[Oracle] UNDO表領域を再作成する方法

UNDO表領域の再作成手順を紹介したいと思います。

「誤ってUNDO表領域を作成した」時や、

「UNDO表領域が肥大しすぎてしまって小さくさせる」時にに利用

できますので参考にしてみてください。

目次

UNDO表領域再作成の方針

UNDO表領域の再作成は

「一時的に別のUNDO表領域を指定して、その間にDROPとCREATEを行う」

で実施します。

以下の流れで作成していきます。

  1. 一時的なUNDO表領域を作成
  2. 1.で作成したUNDO表領域を初期化パラメータ「UNDO_TABLESPACE」を指定
  3. 元のUNDO表領域をオフライン
  4. 元のUNDO表領域を削除
  5. UNDO表領域の作成
  6. 再作成したUNDO表領域を「UNDO_TABLESPACE」を指定
  7. 1.で作成したUNDO表領域を削除

UNDO表領域再作成の手順

まずは一時的なUNDO表領域を作成します。

create undo tablespace undotemp datafile '/u01/app/oracle/oradata/ORCL18C/undotemp01.dbf' size 1g;
select * from dba_data_files where tablespace_name = 'UNDOTEMP';

次に作成したUNDO表領域を初期化パラメータ

「UNDO_TABLESPACE」を指定します。

alter system set undo_tablespace = 'UNDOTEMP';
show parameters undo_tablespace

元のUNDO表領域をオフラインにします。

alter tablespace undotbs1 offline;
select status from dba_tablespaces where tablespace_name = 'UNDOTBS1';

元のUNDO表領域を削除します。

drop tablespace undotbs1 including contents and datafiles cascade constraints;
select * from dba_data_files where tablespace_name = 'UNDOTBS1';

ここで初めてUNDO表領域を再作成します。

create undo tablespace undotbs1 datafile '/u01/app/oracle/oradata/ORCL18C/undotbs101.dbf' size 10480m autoextend off;
select * from dba_data_files where tablespace_name = 'UNDOTBS1';

上で再作成したUNDO表領域を「UNDO_TABLESPACE」を指定します。

alter system set undo_tablespace = 'UNDOTBS1';
show parameters undo_tablespace

最後にで一時的に作成したUNDO表領域を削除します。

drop tablespace undotemp including contents and datafiles cascade constraints;
select * from dba_data_files where tablespace_name = 'UNDOTEMP';

以上、手順は終了です。お疲れ様です。

よかったらシェアしてね!
  • URLをコピーしました!
目次