1.管理Undo表空间 --创建新的Undo表空间 CREATE UNDO TABLESPACE UNDOTBS2 datafile '/paic/g2bh8060/dev/xqd/oradata/hd02ntlf/undotbs2_01.dbf' size 500m autoextend on RETENTION NOGUARANTEE; 默认是NOGUARANTEE --为Undo表空间增加文件 alter tablespace undotbs1 add datafile '/u01/oracle/undo01.dbf' size 500m autoextend on; alter tablespace undotbs1 add datafile '+DATA_MIDG' size 500m autoextend on; 查询与更改undo表空间是否retention guarantee select tablespace_name,RETENTION from dba_tablespaces where tablespace_name like '%UNDO%'; ALTER DATABASE UNDOTBS01 RETENTION GUARANTEE|NOGUARANTEE; 更改系统默认表空间 show parameter undo_tablespace alter system set undo_tablespace=undotbs2; undo表空间删除 drop tablespace undotbs1 INCLUDING CONTENTS AND DATAFILES; undo表空间更名 alter tablespace undotbs2 rename to undotbs1; 重建undo表空间 1.因为延迟段创建的原因,可以先将参数取消; show parameter segment alter system set deferred_segment_creation=false; 2.创建undotemp表空间 3.alter system set undo_tablespace=undotemp;(如果延迟段创建特性启用了,会提示表空间不存在) 4.旧的undotbs1 drop掉。 旧的表空间现在是pending offline状态,等待offline,要等其上的事务都结束后才能真正offline。 ORA-30013: undo tablespace 'UNDOTBS1' is currently in use 5.新的rename成旧的。
2.认识UNDO undo相关参数: undo_management AUTO --9i以后我们undo_management都用auto undo_tablespace UNDOTBS2 --可以动态指定系统undo表空间 undo_retention 900 --单位秒,默认900 undo_retention是针对select操作的,比如闪回查询,我们一般希望能闪回查询3小时内的数据。 事务中的undo块都是active的,事务结束后的块是inactive的,inactive的undo块在过了undo_retention 指定的时间后,就会变成expired。 比如DB最长的查询也在5分钟内,那我undo_retention只要设成300,那么这个select会遭遇01555快照太旧的可能性就比较小,但不保证。 ALTER SYSTEM SET undo_retention=10800 SCOPE=BOTH; 我们通过 undo_management 参数来控制使用哪种方式,如果设为auto,就使用UNDO 表空间,这时必须要指定一个UNDO 表空间。 如果设为manual,系统启动后使用rollback segment方式存储undo信息。如果系统没有指定undo_management,那么系统默认以manual方式启动,即使设置了auto方式的参数,这些参数将被忽略。 假如