在Oracle数据库中,有多种方式可以移动数据文件的位置,之前介绍过一种方法:Oracle HowTo:在非归档模式下如何更改数据文件位置
其实可以采用的方法有多种,本文继续补充几种常用方法:
采用offline的方式
第一步,将表空间offline
alter tablespace tablespace_name offline;
第二步,cp文件到新的目录并rename修改控制文件
第三步,将相应表空间online
当然这种方式同样会影响期间的表空间使用。
以下是简单的示范步骤:
1.将表空间offline [oracle@jumper oracle]$ sqlplus "/ as sysdba"
SQL*Plus: Release 9.2.0.4.0 - Production on Sat Nov 12 18:14:21 2005
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
Connected to:
Oracle9i Enterprise Edition Release 9.2.0.4.0 - Production
With the Partitioning option
JServer Release 9.2.0.4.0 - Production
SQL> archive log list;
Database log mode No Archive Mode
Automatic archival Enabled
Archive destination /opt/oracle/oradata/conner/archive
Oldest online log sequence 6
Current log sequence 9
SQL> select name from v$datafile;
NAME
---------------------------------------------------------
/opt/oracle/oradata/conner/system01.dbf
/opt/oracle/oradata/conner/undotbs01.dbf
/opt/oracle/oradata/conner/users01.dbf
SQL> alter tablespace users offline;
Tablespace altered.
2.拷贝相应的数据文件 SQL> ! cp /opt/oracle/oradata/conner/users01.dbf /opt/oracle/oradata/users01.dbf
SQL> alter tablespace users rename datafile '/opt/oracle/oradata/conner/users01.dbf'
to '/opt/oracle/oradata/users01.dbf';
Tablespace altered.
3.将表空间online SQL> alter tablespace users online;
Tablespace altered.
SQL> select name from v$datafile;
NAME
------------------------------------------------------------------------
/opt/oracle/oradata/conner/system01.dbf
/opt/oracle/oradata/conner/undotbs01.dbf
/opt/oracle/oradata/users01.dbf
当然还有一些其他的方法可以采用.