UNDO表空间
将的DML操作前的数据都快照到这个表空间中,以防止误操作
可以将一定之间内所执行的DML操作进行回滚
undo_retention参数 撤销段的最短保留时间,默认情况下,oracle将自动结合undo表空间和和使用情况来自动调整这个值
设置undo_retention参数的值
alter system set undo_retention = 86400;
查看undo_retention参数的值
show parameter undo_retention;
例子:
SQL> show parameter undo_retention;
NAME TYPE
------------------------------------ ---------------------------------
VALUE
------------------------------
undo_retention integer
900
SQL> alter system set undo_retention=1000;
系统已更改。
SQL> show parameter undo_retention;
NAME TYPE
------------------------------------ ---------------------------------
VALUE
------------------------------
undo_retention integer
1000
undo_retention的guarantee 特性 如果启用这个特性是强制设定undo_retention这个值,启用设置如下
alter tablespace undotp retention guarantee;
查看状态如下:
select tablespace_name,retention from dba_tablespaces where tablespace_name='UNDOTP';
启用undo_retention的guarantee 特性例子:
SQL> alter tablespace undotp retention guarantee;
表空间已更改。
SQL> select tablespace_name,retention from dba_tablespaces where tablespace_name='UNDOTP';
TABLESPACE_NAME
--------------------------------------------------------------------------------
RETENTION
---------------------------------
UNDOTP
GUARANTEE
SQL> alter tablespace undotp retention noguarantee;
表空间已更改。
SQL> select tablespace_name,retention from dba_tablespaces where tablespace_name='UNDOTP';
TABLESPACE_NAME
--------------------------------------------------------------------------------
RETENTION
---------------------------------
UNDOTP
NOGUARANTEE
创建undo表空间
create undo tablespace undo datafile '/oracle/oradata/aaa/aaa_undo.dbf' size 100m reuse autoextend on next 50m maxsize 30720m;
将undo表空间切换到新建的undo表空间
alter system set undo_tablespace=adunion_undo;
查看undo表空间
select tablespace_name from dba_tablespaces where contents='UNDO';
更改undo表空间的保留时间
alter system set undo_retention = 86400;
删除掉旧的undo表空间
drop tablespace undotbs1;