where tablespace_name='UNDOTBS1'
/
FILE_NAME
-------------------------------------------------- --------------- --------- ---
/oracle/qgzx/u01/oradata/qgzx_undotbs01.dbf
/oracle/qgzx/u01/oradata/qgzx_undotbs02.dbf
[oracle@yz2]$df -h /oracle/qgzx/u01/oradata/
Filesystem
/dev/sda1
SQL> CREATE SMALLFILE UNDO TABLESPACE "UNDOTBS2" DATAFILE '/oracle/qgzx/u01/oradata/qgzx_undotbs02a.dbf' SIZE 5G AUTOEXTEND ON RETENTION NOGUARANTEE;
Tablespace created.
查看是否创建完成
select FILE_NAME,TABLESPACE_NAME,STATUS,AUTOEXTENSIBLE from dba_data_files
where tablespace_name like 'UNDOTBS%'
/
FILE_NAME
--------------------------------------------- ------------------------------ --------- ---
/oracle/qgzx/u01/oradata/qgzx_undotbs01.dbf
/oracle/qgzx/u01/oradata/qgzx_undotbs02.dbf
/oracle/qgzx/u01/oradata/qgzx_undotbs02a.dbf
2.查看现在正在使用的undo表空间
SQL> show parameter undo;
NAME
------------------------------------ ----------- ------------------------------
undo_management
undo_retention
undo_tablespace
3.切换UNDO表空间为undotbs2
SQL> alter system set undo_tablespace=undotbs2;
System altered.
SQL> show parameter undo;
NAME
------------------------------------ ----------- ------------------------------
undo_management
undo_retention
undo_tablespace
4.关闭自动增长(因为undotbs1的自动增长没有关闭,所以暂时打算与保持undotbs1一样,不关闭)
alter database datafile '/oracle/qgzx/u01/oradata/qgzx_undotbs01.dbf' autoextend off;
5.重启后检查
发现parameter 的undo_tablespace还是undotbs1,使用如下命令,确定spfile也被修改。报错
alter system set undo_tablespace=undotbs2 scope=both
*
ERROR at line 1:
ORA-32001: write to SPFILE requested but no SPFILE specified at startup
SQL> show parameter spfile;
NAME
------------------------------------ ----------- ------------------------------
spfile
SQL> create spfile from pfile;
File created.
之后重启数据库,让数据库以spfile启动。
SQL> alter system checkpoint;
System altered.
SQL> startup force;
ORACLE instance started.
Total System Global Area 6442450944 bytes
Fixed Size
Variable Size
Database Buffers
Redo Buffers
Database mounted.
Database opened.
SQL> show parameter spfile;
NAME
------------------------------------ ----------- ------------------------------
spfile
SQL> alter system set undo_tablespace=undotbs2;
System altered.
SQL> show parameter undo;
NAME
------------------------------------ ----------- ------------------------------
undo_management
undo_retention
undo_tablespace