oracle資料庫恢復與備份

2021-06-18 04:25:48 字數 2803 閱讀 5861

一、oracle資料庫恢復

1.恢復剛才刪除的一條資料

delete from emp e where e.empname='smith'

select * from flashback_transaction_query f where f.table_name='emp'

undo_sql下面的語句為剛才刪除資料的相反操作,執行該語句即可恢復剛才刪除的資料

在11g版本中undo_sql為空值

alter database add supplemental log data

2.恢復剛更新的資料到某一時間點

update emp e set e.job='clerk'

select sysdate from dual;

檢視指定時間點時的資料是否是需要恢復前的資料:

select * from emp as of timestamp to_timestamp('2013/3/30 21:10:19', 'yyyy-mm-dd hh24:mi:ss')

alter table emp enable row movement;

恢復到某一時間點:

flashback table emp to timestamp to_timestamp('2013/3/30 21:10:19', 'yyyy-mm-dd hh24:mi:ss')

3.恢復刪除的表

drop table bonus

flashback table bonus to before drop

檢視被刪除的表:

select * from user_recyclebin u order by u.droptime desc

二、oracle資料庫備份

1.資料庫的rman備份須要在歸檔模式下

檢視歸檔模式

$ sqlplus / as sysdba

sql> archive log list

database log mode              no archive mode

automatic archival             disabled

archive destination            use_db_recovery_file_dest

oldest online log sequence     18

current log sequence           20

更改歸檔模式

關閉資料庫

sql> shutdown immediate

啟動資料庫到mount狀態

sql> startup mount

更改為歸檔模式(noarchivelog為非歸檔模式)

sql> alter database archivelog;

再次檢視是否為歸模式

sql> archive log list

database log mode              archive mode

automatic archival             enabled

archive destination            use_db_recovery_file_dest

oldest online log sequence     18

next log sequence to archive   20

current log sequence           20

進入rman

$ rman target/

檢視預設設定

rman> show all;

檢視備份的相關資訊

rman> list backup;control file included: ckp scn: 1037059      ckp time: 31-aug-13

三、oracle資料庫全庫恢復

資料庫啟動過程

找到初始化spfile或pfile,處於nomount狀態;

根據初始化檔案找到控制檔案contral file,處於mount狀態;

根據控制檔案找到資料檔案data file、重做日誌檔案redo file,處於open狀態;

恢復資料庫的前提是oracle資料庫的初始化spfile檔案、控制檔案、重做日誌、歸檔日誌、備份都可以正常使用

恢復原則:根據丟失的檔案情況,啟動資料庫到相應狀態,然後通過rman恢復相應檔案,再將資料庫啟動到下一狀態

檢視是否有備份

rman> list backup summary;

1.僅丟失資料檔案情況

starting recover at 31-aug-13

using channel ora_disk_1

starting media recovery

media recovery complete, elapsed time: 00:00:07

finished recover at 31-aug-13

進入sql將狀態改為open即恢復成功

sql> alter database open;

oracle資料庫備份與恢復

一 使用資料幫浦備份資料 1.建立目錄物件並授權 connect sys password as sysdba create directory dir1 as e dump1 create directory dir2 as e dump2 grant read,write on director...

Oracle資料庫備份與恢復 增量備份

rman乙個強大的功能是支援增量備份,增量備份中心思想就是減少備份的資料量,我們不需要在從頭開始備份了,只需要備份自上次已備份之後的資料塊即可。關於incremental增量備份級別 oracle 9i 共有五種級別 0 1 2 3 4,0級最高 4級最低,0級是1級的基礎以此類推。oracle 1...

Oracle資料庫備份與恢復 增量備份

oracle資料庫備份與恢復 增量備份 rman乙個強大的功能是支援增量備份,增量備份中心思想就是減少備份的資料量,我們不需要在從頭開始備份了,只需要備份自上次已備份之後的資料塊即可。關於incremental增量備份級別 oracle 9i 共有五種級別 0 1 2 3 4,0級最高 4級最低,0...