Oracle HowTo:如何通过只读方式更改Oracle数据文件位置

2014-11-24 16:47:22 · 作者: · 浏览: 1
Oracle HowTo:如何通过只读方式更改Oracle数据文件位置
在Oracle 数据库中,有多种方式可以移动数据文件的位置,之前介绍过几种方法: Oracle HowTo:在非归档模式下如何更改数据文件位置,Oracle HowTo:如何移动数据文件的位置
以上两种方法,可能在要求较高的24x7 系统中不适合采用,因为会使表空间长时间不可用。
特别是当表空间数据文件巨大时,物理拷贝可能需要较长的时间。
本文推荐另外一种方法,可以做一个折中,以下是一个简单的步骤说明:
1.将表空间置于只读
只读状态可以使数据仍然可为用户访问.
alter tablespace tablespace_name read only;
2.物理拷贝文件
3.将表空间offline
alter tablespace tablespace_name offline;
4.rename数据文件
alter database rename file 'old_dir_file' to 'new_dir_file';
5.将表空间联机
alter tablespace tablespace_name online;
6.将表空间置于read write模式
alter tablespace tablespace_name read write;
以下是示范步骤:
1.将表空间置于只读状态
[oracle@jumper oracle]$ sqlplus "/ as sysdba"

SQL*Plus: Release 9.2.0.4.0 - Production on Sat Nov 12 21:10:49 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 Archive Mode Automatic archival Enabled Archive destination /opt/oracle/oradata/conner/archive Oldest online log sequence 7 Next log sequence to archive 10 Current log sequence 10 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 read only; Tablespace altered. 2.物理拷贝文件 SQL> ! cp /opt/oracle/oradata/conner/users01.dbf /opt/oracle/oradata/users01.dbf 3.将表空间脱机 SQL> alter tablespace users offline; Tablespace altered. 4.修改文件名称 SQL> alter database rename file '/opt/oracle/oradata/conner/users01.dbf' to '/opt/oracle/oradata/users01.dbf'; Database altered. 5.将表空间联机 SQL> alter tablespace users online; Tablespace altered. 6.将表空间置于读写状态 SQL> alter tablespace users read write; 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 SQL>