1. 程式人生 > >oracle drop/truncate table 恢復

oracle drop/truncate table 恢復

4. 修改pfile

node1new.__db_cache_size=335544320
node1new.__java_pool_size=4194304
node1new.__large_pool_size=4194304
node1new.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment
node1new.__pga_aggregate_target=339738624
node1new.__sga_target=503316480
node1new.__shared_io_pool_size=0
node1new.__shared_pool_size=150994944
node1new.__streams_pool_size=0
*.audit_file_dest='/u01/app/oracle/admin/node1new/adump'
*.audit_trail='db'
*.compatible='11.2.0.4.0'
*.control_files='/oradata/node1new/control01.ctl','/u01/app/oracle/fast_recovery_area/node1new/control02.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_file_name_convert='/oradata/node1new','/oradata/node2'
*.db_name='node1'
*.db_unique_name='node1new'
*.db_recovery_file_dest='/u01/app/oracle/fast_recovery_area'
*.db_recovery_file_dest_size=5218762752
*.diagnostic_dest='/u01/app/oracle'
*.java_pool_size=0
*.log_archive_dest_1='location=/oradata/arch1'
*.memory_target=842006528
*.open_cursors=300
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.undo_tablespace='UNDOTBS1'



5. 建立各種dump目錄
-----------------------------------------------------
[
[email protected]
tmp]$ export ORACLE_SID=node1new
[[email protected] tmp]$ echo $ORACLE_SID
node1new

11g要建立這些目錄

rm -rf $ORACLE_BASE/admin/$ORACLE_SID
mkdir -p $ORACLE_BASE/admin/$ORACLE_SID/adump
mkdir -p $ORACLE_BASE/admin/$ORACLE_SID/dpdump
mkdir -p $ORACLE_BASE/admin/$ORACLE_SID/pfile
mkdir -p $ORACLE_BASE/admin/$ORACLE_SID/scripts
chmod -R 750 $ORACLE_BASE/admin

rm -rf $ORACLE_BASE/diag/rdbms/$ORACLE_SID
mkdir -p $ORACLE_BASE/diag/rdbms/$ORACLE_SID/$ORACLE_SID/alert 
mkdir -p $ORACLE_BASE/diag/rdbms/$ORACLE_SID/$ORACLE_SID/cdump 
mkdir -p $ORACLE_BASE/diag/rdbms/$ORACLE_SID/$ORACLE_SID/hm    
mkdir -p $ORACLE_BASE/diag/rdbms/$ORACLE_SID/$ORACLE_SID/incident
mkdir -p $ORACLE_BASE/diag/rdbms/$ORACLE_SID/$ORACLE_SID/incpkg
mkdir -p $ORACLE_BASE/diag/rdbms/$ORACLE_SID/$ORACLE_SID/ir    
mkdir -p $ORACLE_BASE/diag/rdbms/$ORACLE_SID/$ORACLE_SID/lck   
mkdir -p $ORACLE_BASE/diag/rdbms/$ORACLE_SID/$ORACLE_SID/metadata
mkdir -p $ORACLE_BASE/diag/rdbms/$ORACLE_SID/$ORACLE_SID/stage 
mkdir -p $ORACLE_BASE/diag/rdbms/$ORACLE_SID/$ORACLE_SID/sweep 
mkdir -p $ORACLE_BASE/diag/rdbms/$ORACLE_SID/$ORACLE_SID/trace
chmod -R 750 $ORACLE_BASE/diag/rdbms/$ORACLE_SID 
    
    

6.恢復controlfile
RMAN> startup nomount pfile='/tmp/pfile.ora';

Oracle instance started

Total System Global Area     167772160 bytes

Fixed Size                     1272600 bytes
Variable Size                 62915816 bytes
Database Buffers             100663296 bytes
Redo Buffers                   2920448 bytes

RMAN> restore controlfile from '/oradata/backup/ctl_NODE1_20160123_18_1';

Starting restore at 23-JAN-16
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=1 device type=DISK

channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:03
output file name=/oradata/node1new/control01.ctl
output file name=/u01/app/oracle/fast_recovery_area/node1new/control02.ctl
Finished restore at 23-JAN-16

SQL> alter database mount;
Database altered.


---restore datafile
RMAN>
run
{
set newname for datafile '/oradata/node1/system01.dbf'  to '/oradata/node1new/system01.dbf';
set newname for datafile '/oradata/node1/sysaux01.dbf'  to '/oradata/node1new/sysaux01.dbf';
set newname for datafile '/oradata/node1/undotbs01.dbf' to '/oradata/node1new/undotbs01.dbf';
set newname for datafile '/oradata/node1/users01.dbf'   to '/oradata/node1new/users01.dbf';
restore database ;
switch datafile all;
}

executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME

Starting restore at 23-JAN-16
Starting implicit crosscheck backup at 23-JAN-16
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=19 device type=DISK
Crosschecked 7 objects
Finished implicit crosscheck backup at 23-JAN-16

Starting implicit crosscheck copy at 23-JAN-16
using channel ORA_DISK_1
Finished implicit crosscheck copy at 23-JAN-16

searching for all files in the recovery area
cataloging files...
no files cataloged

using channel ORA_DISK_1

channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00002 to /oradata/node1new/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00004 to /oradata/node1new/users01.dbf
channel ORA_DISK_1: reading from backup piece /oradata/backup/full_NODE1_20160123_11_1
channel ORA_DISK_1: piece handle=/oradata/backup/full_NODE1_20160123_11_1 tag=TAG20160123T140220
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:25
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00001 to /oradata/node1new/system01.dbf
channel ORA_DISK_1: restoring datafile 00003 to /oradata/node1new/undotbs01.dbf
channel ORA_DISK_1: reading from backup piece /oradata/backup/full_NODE1_20160123_10_1
channel ORA_DISK_1: piece handle=/oradata/backup/full_NODE1_20160123_10_1 tag=TAG20160123T140220
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:45
Finished restore at 23-JAN-16

datafile 1 switched to datafile copy
input datafile copy RECID=5 STAMP=901898007 file name=/oradata/node1new/system01.dbf
datafile 2 switched to datafile copy
input datafile copy RECID=6 STAMP=901898007 file name=/oradata/node1new/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=7 STAMP=901898007 file name=/oradata/node1new/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=8 STAMP=901898007 file name=/oradata/node1new/users01.dbf



7.拷貝歸檔,恢復到最新的時間點

[
[email protected]
arch]$ cp *.dbf  /oradata/arch1/
[[email protected] node1new]$ env|grep SID
ORACLE_SID=node1new
[[email protected] ~]$ rman target /

Recovery Manager: Release 10.2.0.5.0 - Production on Tue Aug 6 00:40:26 2013

Copyright (c) 1982, 2007, Oracle.  All rights reserved.

connected to target database: ROGER (DBID=2525832133, not open)

8.註冊歸檔日誌
RMAN> catalog start with '/oradata/arch1';

using target database control file instead of recovery catalog
searching for all files that match the pattern /oradata/arch1

List of Files Unknown to the Database
=====================================
File Name: /oradata/arch1/1_27_901846980.dbf
File Name: /oradata/arch1/1_29_901846980.dbf
File Name: /oradata/arch1/1_37_901846980.dbf
File Name: /oradata/arch1/1_16_901846980.dbf
File Name: /oradata/arch1/1_32_901846980.dbf
File Name: /oradata/arch1/1_26_901846980.dbf
File Name: /oradata/arch1/1_24_901846980.dbf
File Name: /oradata/arch1/1_25_901846980.dbf
File Name: /oradata/arch1/1_33_901846980.dbf
File Name: /oradata/arch1/1_38_901846980.dbf
File Name: /oradata/arch1/1_23_901846980.dbf
File Name: /oradata/arch1/1_20_901846980.dbf
File Name: /oradata/arch1/1_31_901846980.dbf
File Name: /oradata/arch1/1_30_901846980.dbf
File Name: /oradata/arch1/1_21_901846980.dbf
File Name: /oradata/arch1/1_34_901846980.dbf
File Name: /oradata/arch1/1_36_901846980.dbf
File Name: /oradata/arch1/1_22_901846980.dbf
File Name: /oradata/arch1/1_28_901846980.dbf
File Name: /oradata/arch1/1_18_901846980.dbf
File Name: /oradata/arch1/1_35_901846980.dbf
File Name: /oradata/arch1/1_19_901846980.dbf
File Name: /oradata/arch1/1_17_901846980.dbf

Do you really want to catalog the above files (enter YES or NO)? yes
cataloging files...
cataloging done

List of Cataloged Files
=======================
File Name: /oradata/arch1/1_27_901846980.dbf
File Name: /oradata/arch1/1_29_901846980.dbf
File Name: /oradata/arch1/1_37_901846980.dbf
File Name: /oradata/arch1/1_16_901846980.dbf
File Name: /oradata/arch1/1_32_901846980.dbf
File Name: /oradata/arch1/1_26_901846980.dbf
File Name: /oradata/arch1/1_24_901846980.dbf
File Name: /oradata/arch1/1_25_901846980.dbf
File Name: /oradata/arch1/1_33_901846980.dbf
File Name: /oradata/arch1/1_38_901846980.dbf
File Name: /oradata/arch1/1_23_901846980.dbf
File Name: /oradata/arch1/1_20_901846980.dbf
File Name: /oradata/arch1/1_31_901846980.dbf
File Name: /oradata/arch1/1_30_901846980.dbf
File Name: /oradata/arch1/1_21_901846980.dbf
File Name: /oradata/arch1/1_34_901846980.dbf
File Name: /oradata/arch1/1_36_901846980.dbf
File Name: /oradata/arch1/1_22_901846980.dbf
File Name: /oradata/arch1/1_28_901846980.dbf
File Name: /oradata/arch1/1_18_901846980.dbf
File Name: /oradata/arch1/1_35_901846980.dbf
File Name: /oradata/arch1/1_19_901846980.dbf
File Name: /oradata/arch1/1_17_901846980.dbf


9.怎麼找到這個點?

col SEQUENCE# format a40;
col name format a70;
SQL> col first_change# clear;
SQL> col next_change# clear;
SQL> select SEQUENCE#,FIRST_CHANGE#,NEXT_CHANGE#,name from v$archived_log where name like '/oradata/arch%' order by 2;

SEQUENCE# FIRST_CHANGE# NEXT_CHANGE# NAME
-----------------------------------------------------------------
     16       215824       215997 /oradata/arch/1_16_901846980.dbf
     17       215997       216209 /oradata/arch/1_17_901846980.dbf
     18       216209       216218 /oradata/arch/1_18_901846980.dbf
     19       216218       216227 /oradata/arch/1_19_901846980.dbf
     20       216227       216235 /oradata/arch/1_20_901846980.dbf
     21       216235       216833 /oradata/arch/1_21_901846980.dbf
     22       216833       216930 /oradata/arch/1_22_901846980.dbf
     23       216930       225589 /oradata/arch/1_23_901846980.dbf
     24       225589       226527 /oradata/arch/1_24_901846980.dbf
     25       226527       226530 /oradata/arch/1_25_901846980.dbf
     26       226530       226533 /oradata/arch/1_26_901846980.dbf
     27       226533       226536 /oradata/arch/1_27_901846980.dbf
     28       226536       226539 /oradata/arch/1_28_901846980.dbf
     29       226539       226542 /oradata/arch/1_29_901846980.dbf
     30       226542       226562 /oradata/arch/1_30_901846980.dbf
     31       226562       226860 /oradata/arch/1_31_901846980.dbf
     32       226860       226881 /oradata/arch/1_32_901846980.dbf
     33       226881       249787 /oradata/arch/1_33_901846980.dbf
     34       249787       249883 /oradata/arch/1_34_901846980.dbf
     35       249883       249892 /oradata/arch/1_35_901846980.dbf
     36       249892       249901 /oradata/arch/1_36_901846980.dbf
     37       249901       249909 /oradata/arch/1_37_901846980.dbf
     38       249909       249939
/oradata/arch/1_38_901846980.dbf
    
SQL>

RMAN>  run {
set until scn 249939;
sql 'alter database datafile 1,2,3,4 online';
recover database skip forever tablespace users01;
}

相關推薦

oracle drop/truncate table 恢復

4. 修改pfile node1new.__db_cache_size=335544320 node1new.__java_pool_size=4194304 node1new.__large_pool_size=4194304 node1new.__oracle_base='/u01/app/oracle'

Oracle 資料庫誤truncate table恢復過程

  北京某國企客戶 Oracle 11g R2 資料庫誤truncate table CM_CHECK_ITEM_HIS,表資料丟失,業務查詢到該表時報錯,此時發現數據庫的備份不能用,表資料無法查詢。   客戶Oracle 11g R2 資料庫誤truncate tab

oracle drop 表後 恢復

1、查看回收站中表     select object_name,original_name,partition_name,type,ts_name,createtime,droptime from recyclebin;   2、恢復表 SQL>flashback tab

Oracle Drop表並未直接刪除 drop table xx purge

locate 清除 執行 keep storage 取消 ack 語句 acl drop表 執行drop table xx 語句 drop後的表被放在回收站(user_recyclebin)裏,而不是直接刪除掉。這樣,回收站裏的表信息就可以被恢復,或徹底清除。

[20180627]truncate table的另類恢復.txt

檢查 環境 2-0 www. com output .html access htm [20180627]truncate table的另類恢復.txt--//前幾天看鏈接http://www.xifenfei.com/2018/06/truncate-table-reco

SQL Server數據恢復準備之TRUNCATE TABLE理解

data 取出 發生 ada ESS completed contact ces zhang 當truncate table發生時,如何進行恢復,相信大部分人都會選擇通過還原備份到truncate table前,然後將數據重新導入正式表中。那麽在SQL Server中是不是

oracledrop truncate delete的區別

一、delete 1、delete是DML,執行delete操作時,每次從表中刪除一行,並且同時將該行的的刪除操作記錄在redo和undo表空間中以便進行回滾(rollback)和重做操作,但要注意表空間要足夠大,需要手動提交(commit)操作才能生效,可以通過rollback撤消操作。

oracle容災之truncate資料恢復

在我的另外幾篇文章中,介紹了關於資料庫閃回的一些內容,對於drop和delete的資料閃回。對於truncate,可能有一些資料庫知識的應該會知道,在正常邏輯中,如果我們將表truncate掉了,是找不回來了,TRUNCATE TABLE 是一次性地從表中刪除所有的資料並不把單獨的刪除操

DROP TABLETRUNCATE TABLE和DELETE的區別

相同點 TRUNCATE TABLE和DELETE都可以刪除整個資料庫表的記錄 不同點 DELETE DML語言 可以回退 可以有條件的刪除DELETE FROM 表名 WHERE 條件 TRUNCATE TABLE DDL語言 無法回退 預設

oracledrop truncate delete的區別

一、delete 1、delete是DML,執行delete操作時,每次從表中刪除一行,並且同時將該行的的刪除操作記錄在redo和undo表空間中以便進行回滾(rollback)和重做操作,但要注意表空間要足夠大,需要手動提交(commit)操作才能生效,可以通過rollb

oracle droptruncate和delete的區別

(1)DELETE語句執行刪除的過程是每次從表中刪除一行,並且同時將該行的刪除操作作為事務記錄在日誌中儲存以便進行進行回滾操作。    TRUNCATE TABLE 則一次性地從表中刪除所有的資料並不把單獨的刪除操作記錄記入日誌儲存,刪除行是不能

oracle delete from table 誤刪資料的恢復

oracle delete from table 誤刪資料的恢復: select log_mode,open_mode,flashback_on from v$database;        --檢視閃回功能是否開啟(NO 表示未開啟;Y

Oracle DROPtable以及Truncate table 的簡單測試

1. 一個使用者庫 有一個業務表比較大 大小是 49g 表的行數為:121546147 一億兩千萬行 製作一個虛擬機器的快照測試一下 drop table 和 truncate table的效能差距 2. 首先是drop table  測試時間為:    3.

Oracle資料庫 drop表之後恢復(包括表內資料)

drop表查詢:select object_name,original_name,partition_name,type,ts_name,createtime,droptime from recyclebin;恢復drop掉的表:  (person=表名)flashback 

使用ODU恢復oracletruncate的表資料

1。ODU 介紹       ODU全稱為Oracle Database Unloader,是類似於Oracle的DUL的軟體,用於直接從Oracle資料庫的資料檔案中獲取表資料。在各種原因造成的資料庫不能開啟時,用於搶救資料,最大限度地減少資料丟失。       支援的O

ORACLE 儲存過程不能用truncate table xxx解決方法

ORACLE 儲存過程不能用truncate table xxx CREATE OR REPLACE PROCEDURE XM_MRP_YFKUWEI1 AS /* 工作日每天0點30,要HOLD住研發倉(將F41021的批次狀態碼=E,條件F0005的研發庫位); */ 

ORACLE閃回和恢復DROP掉的表

 --恢復刪除的表DROP TABLE drop_table; 1.用如下語句查詢到這個表還在Oracle回收站中: SELECT * FROM user_recyclebin WHERE original_name='drop_table'; 2.用以下語句進行恢復: FLASHBACK TABLE dro

oracle droptruncate 分割槽表分割槽注意

由於客戶某表月初通過ogg匯入資料較多,ogg未能完成。因此決定使用資料泵臨時匯入。 停止ogg,刪除表分割槽資料。通過delete加條件篩選資料,發現數據量較大,嘗試刪除,執行很長時間後,undo不夠用報錯。 決定,truancate該分割槽。查看錶的分割槽,發現存

oracle truncate table recover(oracle 如何拯救誤操作truncate的表)

 生產上肯定是容易腦袋發熱,truncate一張表,立馬的心跳加速,眼神也不迷糊了,搞錯了,完了…… 那麼,truncate表後,能不能進行恢復? truncate操作是比較危險的操作,不記錄redo,也不能通過閃回查詢來找回資料,但是隻要段所佔用的塊沒有全部被重新佔用的情況下,我們還是可以通過一些

SQL中truncate table和delete的區別

約束 重置 mar 功能 語句 str foreign ack span TRUNCATE TABLE 在功能上與不帶 Where 子句的 Delete 語句相同:二者均刪除表中的全部行。但 TRUNCATE TABLE 比 Delete 速度快,且使用的系統和事務日誌資源