oracle 迁移数据文件

1.关闭数据库

oracle@mumuso ~]$ sqlplus /nolog

SQL*Plus: Release 11.2.0.4.0 Production on Fri Sep 9 10:21:34 2016

Copyright (c) 1982, 2013, Oracle.  All rights reserved.
SQL> conn /as sysdba
Connected to an idle instance.
SQL> startup
ORACLE instance started.

Total System Global Area 3206946816 bytes
Fixed Size            2280384 bytes
Variable Size         1677722688 bytes
Database Buffers     1518338048 bytes
Redo Buffers            8605696 bytes
Database mounted.
Database opened.

SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.

2.将数据文件迁移到指定位置

[oracle@mumuso oradata]$ cp NEANDS.dbf /u01/app/oracle/oradata/orcl/NEANDS.dbf
[oracle@mumuso oradata]$ cp TS_FAIR.dbf /u01/app/oracle/oradata/orcl/TS_FAIR.dbf

3.将数据库启动到mount状态,rename datafile

SQL> startup mount
ORACLE instance started.
Total System Global Area 3206946816 bytes
Fixed Size            2280384 bytes
Variable Size         1677722688 bytes
Database Buffers     1518338048 bytes
Redo Buffers            8605696 bytes
Database mounted.
SQL> alter database rename file '/u01/app/oracle/oradata/NEANDS.dbf'  to '/u01/app/oracle/oradata/orcl/NEANDS.dbf'; 
Database altered.
SQL> alter database rename file '/u01/app/oracle/oradata/TS_FAIR.dbf'  to '/u01/app/oracle/oradata/orcl/TS_FAIR.dbf'; 
Database altered.

4.打开数据库

SQL> alter database open;
Database altered.
SQL> select file#,name,status from v$datafile;

     FILE# NAME                                                 STATUS
---------- ---------------------------------------------------------------------------------------------------- -------
     1 /u01/app/oracle/oradata/orcl/system01.dbf                                SYSTEM
     2 /u01/app/oracle/oradata/orcl/sysaux01.dbf                                ONLINE
     3 /u01/app/oracle/oradata/orcl/undotbs01.dbf                                ONLINE
     4 /u01/app/oracle/oradata/orcl/users01.dbf                                ONLINE
     5 /u01/app/oracle/oradata/orcl/NEANDS.dbf                                ONLINE
     6 /u01/app/oracle/oradata/orcl/TS_FAIR.dbf                                ONLINE

6 rows selected.

在实验过程中做了错误的操作

我已经迁移完数据文件,又做了rename操作,此时控制文件已经找不到原来的数据文件报如下错误:

SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down. " - rest of line ignored.
SQL> alter database rename file '/u01/app/oracle/oradata/NEANDS.dbf'  to '/u01/app/oracle/oradata/orcl/NEANDS.dbf'; 
alter database rename file '/u01/app/oracle/oradata/NEANDS.dbf'  to '/u01/app/oracle/oradata/orcl/NEANDS.dbf'
*
ERROR at line 1:
ORA-01034: ORACLE not available
Process ID: 3342
Session ID: 3394 Serial number: 5

解决办法:

SQL> alter database recover datafile '/u01/app/oracle/oradata/orcl/NEANDS.dbf';
Database altered.
SQL>   alter database recover datafile '/u01/app/oracle/oradata/orcl/TS_FAIR.dbf';
Database altered.
SQL> alter database open;
Database altered.
  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值