1. 確定數據文件狀態
select file_name, status
from dba_data_files
where tablespace_name ='tablespace_name';
2. 將表空間置為read-only(時間可能會很長,比重啟數據庫的時間還長)
alter tablespace tablespace_name read only;
3. 確定表空間狀態為read-only
select tablespace_name, status
from dba_tablespaces
where tablespace_name = 'tablespace_name';
4. 用操作系統命令將數據文件拷貝為新的文件名,確認大小一樣
5. 將表空間offline(這時用戶就不能訪問這個表空間了)
alter tablespace tablespace_name offline;
6. 修改控制文件中的相應記錄
alter database rename file
'/full_path_of_old_location/and_datafile_name.dbf'
to
'/full_path_of_new_location/and_datafile_name.dbf';
7. 將表空間online
alter tablespace tablespace_name online;
8. 將表空間置回為read-write
alter tablespace tablespace_name read write;
9. 備份控制文件
alter database backup controlfile to trace;
10. 在操作系統上刪除原來的數據文件
說明:
1. 將表空間先置為read-only,是讓用戶不能訪問(read)的時間盡量少點(少的時間為拷貝文件所需的時間)
2. 如果是standby環境,對standby的恢復沒有影響,如果要保持一致的話,mount standby后用cp然后alter database rename file ..... 即可。
新聞熱點
疑難解答