這篇文章主要講解了“數(shù)據(jù)庫中刪用戶刪表空間的操作還能恢復(fù)嗎”,文中的講解內(nèi)容簡單清晰,易于學(xué)習(xí)與理解,下面請大家跟著小編的思路慢慢深入,一起來研究和學(xué)習(xí)“數(shù)據(jù)庫中刪用戶刪表空間的操作還能恢復(fù)嗎”吧!
創(chuàng)新互聯(lián)建站長期為超過千家客戶提供的網(wǎng)站建設(shè)服務(wù),團(tuán)隊(duì)從業(yè)經(jīng)驗(yàn)10年,關(guān)注不同地域、不同群體,并針對(duì)不同對(duì)象提供差異化的產(chǎn)品和服務(wù);打造開放共贏平臺(tái),與合作伙伴共同營造健康的互聯(lián)網(wǎng)生態(tài)環(huán)境。為欽北企業(yè)提供專業(yè)的成都網(wǎng)站制作、網(wǎng)站建設(shè)、外貿(mào)網(wǎng)站建設(shè),欽北網(wǎng)站改版等技術(shù)服務(wù)。擁有10年豐富建站經(jīng)驗(yàn)和眾多成功案例,為您定制開發(fā)。
有一次在某微信群里,有人提問以下兩條操作還能恢復(fù)嗎?而且是在沒有開歸檔。緊接著又有人提問數(shù)據(jù)庫是否開了閃回?
drop user aaa cascade; drop tablespace asd including contents and datafiles;
PS:他這里沒有指明閃回是閃回查詢?閃回表?閃回?cái)?shù)據(jù)庫?那我們就從一個(gè)不了解閃回特性的角度來一一看這個(gè)問題(這里假設(shè)是這個(gè)用戶下就一張表)
下面是整個(gè)分析過程:
場景一、閃回查詢
SQL> create table aaa.a1(id number); Table created. SQL> insert into aaa.a1 values(3); 1 row created. SQL> commit; Commit complete. SQL> select dbms_flashback.get_system_change_number from dual; GET_SYSTEM_CHANGE_NUMBER ------------------------ 3575965 SQL> drop user aaa cascade; User dropped. SQL> select * from aaa.a1 as of scn 3575965; select * from aaa.a1 as of scn 3575965 * ERROR at line 1: ORA-00942: table or view does not exist
可以看出閃回查詢是無效的,其實(shí)你要是懂一點(diǎn)閃回查詢首先可以排除掉,因?yàn)殚W回查詢是基于undo的,而且undo受ddl影響的,drop操作并不會(huì)使用到undo表空間,所以基于undo的閃回查詢在這種場景并不能找回?cái)?shù)據(jù)。
場景二、閃回表(flashback table)
SQL> flashback table aaa.a1 to before drop; flashback table aaa.a1 to before drop * ERROR at line 1: ORA-01435: user does not exist
drop user cascade并不會(huì)把表放入回收站的,那么我們再怎么執(zhí)行flashback table也是于事無補(bǔ)。
最后我們再來嘗試一下閃回?cái)?shù)據(jù)庫,看看它是否能夠成為救命稻草。其實(shí)閃回?cái)?shù)據(jù)庫的前提條件就是開啟歸檔,那么抱歉這條路也行不通。
假設(shè)現(xiàn)在開了閃回?cái)?shù)據(jù)庫(flashback database,當(dāng)然包括開啟歸檔),那么我們誤刪的數(shù)據(jù)一定就能被找回嗎?
場景三、閃回?cái)?shù)據(jù)庫(一)
SQL> select dbms_flashback.get_system_change_number from dual; GET_SYSTEM_CHANGE_NUMBER ------------------------ 3574600 SQL> drop user aaa cascade; User dropped. SQL> drop tablespace asd including contents and datafiles; Tablespace dropped. SQL> shutdown immediate; Database closed. Database dismounted. ORACLE instance shut down. SQL> startup mount; ORACLE instance started. Total System Global Area 889389056 bytes Fixed Size 2258360 bytes Variable Size 574622280 bytes Database Buffers 306184192 bytes Redo Buffers 6324224 bytes Database mounted. SQL> flashback database to scn 3574600; //閃回到誤操作前 Flashback complete. SQL> alter database open read only; //以read only模式打開 Database altered. SQL> select * from aaa.a1; select * from aaa.a1 * ERROR at line 1: ORA-00376: file 10 cannot be read at this time ORA-01111: name for data file 10 is unknown - rename to correct file ORA-01110: data file 10: '/u01/app/oracle/product/11.2.0/db_1/dbs/UNNAMED00010'
這里說明一下閃回?cái)?shù)據(jù)庫的原理:flashbackdatabase用來將數(shù)據(jù)庫中的數(shù)據(jù)恢復(fù)到之前的某個(gè)時(shí)間點(diǎn),而非介質(zhì)恢復(fù)。這里的 drop tablespace including contents and datafiles(使用including datafile效果都相同),會(huì)將對(duì)應(yīng)的數(shù)據(jù)文件刪除。所以現(xiàn)在即便是開啟了閃回?cái)?shù)據(jù)庫特性也無濟(jì)于事。
那么要是在上面的情況下,我只執(zhí)行了drop usercascade命令,而沒有執(zhí)行drop tablespace including datafile(在閃回?cái)?shù)據(jù)庫模式下),結(jié)果又會(huì)有什么不同呢?
場景四、閃回?cái)?shù)據(jù)庫(二)
SQL> select dbms_flashback.get_system_change_number from dual; GET_SYSTEM_CHANGE_NUMBER ------------------------ 3581891 SQL> drop user db1 cascade; User dropped. SQL> shutdown immediate; Database closed. Database dismounted. ORACLE instance shut down. SQL> startup mount; ORACLE instance started. Total System Global Area 889389056 bytes Fixed Size 2258360 bytes Variable Size 574622280 bytes Database Buffers 306184192 bytes Redo Buffers 6324224 bytes Database mounted. SQL> flashback database to scn 3581891; Flashback complete. SQL> alter database open read only; Database altered. SQL> select * from db1.milktwo; ID NAME ---------- ---------------------- 33 kk 2 hh
感謝各位的閱讀,以上就是“數(shù)據(jù)庫中刪用戶刪表空間的操作還能恢復(fù)嗎”的內(nèi)容了,經(jīng)過本文的學(xué)習(xí)后,相信大家對(duì)數(shù)據(jù)庫中刪用戶刪表空間的操作還能恢復(fù)嗎這一問題有了更深刻的體會(huì),具體使用情況還需要大家實(shí)踐驗(yàn)證。這里是創(chuàng)新互聯(lián),小編將為大家推送更多相關(guān)知識(shí)點(diǎn)的文章,歡迎關(guān)注!
網(wǎng)頁題目:數(shù)據(jù)庫中刪用戶刪表空間的操作還能恢復(fù)嗎
網(wǎng)頁路徑:http://aaarwkj.com/article6/pcceog.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供品牌網(wǎng)站制作、網(wǎng)站制作、網(wǎng)站收錄、微信小程序、企業(yè)網(wǎng)站制作、面包屑導(dǎo)航
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)