Two methods of Oracle rename data files ____oracle

Source: Internet
Author: User
Tags chr

First Kind

Alter tablespace users rename datafile ' = = ' to ' * * *;

In this way, the database is open, and the tablespace can be changed in offline state.

sql> alter tablespace users rename DataFile '/opt/ora10g/oradata/orcl/user0100.dbf ', '/opt/ora10g/oradata/orcl/
User099.dbf ' to '/opt/ora10g/oradata/orcl/userrename1.dbf ', '/opt/ora10g/oradata/orcl/userrename2.dbf '; Alter tablespace users rename DataFile '/opt/ora10g/oradata/orcl/user0100.dbf ', '/opt/ora10g/oradata/orcl/ User099.dbf ' to '/opt/ora10g/oradata/orcl/userrename1.dbf ', '/opt/ora10g/oradata/orcl/userrename2.dbf ' * ERROR at Line 1:ora-01525:error in renaming data files ora-01121:cannot Rename database file 107-file be in use or recovery or
A-01110:data file: '/opt/ora10g/oradata/orcl/user0100.dbf ' sql> alter tablespace users offline;

Tablespace altered. sql> alter tablespace users rename DataFile '/opt/ora10g/oradata/orcl/user0100.dbf ', '/opt/ora10g/oradata/orcl/
User099.dbf ' to '/opt/ora10g/oradata/orcl/userrename1.dbf ', '/opt/ora10g/oradata/orcl/userrename2.dbf '; Alter tablespace users rename DataFile '/opt/ora10g/oradata/orcl/user0100.dbf ', '/opt/ora10g/oradata/orCl/user099.dbf ' to '/opt/ora10g/oradata/orcl/userrename1.dbf ', '/opt/ora10g/oradata/orcl/userrename2.dbf ' * ERROR at Line 1:ora-01525:error in renaming data files ora-01141:error renaming data file 107-new file '/opt/ora10g/oradata/or CL/USERRENAME1.DBF ' not found Ora-01110:data file: '/opt/ora10g/oradata/orcl/user0100.dbf ' ora-27037:unable to OBTA
In file status linux-x86_64 error:2: No such file or directory Additional Information:3 sql>! [Oracle@rac1 ~]$ Cp/opt/ora10g/oradata/orcl/user0100.dbf/opt/ora10g/oradata/orcl/userrename1.dbf[oracle@rac1 ~]$ Cp/opt/ora10g/oradata/orcl/user099.dbf/opt/ora10g/oradata/orc l/userrename2.dbf [Oracle@rac1 ~]$ exit Exit SQL> Alter tablespace users rename DataFile '/opt/ora10g/oradata/orcl/user0100.dbf ', '/opt/ora10g/oradata/orcl/
User099.dbf ' to '/opt/ora10g/oradata/orcl/userrename1.dbf ', '/opt/ora10g/oradata/orcl/userrename2.dbf ';

Tablespace altered.
sql> alter tablespace users online;

 Tablespace altered.

Second Kind

Alter DATABASE rename file ' = = ' to ' * * *;

This method requires the database to be in Mount state

Sql> Startup Mount ORACLE instance started. Total System Global area 788529152 bytes Fixed size 2087216 bytes Variable Size 423626448 by
TEs database buffers 356515840 bytes Redo buffers 6299648 Database bytes. sql> ALTER DATABASE rename file '/opt/ora10g/oradata/orcl/userrename2.dbf ', '/opt/ora10g/oradata/orcl/

Userrename1.dbf ' to '/opt/ora10g/oradata/orcl/user099.dbf ', '/opt/ora10g/oradata/orcl/user0100.dbf ';

Database altered.
sql> ALTER DATABASE open; ALTER DATABASE open * ERROR at line 1:ora-01113:file needs media recovery ora-01110:data file: '/opt/ora10g/ora DATA/ORCL/USER099.DBF '-- The reason why this cannot be open is that the database has just been shut down to write the SCN of the two data files userrename2.dbf and userrename1.dbf, while the USER099.DBF and user0100.dbf SCN are offline, so that the header and data file headers of the control file

Inconsistent, so the database is not open. sql> ALTER DATABASE rename file '/opt/ora10g/oradata/orcl/user099.dbf ', '/opt/ora10g/oradata/orcl/user0100.dbf ' to '/opt/ora10g/oradata/orcl/userrename2.dbf ', '/opt/ora10g/oradata/orcl/usERRENAME1.DBF ';

Database altered.

sql> ALTER DATABASE open; Database altered.

Also attached is a batch modification of the data file name statement

Set pagesize 999
set linesize 999
select ' ALTER DATABASE rename file ' | | member| | ' | | | Chr (39) | | Replace (member, '/paic/hq/bk/restore/data/oradata/lass/', '/paic/z4ah8020/stg/lass/oradata/hs03lass/') | | 
From V$logfile
where member like '/paic/hq/bk/restore/data/oradata/lass/% '; 
 
Select ' ALTER DATABASE rename file ' | | | name| | ' | | | Chr (39) | | Replace (name, '/paic/hq/bk/restore/data/oradata/lass/', '/paic/z4ah8020/stg/lass/oradata/hs03lass/') | | 
From V$datafile 
where name like '/paic/hq/bk/restore/data/oradata/lass/% '

select ' ALTER DATABASE rename file ' | | ' '''|| name| | ' | | | Chr (39) | | Replace (name, '/paic/hq/bk/restore/data/oradata/lass/', '/paic/z4ah8020/stg/lass/oradata/hs03lass/') | | 
From V$tempfile 
where name like '/paic/hq/bk/restore/data/oradata/lass/% '


Note: Red is the original path purple as the target path

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.