连接数据库输入以下命令,将控制文件移动到自己想要的目录我是在orcl2目录下新建了一个文件夹:
alter system set control_files='/u01/app/oracle/oradata/orcl2/controlfile/control01.ctl' scope=spfile;
然后修改pfile文件
输入:create pfile from spfile;
关闭数据库实例: shutdown immediate
将自己的控制文件移动到新建的目录:
然后启动数据库实例:startup
如果启动成功:则说明移动成功。
接着关闭数据库: shutdown immediate
然后启动到挂在状态:startup mount
三个文件的目录在:/u01/app/oracle/oradata/orcl2
在这个目录下爱可以查看到自己的控制文件数据文件和日志文件
然后输入以下命令:
ALTER DATABASE RENAME FILE '/u01/app/oracle/oradata/orcl2/system01.dbf' TO '/u01/app/oracle/oradata/orcl2/datafile/system01.dbf';
ALTER DATABASE RENAME FILE '/u01/app/oracle/oradata/orcl2/example01.dbf' TO '/u01/app/oracle/oradata/orcl2/datafile/example01.dbf';
ALTER DATABASE RENAME FILE '/u01/app/oracle/oradata/orcl2/sysaux01.dbf' TO '/u01/app/oracle/oradata/orcl2/datafile/sysaux01.dbf';
ALTER DATABASE RENAME FILE '/u01/app/oracle/oradata/orcl2/temp01.dbf' TO '/u01/app/oracle/oradata/orcl2/datafile/temp01.dbf';
ALTER DATABASE RENAME FILE '/u01/app/oracle/oradata/orcl2/temp02.dbf' TO '/u01/app/oracle/oradata/orcl2/datafile/temp02.dbf';
ALTER DATABASE RENAME FILE '/u01/app/oracle/oradata/orcl2/tpcctab1.dbf' TO '/u01/app/oracle/oradata/orcl2/datafile/tpcctab1.dbf';
ALTER DATABASE RENAME FILE '/u01/app/oracle/oradata/orcl2/undotbs01.dbf' TO '/u01/app/oracle/oradata/orcl2/datafile/undotbs01.dbf';
ALTER DATABASE RENAME FILE '/u01/app/oracle/oradata/orcl2/undotbs1.dbf' TO '/u01/app/oracle/oradata/orcl2/datafile/undotbs1.dbf';
ALTER DATABASE RENAME FILE '/u01/app/oracle/oradata/orcl2/users01.dbf' TO '/u01/app/oracle/oradata/orcl2/datafile/users01.dbf';
ALTER DATABASE RENAME FILE '/u01/app/oracle/oradata/orcl2/redo01.log' TO '/u01/app/oracle/oradata/orcl2/logfile/redo01.log';
ALTER DATABASE RENAME FILE '/u01/app/oracle/oradata/orcl2/redo02.log' TO '/u01/app/oracle/oradata/orcl2/logfile/redo02.log';
ALTER DATABASE RENAME FILE '/u01/app/oracle/oradata/orcl2/redo03.log' TO '/u01/app/oracle/oradata/orcl2/logfile/redo03.log';
接着将文件移动到目标目录
然后打开数据库
alter database open;
输入: select name from v$datafile;
输入: select * from v$logfile;
发现都已移动成功且数据库已成功启动
4.