Tải bản đầy đủ (.pdf) (10 trang)

OCA /OCP Oracle Database 11g A ll-in-One Exam Guide- P79 pptx

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (195.87 KB, 10 trang )

OCA/OCP Oracle Database 11g All-in-One Exam Guide
736
The Flashback Data Archive
The three flashback technologies discussed so far (Flashback Database, Flashback
Drop, and the various forms of Flashback Query) can be useful, but they all have
limited flashback capability. A Flashback Data Archive can be configured to guarantee
the ability to flash back a table to any time—perhaps to a time years ago. It can also
guarantee that data is removed when it has expired.
Architecturally, Flashback Data Archive requires one or more tablespaces, various
segments for each protected table, and a new background process: the FBDA process.
The DBA must create the tablespace(s) and the archive(s) within them, specifying a
retention period for each archive, and then nominate tables to be protected by an
archive. The necessary segments will be created automatically, and the FBDA will start
when required. Users and application software will not be aware of any change so far
as DML is concerned. Some DDL commands (such as DROP and TRUNCATE) will
not be usable against protected tables, as they would remove information from the
data dictionary needed to interpret information in the archive. Flashback query
commands (such as a SELECT with the AS OF clause) will execute successfully
against versions of the table within the time frame specified for the archive protecting
the table.
To use the Total Recall facility, implemented by Flashback Data Archives, first
create a tablespace. It is technically possible to create the archive(s) in a preexisting
tablespace, but it makes sense to separate them from regular data. Then create the
archive, specifying a tablespace, a retention time, and (optionally) a quota. For
example,
create flashback archive default hrarch tablespace fbda1
quota 10g retention 5 year;
This command includes the DEFAULT keyword, which means that it will be used
as the archive for all tables unless specified otherwise. The default archive can also be
set later:
alter flashback archive hrarch set default;


The QUOTA clause limits the space the archive can occupy in the tablespace. If an
archive fills, more space can be added either in the original tablespace or in another
tablespace. For example, this command will extend the archive into another tablespace:
alter flashback archive hrarch add tablespace fbda2 quota 10g;
It is also possible to adjust the retention:
alter flashback archive hrarch modify retention 7 year;
Data is removed from an archive automatically by the FBDA background process
once it is older than the nominated retention period, but it can be removed manually
before the period has expired. For example,
Chapter 19: Flashback
737
PART III
alter flashback archive hrarch
purge before timestamp to_timestamp('01-01-2009','dd-mm-yyyy');
As there will often be legal implications to the ability to manage an archive, it is
protected by privileges. The FLASHBACK ARCHIVE ADMINISTER system privilege
grants the ability to create, alter, or drop an archive, and control the retention and
purging. You must grant FLASHBACK ARCHIVE on the archive to a user who will
nominate tables to be archived:
grant flashback archive administer to fbdaadmin;
grant flashback archive on hrarch to hr;
Finally, to enable archive protection for a table, use this command:
alter table hr.employees flashback archive hrarch;
There are three data dictionary views that document the Flashback Data Archive
configuration:
• DBA_FLASHBACK_ARCHIVE Describes the configured archives.
• DBA_FLASHBACK_ARCHIVE_TS Shows the quotas assigned per archive per
tablespace.
• DBA_FLASHBACK_ARCHIVE_TABLES Lists the tables for which archiving is
enabled.

Exercise 19-5: Create a Flashback Data Archive In this exercise you will
investigate the structures of a Flashback Data Archive.
1. Create a tablespace to be used for the Flashback Data Archive:
create tablespace fda datafile 'fda1.dbf' size 10m;
2. Create a Flashback Data Archive in the tablespace, with a retention of seven
years:
create flashback archive fla1 tablespace fda retention 7 year;
3. Create a schema to use for this exercise, and grant it the DBA role:
grant dba to fbdauser identified by fbdauser;
4. Grant the user the necessary privilege on the archive:
grant flashback archive on fla1 to fbdauser;
5. Connect as the FBDAUSER. Create a table, and enable the Flashback Data
Archive for this table:
connect fbdauser/fbdauser
create table t1 as select * from all_users;
alter table t1 flashback archive fla1;
6. Run these queries to determine the objects created by the archive. You may
have to wait several minutes, because the objects are not created immediately.
OCA/OCP Oracle Database 11g All-in-One Exam Guide
738
The illustration shows an example of the result, but the names will be unique
to your environment.
select object_name,object_type from user_objects;
select segment_name,segment_type from dba_segments
where tablespace_name='FDA';
7. Perform some DML against the protected table:
delete from t1;
commit;
8. Perform a flashback query against the protected table using standard flashback
query syntax, and then query the history table in the archive. The history table’s

name will have been displayed in Step 6. This illustration shows this step:
9. Attempt some DDL commands against the protected table:
alter table t1 drop column created;
truncate table t1;
drop table t1;
Chapter 19: Flashback
739
PART III
Connect AS SYSDBA, and attempt these:
drop user fbdauser cascade;
drop tablespace fda including contents and datafiles;
Note that these commands all generate errors related to the existence of the
archive and the protected table.
10. Remove the archive protection from the table:
alter table fbdauser.t1 no flashback archive;
11. Drop the Flashback Data Archive:
drop flashback archive fla1;
12. Rerun all the commands from Step 9.
Two-Minute Drill
Restore Dropped Tables from the Recycle Bin
• Dropped tables can be restored with FLASHBACK TABLE <table_name> TO
BEFORE DROP, if the space they occupy has not been reused.
• Flashback drop cannot function if the owning schema or the tablespace has
been dropped.
• Dependent indexes, triggers, and grants will also be restored, as will all
constraints except foreign key constraints.
• Dropped tables can be viewed, but you cannot perform DML or DDL against
them.
• Space occupied by dropped objects does not impact on quotas or trigger space
shortage alerts.

Perform Flashback Query
• Flashback Query relies on data in the undo segments.
• The AS OF clause must be used to give access to the pseudocolumns that
identify different versions of a row.
• The point to which the flashback should go can be specified as a timestamp or
an SCN.
Use Flashback Transaction
• The SELECT ANY TRANSACTION and FLASHBACK ANY TABLE privileges
must be granted to users who will use the flashback transaction facility.
• Transactions can be viewed in the FLASHBACK_TRANSACTION_QUERY
view, the UNDO_SQL column being a construction of a statement to reverse
the change.
OCA/OCP Oracle Database 11g All-in-One Exam Guide
740
• A transaction flashback may not succeed, because of conflicts caused
(typically) by constraint violations.
Perform Flashback Table Operations
• A table flashback attempts to reverse all changes applied to one or more tables.
• The necessary changes, no matter over what time or how many tables, are
applied as one transaction.
• Row movement must be enabled on tables before attempting a table flashback.
Configure and Monitor Flashback Database and Perform
Flashback Database Operations
• A database flashback is functionally equivalent to an incomplete recovery.
• Flashback logs exist in the flash recovery area, and the flashback buffer exists
in the shared pool; both are automatically managed.
• A database flashback operation is accomplished in mount mode and
terminated with a RESETLOGS.
• Both flashback log files and redo log files are needed during a flashback. The
database must be running in archivelog mode.

Set Up and Use a Flashback Data Archive
• An archive exists in one or more tablespaces.
• Once a table is nominated for archiving, some DDL commands will no longer
be possible.
• The FBDA background process captures before-images of rows and saves them to
the archive, and purges the archive of data that has passed its retention period.
Self Test
1. Under which of these circumstances might Flashback Database be of use?
(Choose the best answer.)
A. To recover a dropped table
B. To recover a dropped schema
C. To recover a damaged datafile
D. To reverse a bad transaction
E. All of the above
Chapter 19: Flashback
741
PART III
2. Which of the following is correct about Flashback Database? (Choose two
correct answers.)
A. You should set the FLASHBACK_BUFFER_SIZE parameter.
B. You must create the flashback log files.
C. You must set the DB_RECOVERY_FILE_DEST parameter.
D. You must issue ALTER SYSTEM FLASHBACK ON.
E. You must issue ALTER DATABASE FLASHBACK ON.
3. Why is archivelog mode required to enable Flashback Database? (Choose the
best answer.)
A. Because the redo log data is needed to reverse changes
B. To recover to an exact time after flashback
C. Because ARCn processes are needed to write flashback data
D. Because archivelog mode is optional, not required

4. What state must the database be in to turn on the Flashback Database feature?
(Choose the best answer.)
A. Shutdown
B. Nomount
C. Mount
D. Open
5. Which of the following commands is not necessary for a Flashback Database
operation? (Choose all that apply.)
A. Alter database open readonly
B. Alter database open resetlogs
C. Flashback database to . . .
D. Recover database until . . .
E. Shutdown
F. Startup mount
6. What tool(s) can be used to perform a database flashback? (Choose the best
answer.)
A. Database Control and RMAN
B. Database Control and SQL*Plus
C. RMAN and SQL*Plus
D. Database Control, RMAN, and SQL*Plus
OCA/OCP Oracle Database 11g All-in-One Exam Guide
742
7. You have set the DB_FLASHBACK_RETENTION_TARGET to one day, but the
flash recovery area does not have room for this much flashback data. What
will happen? (Choose the best answer.)
A. The database will hang until space is freed up.
B. It will depend on whether AUTOEXTEND has been enabled for the flash
recovery area.
C. The database will continue to function, but flashback operations may fail.
D. If there are any backups in the flash recovery area not needed according

the retention policy, they will be automatically removed.
8. A user error has occurred, but the effects are limited to one tablespace. You
want to flash back this one tablespace, but not the others. What must you do?
(Choose the best answer.)
A. Execute ALTER TABLESPACE . . . FLASHBACK OFF for all the other
tablespaces, then flash back the database.
B. Take the other datafiles offline, flash back the database, and bring the
other datafiles online.
C. Flash back the whole database, then do complete recovery of the other
tablespaces.
D. It is not possible to flash back one tablespace and leave the rest of the
database current.
9. You have enabled Flashback Database, but you suspect that flashback logging
is impacting adversely on performance. What could you do? (Choose the best
answer.)
A. Reduce the DB_FLASHBACK_RETENTION_TARGET parameter.
B. Tune the frequency of RVWR writes.
C. Stop flashback logging for some tablespaces.
D. Investigate the flashback log multiplexing and archiving strategy.
E. Tune the flashback buffer.
10. When you drop a table, what objects will go into the recycle bin? (Choose two
answers.)
A. The table
B. Grants on the table
C. Indexes on the table
D. All constraints on the table
E. All constraints on the table except foreign key constraints
11. After dropping a table, how can you access the rows within it? (Choose the
best answer.)
A. Query the table using the AS OF syntax.

Chapter 19: Flashback
743
PART III
B. Query the table using the BEFORE DROP syntax.
C. Query the table using its recycle bin name.
D. You can’t query it until it has been recovered.
12. If a table has been dropped and then another table created with the same
name, which of the following statements are correct? (Choose two answers.)
A. You can rename the new table, before you flash back the dropped one.
B. You can flash back the dropped table, if you specify a new name for it.
C. You can flash back the dropped table into a different schema.
D. You must drop the new table before flashing back the old one.
13. Under which of the following circumstances will Flashback Drop work?
(Choose the best answer.)
A. When a table has been truncated
B. When a table has been purged
C. When a user has been dropped
D. When an index has been dropped
E. None of the above
14. There are two tables in the recycle bin with the same original name. What will
happen if you issue a FLASHBACK TABLE <original_name> TO BEFORE DROP
command? (Choose the best answer.)
A. The command will return an error.
B. The oldest recycle bin table will be recovered.
C. The newest recycle bin table will be recovered.
D. You can’t have two tables in the recycle bin with the same original name.
15. If a Flashback Table operation violates a constraint, what will happen?
(Choose the best answer.)
A. The row concerned will not be flashed back, but the rest of the operation
will succeed.

B. The flashback operation will hang until the problem is fixed.
C. The flashback operation will be rolled back.
D. You must disable constraints before a table flashback.
16. What is the best technique to flash back two tables in a foreign key
relationship? (Choose the best answer.)
A. Flash back the child table, then the parent table.
B. Flash back the parent table, then the child table.
C. Flash back both tables in one operation.
D. This is not an issue—foreign key constraints are not protected by
flashback.
OCA/OCP Oracle Database 11g All-in-One Exam Guide
744
17. Why and when must you enable row movement on a table before a flashback
operation? (Choose the best answer.)
A. Flashback Drop requires row movement, because all the rows in the table
will have different object numbers.
B. Flashback Query requires row movement, because the rows will have new
ROWIDs picked up from the undo segment.
C. Flashback Transaction requires row movement, because any affected rows
may be moved as the transaction is reversed.
D. Flashback Table requires row movement, because any affected rows may be
moved as the changes are reversed.
18. Which process is responsible for writing before-images of rows to a Flashback
Data Archive? (Choose the best answer.)
A. FBDA, Flashback Data Archiver Process
B. RVWR, Recovery Writer
C. CTWR, Change Tracking Writer
D. ARCn, Archiver process
19. Which of these operations cannot be executed against a table for which
archiving has been enabled? (Choose all correct answers.)

A. DROP
B. TRUNCATE
C. Add a column
D. Drop a column
E. None of the above
Self Test Answers
1. þ B. The only way to recover a dropped schema (other than incomplete
recovery) is Flashback Database.
ý A, C, D, and E. No flashback technology will help with physical
corruption, so C and E are wrong. A would be better fixed with Flashback
Table, and D with Flashback Transaction.
2. þ C and E. The flash recovery area must be configured, and flashback
enabled within the database.
ý A, B, and D. There is no such parameter as FLASHBACK_BUFFER_SIZE,
and the flashback logs are created automatically, so A and B are wrong.
Remember that flashback is an attribute of the database, not the instance, so
D is also wrong.
Chapter 19: Flashback
745
PART III
3. þ B. Flashback is only approximate; redo is needed to reach the precise
point required—so B is correct.
ý A, C, and D. A is wrong because redo can never be used to reverse
changes, only to redo them. C is wrong because the flashback data is written
by the RVWR process, not by the archiver processes. D is wrong because
archivelog mode is necessary.
4. þ C. Mount mode is necessary.
ý A, B, and D. As with the transition to archivelog mode, the database must
be mounted.
5. þ A and D. These steps are optional (but possibly useful).

ý B, C, E, and F. These steps are all required.
6. þ D. All three tools are usable.
ý A, B, and C. A database flashback can be initiated with SQL*Plus, or
RMAN, or Database Control.
7. þ C. The retention target is only a target, and Oracle will continue to
function even if it cannot be met—but your flashbacks may fail.
ý A, B, and D. A is what happens if it is not possible to archive logs. B is an
attribute that can be applied to datafiles, not the flash recovery area. D will
only happen if you instruct RMAN to do it.
8. þ D. One tablespace cannot be flashed back (though a TSPITR operation
would give that result).
ý A, B, and C. A restricts tablespaces from generating flashback data. B and
C can’t work because the other datafiles would not be synchronized.
9. þ C. This might reduce the workload involved in flashback logging.
ý A, B, D, and E. A will not have an effect on performance, only on how far
you can flash back. B and E are impossible—Oracle controls these. D is wrong
because flashback logs cannot be multiplexed or archived.
10. þ A and C. The only items that go into the recycle bin are the table and its
indexes.
ý B, D, and E. Grants are preserved, but they remain in the data dictionary.
The same is true of constraints, except for foreign key constraints, which are
dropped.
11. þ C. You can query the table using its system-generated name.
ý A, B, and D. AS OF is the syntax for flashback query, and BEFORE DROP
is the syntax to flash back the drop.

×