1. 首页 > ITPUX技术网 > 正文

修改(切换)当前数据库的UNDO表空间

UNDO 表空间——为了保护数据的一致性而存储数据旧的镜像的表空间
当修改数据未提交的时候,修改的进程直接修改数据块,这个数据库块的旧的镜像被转移到UNDO中存储,此时没有提交的时候为了防止其他用户修改发生错乱,这个行会被加锁,如果查询这个数据的话,发现有锁,就直接到UNDO中去查询数据的旧的镜像。

SQL> show parameter undo

NAME TYPE VALUE
———————————— ———– ——————————
undo_management string AUTO –UNDO的管理方式:AUTO
undo_retention integer 900 –undo数据在undo段中保留的最大时间为900s
undo_tablespace string UNDOTBS1 –当前数据库默认的undo表空间

UNDO段空间不足的时候需要加数据文件扩容

比如:修改了20G数据,但是此时UNDO段只有10G,旧的镜像空间是不足的,此时会发生ORA-01555的错误,此时需要扩容UNDO 表空间

修改(切换)当前数据库的UNDO表空间

1、创建一个新的UNDO 表空间

SQL> create undo tablespace undotbs2 datafile ‘/u01/oracle/oradata/ORCL/undo02.dbf’ size 2G;

Tablespace created.

2、切换

alter tablespace undotbs1 offline; –回滚没有提交的数据

SQL> alter system set undo_tablespace=undotbs2 scope=both;

System altered.

SQL> show parameter undo

NAME TYPE VALUE
———————————— ———– ——————————
undo_management string AUTO
undo_retention integer 900
undo_tablespace string UNDOTBS2

3、删除旧的

SQL> drop tablespace undotbs1 including contents and datafiles;

Tablespace dropped.

4、扩容

SQL> alter tablespace undotbs2 add datafile ‘/u01/oracle/oradata/ORCL/undotbs201.dbf’ size 500M;

Tablespace altered.

本文由风哥教程整理发布,仅用于学习测试使用,转载注明出处:http://www.fgedu.net.cn/10327.html

联系我们

在线咨询:点击这里给我发消息

微信号:itpux-com

工作日:9:30-18:30,节假日休息