1.What are the prerequisites for performing flashback transactions? (Choose all that apply)

1.What are the prerequisites for performing flashback transactions? (Choose all that apply) 
A.Supplemental log must be enabled
B.Supplemental log must be enabled for the primary key
C.Undo retention guarantee for the database must be configured
D.”EXECUTE “ permission on the DBMS_FLASHBACK package must be granted to the user 
答案:ABD
解析:这里问的是闪回事务的先觉条件
SQL> alter database add  SUPPLEMENTAL log data; --打开附加日志
Database altered.
SQL> alter database add SUPPLEMENTAL log data(primary key) columns; --打开带主键的附加日志
Database altered.
SQL> select supplemental_log_data_min,supplemental_log_data_pk,supplemental_log_data_ui from v$database; --查看状态
SUPPLEME SUP SUP
-------- --- ---
YES      YES NO
SQL> select versions_xid,versions_startscn,versions_operation,id,name from test versions between scn minvalue and maxvalue where id=1 --查看具体的xid和操作方式
VERSIONS_XID     VERSIONS_STARTSCN V         ID NAME
---------------- ----------------- - ---------- ----------------------------------------------
02001100A1120000           8338066 U          1 asdf
                                              1 ll
SQL> /
SQL> select undo_sql from flashback_transaction_query where xid='02001100A1120000'; --可以查到具体的撤回sql语句了
UNDO_SQL
--------------------------------------------------------------------------------
update "BK"."TEST" set "NAME" = 'll' where ROWID = 'AAAjvnAAHAAAACXAAA';
SQL> alter database drop SUPPLEMENTAL log data(primary key) columns; --关闭undo语句日志,这里注意需要反向关闭
SQL> alter database drop  SUPPLEMENTAL log data;
--这里已经查出来了,这个DBMS_FLASHBACK描述如下
Using DBMS_FLASHBACK, you can flash back to a version of the database at a specified wall-clock time or a specified system change number (SCN).
execute dbms_flashback.enable_at_time(sysdate-40/1440); --恢复之前的记录(这里需要注意只是针对该会话,恢复后进行对数据处理,如果退出重新登陆那么将恢复)
execute dbms_flashback.disable();--在执行完成后,必须进行disable,否则不能在执行enable_at_tim
select dbms_flashback.get_system_change_number() from dual; 8301691 --查询一下当前的scn号码    
execute dbms_flashback.enable_at_system_change_number(8301691); --闪回到那个scn上,新增加的行没有了
这里dbms_flashback还有其他方法,可以查文档,这里感觉AB也可以,D不是必须的      

你可能感兴趣的:(1z0-053(206道题))