資料檔案遷移

壹頁書發表於2014-04-15
資料檔案遷移有兩種方法:
1  使表空間到離線狀態,然後重新命名資料檔案,然後再恢復表空間狀態
2  關閉資料庫,然後起到mount狀態,重新命名資料檔案,然後把庫開到open狀態

第一種演示如下

點選(此處)摺疊或開啟

  1. SQL> select file_id , file_name , tablespace_name , bytes/1024/1024 from dba_data_files;

  2.    FILE_ID FILE_NAME TABLESPACE BYTES/1024/1024
  3. ---------- -------------------------------------------------- ---------- ---------------
  4.          1 /u01/app/oracle/oradata/PROD/disk3/system01.dbf SYSTEM 325
  5.          2 /u01/app/oracle/oradata/PROD/disk4/undotbs01.dbf UNDOTBS 200
  6.          3 /u01/app/oracle/oradata/PROD/disk4/sysaux01.dbf SYSAUX 325
  7.          4 /u01/app/oracle/oradata/PROD/disk3/system02.dbf UNDOTBS2 10
  8.          5 /u01/app/oracle/oradata/PROD/disk4/undotbs02.dbf UNDOTBS3 10
  9.          6 /u01/app/oracle/oradata/PROD/disk3/user01.dbf USERS 15
  10.          7 /u01/app/oracle/oradata/PROD/disk4/user02.dbf USERS 10
  11.          8 /u01/app/oracle/oradata/PROD/disk4/lxtbs01.dbf LXTBS 10
  12.          9 /u01/app/oracle/oradata/PROD/disk3/lxtbs02.dbf LXTBS 10

  13. 9 rows selected.

  14. SQL> alter tablespace lxtbs offline;

  15. Tablespace altered.
  16. SQL> alter tablespace lxtbs rename datafile \'/u01/app/oracle/oradata/PROD/disk4/lxtbs01.dbf\' to \'/u01/app/oracle/oradata/PROD/disk3/lxtbs01.dbf\';

  17. Tablespace altered.

  18. SQL> alter tablespace lxtbs online;

  19. Tablespace altered.

  20. SQL> select file_id , file_name , tablespace_name , bytes/1024/1024 from dba_data_files;

  21.    FILE_ID FILE_NAME TABLESPACE BYTES/1024/1024
  22. ---------- -------------------------------------------------- ---------- ---------------
  23.          1 /u01/app/oracle/oradata/PROD/disk3/system01.dbf SYSTEM 325
  24.          2 /u01/app/oracle/oradata/PROD/disk4/undotbs01.dbf UNDOTBS 200
  25.          3 /u01/app/oracle/oradata/PROD/disk4/sysaux01.dbf SYSAUX 325
  26.          4 /u01/app/oracle/oradata/PROD/disk3/system02.dbf UNDOTBS2 10
  27.          5 /u01/app/oracle/oradata/PROD/disk4/undotbs02.dbf UNDOTBS3 10
  28.          6 /u01/app/oracle/oradata/PROD/disk3/user01.dbf USERS 15
  29.          7 /u01/app/oracle/oradata/PROD/disk4/user02.dbf USERS 10
  30.          8 /u01/app/oracle/oradata/PROD/disk3/lxtbs01.dbf LXTBS 10
  31.          9 /u01/app/oracle/oradata/PROD/disk3/lxtbs02.dbf LXTBS 10

  32. 9 rows selected.
第二種
alter database rename file '/u01/app/oracle/oradata/PROD/disk4/lxtbs01.dbf' to
'/u01/app/oracle/oradata/PROD/disk3/lxtbs01.dbf';


alter database rename file '/u01/app/oracle/oradata/PROD/disk4/lxtbs01.dbf' to
'/u01/app/oracle/oradata/PROD/disk3/lxtbs01.dbf';
建議使用第一種辦法,方便,且不需要關庫,省掉了好多書面報告

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29254281/viewspace-1142167/,如需轉載,請註明出處,否則將追究法律責任。

相關文章