专业编程教程与实战项目分享平台

网站首页 > 技术文章 正文

7步,让你清楚“如何修改Oracle数据文件目录和数据文件名”!

ins518 2024-10-23 13:08:36 技术文章 15 ℃ 0 评论

导读

本篇内容适用于:

当表空间中的数据文件放错了位置,并且名字不符合要求,想要更改数据文件路径和数据文件名的场景。

前提条件:

1.打开了数据库的归档模式

2.必须在业务跑完,数据库没有外来链接时,对数据没有修改时才能进行

例如:原来数据文件: /oracle/dsg.dbf

改为:/oracle/app/oracle/oradata/gao/shine.dbf


接下来就是具体的操作步骤,7步足矣:

Step1:

查看数据文件路径名字和文件号,

把文件号记下来。

SQL> select file_name,file_id from dba_data_files;

Step2:使用rman copy 来把dsg.dbf拷贝一份到想放到的路径下,并改名字。

rman target /

RMAN>copydatafile 6 to '/oracle/app/oracle/oradata/gao/shine.dbf';

Step3:

在sqlplus中让6号文件下线。

SQL> alter database datafile 6 offline;

Step4:

在sqlplus中重定义该数据文件的名字和目录

alter database rename file '/oracle/dsg.dbf' to '/oracle/app/oracle/oradata/gao/shine.dbf';

Step5:

在rman中恢复该数据文件。

rman target /

recover datafile 6;

Step6:

在sqlplus中让该数据文件online。

SQL>alter database datafile 6 online;

Step7:

查看数据文件路径名字和文件编号。

SQL> select name,file# from v$datafile;

本文暂时没有评论,来添加一个吧(●'◡'●)

欢迎 发表评论:

最近发表
标签列表