数据库:oracle 19.3
系统:windows 11
测试目标:此前介绍过非关键数据文件的位置修改,现在来介绍数据库关键数据文件位置的修改.
处理SYSAUX表空间:
SQL> select file_name,bytes/1024/1024,autoextensible,tablespace_name from dba_data_files where tablespace_name='SYSAUX'
FILE_NAME BYTES/1024/1024 AUTOEX TABLESPACE_NAME
------------------------------------------------------------ --------------- ------ ------------------------------------------------------------
F:\APP\ADMINISTRATOR\ORADATA\ORCL\SYSAUX01.DBF 1740 YES SYSAUX
SQL> alter tablespace sysaux offline;
表空间已更改。
说明:此时在系统层面将F:\APP\ADMINISTRATOR\ORADATA\ORCL\SYSAUX01.DBF复制到F:\APP\ADMINISTRATOR\ORADATA\ORCL\TEST\SYSAUX01.DBF
SQL> alter tablespace sysaux rename datafile 'F:\APP\ADMINISTRATOR\ORADATA\ORCL\SYSAUX01.DBF' to 'F:\APP\ADMINISTRATOR\ORADATA\ORCL\TEST\SYSAUX01.DBF';
表空间已更改。
SQL> alter tablespace sysaux online;
表空间已更改。
SQL> select file_name,autoextensible,bytes/1024/1024,tablespace_name from dba_data_files where tablespace_name='SYSAUX';
FILE_NAME AUTOEX BYTES/1024/1024 TABLESPACE_NAME
------------------------------------------------------------ ------ --------------- ------------------------------------------------------------
F:\APP\ADMINISTRATOR\ORADATA\ORCL\TEST\SYSAUX01.DBF YES 1740 SYSAUX
处理SYSTEM表空间:
SQL> alter tablespace system offline;
alter tablespace system offline
*
第 1 行出现错误:
ORA-01541: 系统表空间无法脱机; 如有必要请关闭
SQL> alter database datafile 'E:\DMP\SYSTEM02.DBF' offline;
alter database datafile 'E:\DMP\SYSTEM02.DBF' offline
*
第 1 行出现错误:
ORA-01541: 系统表空间无法脱机; 如有必要请关闭
说明:关键数据文件无法离线
SQL> select name from v$datafile
NAME
------------------------------------------------------------
F:\APP\ADMINISTRATOR\ORADATA\ORCL\SYSTEM01.DBF
F:\APP\ADMINISTRATOR\ORADATA\ORCL\TEST02.DBF
F:\APP\ADMINISTRATOR\ORADATA\ORCL\TEST\SYSAUX01.DBF
F:\APP\ADMINISTRATOR\ORADATA\ORCL\UNDOTBS01.DBF
F:\APP\ADMINISTRATOR\ORADATA\ORCL\TEST01.DBF
F:\APP\ADMINISTRATOR\ORADATA\ORCL\USERS01.DBF
F:\APP\ADMINISTRATOR\ORADATA\ORCL\USERS02.DBF
F:\APP\ADMINISTRATOR\ORADATA\ORCL\USERS03.DBF
F:\APP\ADMINISTRATOR\ORADATA\ORCL\USERS04.DBF
F:\APP\ADMINISTRATOR\ORADATA\ORCL\USERS05.DBF
F:\APP\ADMINISTRATOR\ORADATA\ORCL\USERS06.DBF
F:\APP\ADMINISTRATOR\ORADATA\ORCL\USERS07.DBF
F:\APP\ADMINISTRATOR\ORADATA\ORCL\RMAN_TS01.DBF
E:\DMP\SYSTEM02.DBF
F:\APP\ADMINISTRATOR\ORADATA\ORCL\TEST03.DBF
F:\APP\ADMINISTRATOR\ORADATA\ORCL\TEST04.DBF
F:\APP\ADMINISTRATOR\ORADATA\ORCL\TEST05.DBF
F:\APP\ADMINISTRATOR\ORADATA\ORCL\USERS10.DBF
已选择 18 行。
SQL> select tablespace_name,status from dba_tablespaces;
TABLESPACE_NAME STATUS
------------------------------------------------------------ ------------------
SYSTEM ONLINE
SYSAUX ONLINE
UNDOTBS1 ONLINE
TEMP ONLINE
USERS ONLINE
TEST ONLINE
TSP_ORDADM ONLINE
TSP_ORDADM1 ONLINE
RMAN_TS ONLINE
LOCAL_TEMP ONLINE
已选择 10 行。
SQL> shutdown immediate;
数据库已经关闭。
已经卸载数据库。
ORACLE 例程已经关闭。
SQL> startup mount;
ORACLE 例程已经启动。
Total System Global Area 1.2583E+10 bytes
Fixed Size 12581272 bytes
Variable Size 4194304000 bytes
Database Buffers 8355053568 bytes
Redo Buffers 20971520 bytes
数据库装载完毕。
说明:此时将E:\DMP\SYSTEM02.DBF复制成F:\APP\ADMINISTRATOR\ORADATA\ORCL\SYSTEM02.DBF
SQL> alter database rename file 'E:\DMP\SYSTEM02.DBF' to 'F:\APP\ADMINISTRATOR\ORADATA\ORCL\SYSTEM02.DBF';
数据库已更改。
SQL> alter database open;
数据库已更改。
SQL> select name from v$datafile;
NAME
------------------------------------------------------------
F:\APP\ADMINISTRATOR\ORADATA\ORCL\SYSTEM01.DBF
F:\APP\ADMINISTRATOR\ORADATA\ORCL\TEST02.DBF
F:\APP\ADMINISTRATOR\ORADATA\ORCL\TEST\SYSAUX01.DBF
F:\APP\ADMINISTRATOR\ORADATA\ORCL\UNDOTBS01.DBF
F:\APP\ADMINISTRATOR\ORADATA\ORCL\TEST01.DBF
F:\APP\ADMINISTRATOR\ORADATA\ORCL\USERS01.DBF
F:\APP\ADMINISTRATOR\ORADATA\ORCL\USERS02.DBF
F:\APP\ADMINISTRATOR\ORADATA\ORCL\USERS03.DBF
F:\APP\ADMINISTRATOR\ORADATA\ORCL\USERS04.DBF
F:\APP\ADMINISTRATOR\ORADATA\ORCL\USERS05.DBF
F:\APP\ADMINISTRATOR\ORADATA\ORCL\USERS06.DBF
F:\APP\ADMINISTRATOR\ORADATA\ORCL\USERS07.DBF
F:\APP\ADMINISTRATOR\ORADATA\ORCL\RMAN_TS01.DBF
F:\APP\ADMINISTRATOR\ORADATA\ORCL\SYSTEM02.DBF
F:\APP\ADMINISTRATOR\ORADATA\ORCL\TEST03.DBF
F:\APP\ADMINISTRATOR\ORADATA\ORCL\TEST04.DBF
F:\APP\ADMINISTRATOR\ORADATA\ORCL\TEST05.DBF
F:\APP\ADMINISTRATOR\ORADATA\ORCL\USERS10.DBF
已选择 18 行。
结论:已成功将系统关键数据文件转移到F:\APP\ADMINISTRATOR\ORADATA\ORCL\SYSTEM02.DBF