oracle 更换数据库文件位置,ORACLE数据库数据文件位置迁移

一。移动数据文件 移动数据文件使用的有2种办法 方法一、以数据文件为单位移动 SQL select name from v$datafile; ------ ------ 2.关闭数据库 SQL shutdown immediate Database closed. Database dismounted. ORACLE instance shut down. 3.MOUNT到数据库 S

一。移动数据文件  移动数据文件使用的有2种办法

方法一、以数据文件为单位移动

SQL> select name from v$datafile;

------

------

2.关闭数据库

SQL> shutdown immediate

Database closed.

Database dismounted.

ORACLE instance shut down.

3.MOUNT到数据库

SQL> startup mount

ORACLE instance started.

Total System Global Area  135338868 bytes

Fixed Size                   453492 bytes

Variable Size             109051904 bytes

Database Buffers           25165824 bytes

Redo Buffers                 667648 bytes

Database mounted.

4.把要移动的数据文件剪切到目标目录,

SQL>SELECT 'host mv ' || d.FILE_NAME ||  ' /home/lc_orauser/mount/tablespace1/'||substr(d.FILE_NAME,34)||';' FROM Dba_Data_Files d;

host mv /home/lc_orauser/oradata/niutest/users01.dbf /home/lc_orauser/mount/tablespace1/users01.dbf;

host mv /home/lc_orauser/oradata/niutest/sysaux01.dbf /home/lc_orauser/mount/tablespace1/sysaux01.dbf;

……

5.alter database方法移动数据文件

SQL>SELECT 'alter database  rename file  '''|| d.file_name ||''' to ''/home/lc_orauser/mount/tablespace1/' ||

substr(d.FILE_NAME,34)||'''' FROM dba_tablespaces t,Dba_Data_Files d WHERE t.tablespace_name=d.TABLESPACE_NAME;

alter database  rename file  '/home/lc_orauser/mount/tablespace1/users01.dbf' to

'/home/lc_orauser/mount/tablespace1/1/users01.dbf'

……

6.移动其他数据文件同上。但是我们要注意的是TEMP数据文件。在我们上边列出数据文件的命令里没有包含这个文件。而且移动这个文件会报如下错:

*

ERROR at line 1:

ORA-01511: error in renaming log/data files

ORA-01516: nonexistent log file, datafile, or tempfile

"E:\ORACLE\ORADATA\SLUMGA\temp01.DBF"

那如何移动呢?我们需要创建一个TEMP文件,如下:

SQL> create temporary tablespace temp2 tempfile 'e:\oracle\tem2.dbf' size 20M reuse

autoextend on next 50m maxsize unlimited;

SQL> alter database default temporary tablespace temp2;

打开数据库,成功。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值