OCP(11g)-----> oracle First In First Out (FIFO)/Last In First Out

maohaiqing0304發表於2013-04-29
 
oracle First In First Out (FIFO)/Last In First Out (LIFO)  .....
You discover that your Recycle Bin contains two tables with the same name, MY_TABLE. You also have a table named MY_TABLE in your schema. You execute the following statement:
FLASHBACK TABLE my_table TO BEFORE DROP RENAME TO my_table2;
What will be the result of executing this statement?
A. One of the tables is recovered from the Recycle Bin using a First In First Out (FIFO) approach.
B. One of the tables is recovered from the Recycle Bin using a Last In First Out (LIFO) approach.
C. Both the tables are recovered from the Recycle Bin with one table renamed to MY_TABLE2 and the other to a system-generated name.
D. None of the tables are recovered from the Recycle Bin, and the statement returns an error.
Answer: B
SQL> create table aa1 as select dict_code,dict_desc from base_dict;

表已建立。

已用時間:  00: 00: 00.06
SQL> desc aa1;
名稱                                                                         是否為空? 型別
-----------------------------------------------------------------------------------------------
DICT_CODE                                                               VARCHAR2(50)
DICT_DESC                                                               VARCHAR2(400)

SQL> create table aa as select * from tab;

表已建立。

已用時間:  00: 00: 00.14
SQL> drop table aa;      ----&gt該刪除的是tab模擬表

表已刪除。

已用時間:  00: 00: 00.07
SQL> rename aa1 to aa; 

表已重新命名。

已用時間:  00: 00: 00.04
SQL> drop table aa;   ---&gt該表是基於base_dict建立的表 

表已刪除。

已用時間:  00: 00: 00.01
SQL> sho recycle;
ORIGINAL NAME    RECYCLEBIN NAME                OBJECT TYPE  DROP TIME
---------------- ------------------------------ ------------ -------------------
AA               BIN$LdL8XIZ2T9q/VKY/co2S8A==$0 TABLE        2013-04-19:11:40:09
AA               BIN$LVSXxo8OTfyfxTFN+sw8Bg==$0 TABLE        2013-04-19:11:39:55
SQL> FLASHBACK TABLE aa to before drop rename to aa1;

閃回完成。

已用時間:  00: 00: 00.01

SQL> desc aa1;   ---------&gt返回的結果證明:recyclebin表2個相同的表閃回機制:後進先出
名稱                                                                   是否為空? 型別
-----------------------------------------------------------------------------------------------
DICT_CODE                                                                       VARCHAR2(50)
DICT_DESC                                                                       VARCHAR2(400)

SQL>當空間壓力出現時,Oracle會覆蓋些回收站物件從而自動回收表空間。Oracle根據先進先出的原則來選擇丟棄物件進行刪除,所以最先被丟棄的物件也最先被清除。而物件的清除僅僅是為了解決產生的空間壓力問題,所以會盡可能清除少的物件來滿足空間壓力的要求。這樣處理,既最大限度地保證了物件在回收站中的可用時間,又減少了Oracle在事物處理時的效能影響。

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/28602568/viewspace-759532/,如需轉載,請註明出處,否則將追究法律責任。

相關文章