一。移动数据文件 移动数据文件使用的有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;
打开数据库,成功。