由於規范存儲位置以及存儲空間調整緣故需要移動表空間MRP_INDEX2的數據文件,如下所示,首先將表空間MRP_INDEX2脫機; 然後復制數據文件;接著重命名數據文件,最後將表空間MRP_INDEX2聯機.
在操作過後,最後一步將表空間MRP_INDEX2聯機上線時,出現了意外錯誤信息,如下所示:
SQL> ALTER TABLESPACE MRP_INDEX2 OFFLINE NORMAL;
Tablespace altered.
SQL> !cp /u03/flash_recovery_area/oradata/epps/mrp_index2_x01.dbf /u04/epps/oradata/mrp_index2_x01.dbf
SQL> !cp /u03/flash_recovery_area/oradata/epps/mrp_index2_x02.dbf /u04/epps/oradata/mrp_index2_x02.dbf
SQL> ALTER DATABASE RENAME FILE '/u03/flash_recovery_area/oradata/epps/mrp_index2_x01.dbf' TO '/u04/epps/oradata/mrp_index2_x01.dbf';
Database altered.
如下所示,在重命名文件時,其中一個文件路徑'u04/epps/oradata/mrp_index2_x02.dbf'弄錯了,當時一直沒有留意到這個錯誤,怕耽擱Tablespace的聯機上線時間。於是先將表空間MRP_INDEX2聯機上線
SQL> ALTER DATABASE RENAME FILE '/u03/flash_recovery_area/oradata/epps/mrp_index2_x02.dbf' TO 'u04/epps/oradata/mrp_index2_x02.dbf'
*
ERROR at line 1:
ORA-01511: error in renaming log/data files
ORA-01141: error renaming data file 86 - new file
'u04/epps/oradata/mrp_index2_x02.dbf' not found
ORA-01110: data file 86:
'/u03/flash_recovery_area/oradata/epps/mrp_index2_x02.dbf'
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3
SQL> ALTER TABLESPACE MRP_INDEX2 ONLINE ;
Tablespace altered.
檢查過後發現了上面腳本錯誤,於是接著處理,但是將表空間MRP_INDEX2脫機後,沒有重新拷貝數據文件過去,直接重命名數據文件(SCN已經改變,導致下面ORA-01113錯誤),然後表空間聯機上線時,出現了下面錯誤
SQL> ALTER TABLESPACE MRP_INDEX2 OFFLINE NORMAL;
Tablespace altered.
SQL> ALTER DATABASE RENAME FILE '/u03/flash_recovery_area/oradata/epps/mrp_index2_x02.dbf' TO '/u04/epps/oradata/mrp_index2_x02.dbf';
Database altered.
SQL>
SQL> ALTER TABLESPACE MRP_INDEX2 ONLINE ;
ALTER TABLESPACE MRP_INDEX2 ONLINE
*
ERROR at line 1:
ORA-01113: file 86 needs media recovery
ORA-01110: data file 86: '/u04/epps/oradata/mrp_index2_x02.dbf'
解決方法:
1:首先將對應報錯的數據文件脫機
SQL> alter database datafile '/u04/epps/oradata/mrp_index2_x02.dbf' offline;
Database altered.
2:其次recover這個數據文件
SQL> alter database recover datafile '/u04/epps/oradata/mrp_index2_x02.dbf';
Database altered.
3:然後將該數據文件聯機上線
SQL> alter database datafile '/u04/epps/oradata/mrp_index2_x02.dbf' online;
Database altered.
4:最後將該表空間MRP_INDEX2聯機上線。
SQL> ALTER TABLESPACE MRP_INDEX2 ONLINE ;
當然也可以使用RMAN還原,這裡感覺使用SQL命令還原要簡單方便一點,最後刪除拷貝前的文件
rm /u03/flash_recovery_area/oradata/epps/mrp_index2_x01.dbf
rm /u03/flash_recovery_area/oradata/epps/mrp_index2_x02.dbf
其實考官問你這個問題有2個目的,1,就是對數據庫的了解和操作的熟練程度,也就是你的能力。2,就是看你有沒有實際管理數據庫的經驗,管理方法。
所以 首先你要問明數據庫是否為歸檔模式,如果不是,你要說出作為dba或管理員如果數據庫既不歸檔又不備份,那麼這個人是不合和,不稱職的。如果為歸檔模式,那麼你在回答可以以如下步驟操作:
例如:
SQL> startup mount
SQL> alter database open;
alter database open
*
ERROR at line 1:
ORA-01157: cannot identify/lock data file 3 - see DBWR trace file
ORA-01110: data file 3: '/opt/oracle/oradata/eygle/eygle02.dbf'
SQL> alter database create datafile 3 as '/opt/oracle/oradata/eygle/eygle02.dbf';
Database altered.
SQL> alter database open;
alter database open
*
ERROR at line 1:
ORA-01113: file 3 needs media recovery
ORA-01110: data file 3: '/opt/oracle/oradata/eygle/eygle02.dbf'
SQL> recover datafile 3;
Media recovery complete.
SQL> alter database open;
Database altered.
通過sql命令查看oracle數據庫的物理結構
數據文件 SQL> select * from dba_data_files;
重做日志 SQL> select * from v$logfile;
歸檔日志 SQL> select * from v$archived_log
臨時文件 SQL> select * from v$tempfile;
創建新的表空間,並且根據需要添加數據文件
create tablespace xxx datafile='xxx' size 1000m;
alter tablespace xxx add datafile='xxx' size 1000m;
管理表空間的各種操作(調整大小、只讀、刪除等)
查看使用率
col tablespace_namefor a20
col TOTAL_M for a20
col FREE_M for a20
COL used_m for a20
coluseage for a10
Select a.tablespace_name,
to_char(a.bytes / 1024 / 1024, '99999') total_M,
to_char(b.bytes / 1024 / 1024, '99999') free_M,
to_char(a.bytes / 1024 / 1024 -b.bytes / 1024 / 1024, '99999.999') used_M,
to_char((1 - b.bytes / a.bytes) * 100, '99.99') || '%' useage
from (select tablespace_name, sum(bytes) bytes
from dba_data_files
groupby tablespace_name) a,
(select tablespace_name, sum(bytes) bytes
from dba_free_space
groupbytablespace_name) b
where a.tablespace_name = b.tablespace_name
刪除表空間以及文件
drop tablespace xxx including contents and datafiles;
調整表空間只讀
alter tablespace xxx read only;
調整大小的話是針對表空間的數據文件的
首先查看表空間有幾個數據文件
select file_name from dba_data_files where tablespace_name='xxx';
重新設置一個數據文件的大小
alter database datafile 'xxx' resize 1000m;
添加一個數據文件
alter tablespace xxx add datafile='xxx' size 1000m;
刪除一個數據文件
alter tablespace xxx drop datafi......余下全文>>