以下在測試環境施作的
SOP大致如下
1. Shutdown DB instance
2. Cold copy all db files to other location
3.Modify parameter files
4.Startup mount , rename location of files
SQL>
spool rename.sql
set pagesize 0
set linesize 300
select 'alter database rename file '''||file_name||''' to ''/ora_test/oradata/orcl'||substr(file_name,21)||''';' from
(select file_name from dba_data_files
union
select file_name from dba_temp_files
union
select member as file_name from v$logfile) fpath;
spool off
alter database rename file '/oracle/oradata/orcl/cwmlite01.dbf' to '/ora_test/oradata/orcl/cwmlite01.dbf';
alter database rename file '/oracle/oradata/orcl/drsys01.dbf' to '/ora_test/oradata/orcl/drsys01.dbf';
alter database rename file '/oracle/oradata/orcl/example01.dbf' to '/ora_test/oradata/orcl/example01.dbf';
alter database rename file '/oracle/oradata/orcl/indx01.dbf' to '/ora_test/oradata/orcl/indx01.dbf';
alter database rename file '/oracle/oradata/orcl/odm01.dbf' to '/ora_test/oradata/orcl/odm01.dbf';
alter database rename file '/oracle/oradata/orcl/redo01.log' to '/ora_test/oradata/orcl/redo01.log';
alter database rename file '/oracle/oradata/orcl/redo02.log' to '/ora_test/oradata/orcl/redo02.log';
alter database rename file '/oracle/oradata/orcl/redo03.log' to '/ora_test/oradata/orcl/redo03.log';
alter database rename file '/oracle/oradata/orcl/system01.dbf' to '/ora_test/oradata/orcl/system01.dbf';
alter database rename file '/oracle/oradata/orcl/temp01.dbf' to '/ora_test/oradata/orcl/temp01.dbf';
alter database rename file '/oracle/oradata/orcl/tools01.dbf' to '/ora_test/oradata/orcl/tools01.dbf';
alter database rename file '/oracle/oradata/orcl/undotbs01.dbf' to '/ora_test/oradata/orcl/undotbs01.dbf';
alter database rename file '/oracle/oradata/orcl/users01.dbf' to '/ora_test/oradata/orcl/users01.dbf';
alter database rename file '/oracle/oradata/orcl/xdb01.dbf' to '/ora_test/oradata/orcl/xdb01.dbf';
SQL> create pfile='/tmp/pfile.ora' from spfile;
File created.
SQL>shutdown immediate;
vi /tmp/pfile.ora ,
#修改control file 路徑,
把 /oracle/oradata/ 修改為 /ora_test/oradata
#如果也要修改log 路徑 從 /oracle/admin 修改成 /ora_test/admin 的話, 也記得
把 /oracle/admin/ 修改為 /ora_test/admin
-bash-3.00$ sqlplus "/ as sysdba"
SQL*Plus: Release 9.2.0 .8.0 - Production on Wed Apr 25 11:00:32 2012
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
Connected to an idle instance.
SQL> create spfile from pfile='/tmp/pfile.ora';
File created.
SQL> exit
Disconnected
SQL> startup mount;
SQL>
spool rename.log
start rename.sql
spool off
SQL> alter database open;
Database altered.
#temp tablespace 需另外處理
SQL> select file_name from dba_temp_files
FILE_NAME
--------------------------------------------------------------------------------
/oracle/oradata/orcl/temp01.dbf
SQL>
SQL> drop tablespace temp ;
drop tablespace temp
*
ERROR at line 1:
ORA-12906: cannot drop default temporary tablespace
CREATE TEMPORARY TABLESPACE TEMP2
TEMPFILE '/ora_test/oradata/orcl/temp01.dbf' SIZE 128M AUTOEXTEND ON NEXT 32M MAXSIZE 4096M
EXTENT MANAGEMENT LOCAL UNIFORM SIZE 1024K
SEGMENT SPACE MANAGEMENT MANUAL;
/
Tablespace created.
SQL>
ALTER DATABASE DEFAULT TEMPORARY TABLESPACE temp2;
Database altered.
SQL>
drop tablespace temp including contents and datafiles;
Tablespace dropped.
SQL>
CREATE TEMPORARY TABLESPACE TEMP
TEMPFILE '/ora_test/oradata/orcl/temp001.dbf' SIZE 128M AUTOEXTEND ON NEXT 32M MAXSIZE 4096M
EXTENT MANAGEMENT LOCAL UNIFORM SIZE 1024K
SEGMENT SPACE MANAGEMENT MANUAL;
/
ALTER DATABASE DEFAULT TEMPORARY TABLESPACE temp;
drop tablespace temp2 including contents and datafiles;
沒有留言:
張貼留言