QUESTION NO:230
thesamenameexistsintheschema.
YouqueryRECYCLEBINandfindmultipleentriesfortheSALES_EMPtableasfollows:Youthenissue thefollowingstatementtorecoverthetable:
SQL>FLASHBACK TABLE sales_emp To BEFORE DROP;
What would be the outcome of the precedent statement?
A.Itretrievesthelatestversionofthetablefromtherecyclebin
B.Itretrievestheoldestversionofthetablefromtherecyclebin
C.Itretrievestheversionofthetableforwhichundoinformationisavailable
D.Itreturnsanerrorbecausethetablenameisnotspecifiedasperthenamesinthe
OBJECT_NAMEcolumn
【题目示意】
此题考查有关于recyclebin回收站的相关知识。题目大意是,当前用户的recyclebin中有三个同名的对象,各个对象被删除的时间不同,通过flashback table闪回命令恢复对象会是怎样情况。
【解析】
回收站功能默认是开启的,即便是闪回功能是关闭状态。回收站是否启用是只是由“recyclebin”参数来控制,默认情况下,这个参数是启用的(on)。
查看recyclebin参数值:
SQL> show parameter recyclebin;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
recyclebin string on
如下创建对象并删除对象t1,查看recyclebin
SQL> select original_name,type,droptime from user_recyclebin;
ORIGINAL_NAME TYPE DROPTIME
-------------------------------- ------------------------- -------------------
T1 TABLE 2014-01-22:15:33:48
SQL> create table t1(id int);
Table created.
SQL> drop table t1;
Table dropped.
SQL> select original_name,type,droptime from user_recyclebin;
ORIGINAL_NAME TYPE DROPTIME
-------------------------------- ------------------------- -------------------
T1 TABLE 2014-01-22:15:45:05
T1 TABLE 2014-01-22:15:33:48
执行:flashback table 命令,可以看到droptime为2014-01-22:15:45:05的那条记录被恢复了。
SQL> flashback table t1 to before drop;
Flashback complete.
SQL> select original_name,type,droptime from user_recyclebin;
ORIGINAL_NAME TYPE DROPTIME
-------------------------------- ------------------------- -------------------
T1 TABLE 2014-01-22:15:33:48
【小结】
我们可以通过修改参数“recyclebin”为“off”来禁用回收站功能。这个参数既可以在使用“ALTER SYSTEM”命令修改,也可以使用“ALTER SESSION”命令进行修改。
session级别设置recyclebin参数为off时候,当切换用户即会话改变的时候,recyclebin会恢复为默认值。
System级别设置recyclebin为off是系统级别修改,将彻底禁用recyclebin功能。
通过本题可以继续扩展,当recyclebin中有相同名字的对象要purge(sql>purge objectname彻底删除)时候,只会删除droptime时间最早(即是彻底删除那个最早删除的那个版本),sql>purge recyclelin;清空当前用户的recyclebin。
还有需要注意的是,在sys用户下,因为sys用户的表空间为system,所以此时回收站recyclebin功能被禁用,即使参数值为on。
【答案】A
相关参考