Oracle 11g 遷移資料檔案

2021-09-26 18:19:55 字數 1423 閱讀 6141

一、基礎環境

作業系統:windows 或 linux 

資料庫版本:oracle database 11g r2

二、解決問題

1、我們在進行備份資料庫或者進行複雜的操作的時候,表空間自動擴充套件功能開啟的時候,會提示磁碟空間不足。

2、將資料檔案分散到不同的磁碟,以提高資料庫的 i/o 效能。

三、操作步驟

1、以 dba 的身份登陸sql plus ;

sqlplus / as sysdba;
2.1、查詢資料檔案清單:資料表空間、索引表空間使用以下語句

select name from v$datafile;
2.2、查詢資料檔案清單:臨時表空間使用以下語句

select file_name from dba_temp_files
3、正常關閉資料庫。

shutdown immediate;
4、開始移動資料檔案(為了保險起見,也可使用複製命令)。

特別說明:在sql plus中,先輸入乙個$,後面再加上作業系統的命令,可以執行作業系統的操作;資料檔案的路徑必須是英文雙引號;在windows 系統中,命令和路徑不區分大小寫,大小寫均可; 在 linux 系統中,命令和路徑是區分大小寫的,因此必須使用小寫。

windows 系統:

$move "d:\programfiles\oracle\oradata\orcl\sspt01.dbf" "e:\oradata\sspt01.dbf";
linux 系統:

$mv "/oradata/orcl/sspt01.dbf" "/opt/oradata/sspt01.dbf";
5、將資料庫啟動到 mount 狀態。

startup mount;
6、修改資料檔案名稱,資料檔案路徑必須使用單引號。(以下語句中的路徑為 windows 路徑,可以替換成 linux 路徑)

alter database rename file 'd:\programfiles\oracle\oradata\orcl\sspt01.dbf' to 'e:\oradata\sspt01.dbf';
7、開啟資料庫。

alter database open;
8、查詢資料庫資料檔案狀態。

select name,status from v$datafile;
9、查詢 scott.emp 表中的資料。

select * from scott.emp;
10、操作完成,退出 sql plus。

oracle 遷移資料檔案

步驟 1.sql select file name from dba data files file name d oracle product 10.2.0 oradata test datafile o1 mf users 4yfv39n0 dbf d oracle product 10.2.0...

oracle 遷移資料檔案( 轉)

步驟 1.sql select file name from dba data files file name d oracle product 10.2.0 oradata test datafile o1 mf users 4yfv39n0 dbf d oracle product 10.2.0...

遷移資料檔案步驟

select file name,status from v datafile select from v tablespace 1.alter tablespace aaa offline 2.shutdown immediate 3.copy data file to destination d...