- •About the Authors
- •Contents at a Glance
- •Contents
- •Table of Exercises
- •Introduction
- •Assessment Test
- •Answers to Assessment Test
- •What Is ASM?
- •Working with the ASM Instance
- •Overview of ASM Data Dictionary Views
- •Using ASM Storage
- •Using RMAN with ASM
- •Summary
- •Exam Essentials
- •Review Questions
- •Answers to Review Questions
- •Understanding the Oracle Database as It Relates to Backup and Recovery
- •Performing Oracle Offline Backups
- •Performing Oracle Online Backups
- •Backing Up the Control File
- •Summary
- •Exam Essentials
- •Review Questions
- •Answers to Review Questions
- •Performing Incomplete Recoveries
- •Performing Other Types of Recoveries
- •Summary
- •Exam Essentials
- •Review Questions
- •Answers to Review Questions
- •Why Use RMAN?
- •Exploring the RMAN Architecture
- •Connecting to RMAN
- •Configuring RMAN for Use
- •Backing Up Your Database with RMAN
- •Summary
- •Exam Essentials
- •Review Questions
- •Answers to Review Questions
- •Introducing the Recovery Catalog
- •Creating the Recovery Catalog User and Schema Objects
- •Using a Recovery Catalog
- •Maintaining the Recovery Catalog
- •Using the RMAN Virtual Private Catalog
- •Summary
- •Exam Essentials
- •Review Questions
- •Answers to Review Questions
- •RMAN Database-Recovery Basics
- •Using Image Copies to Recover Your Database
- •Other Basic Recovery Topics
- •Summary
- •Exam Essentials
- •Review Questions
- •Answers to Review Questions
- •Summary
- •Exam Essentials
- •Review Questions
- •Answers to Review Questions
- •Switching Between RMAN Incarnations
- •Overview of RMAN Database Duplication
- •Performing an RMAN Tablespace Point-in-Time Recovery
- •Summary
- •Exam Essentials
- •Review Questions
- •Answers to Review Questions
- •Overview of Flashback Technology
- •Using Automatic Undo Management
- •Using Flashback Technologies
- •Using Additional Flashback Operations
- •Summary
- •Exam Essentials
- •Review Questions
- •Answers to Review Questions
- •Diagnosing the Database
- •Managing Database Performance
- •Summary
- •Exam Essentials
- •Review Questions
- •Answers to Review Questions
- •Managing Memory
- •Managing Space
- •Managing Resources
- •Summary
- •Exam Essentials
- •Review Questions
- •Answers to Review Questions
- •Automating Tasks with the Scheduler
- •Exploring the Scheduler Architecture
- •Exploring Common Administration Tools
- •Using Scheduler Jobs
- •Using Scheduler Programs
- •Using Schedules
- •Creating Lightweight Jobs
- •Using Job Chains
- •Using Scheduler Windows
- •Creating and Using Job Classes
- •Using Advanced Scheduler Concepts to Prioritize Jobs
- •Using Scheduler Views
- •Summary
- •Exam Essentials
- •Review Questions
- •Answers to Review Questions
- •An Overview of Globalization Support
- •Using NLS Parameters
- •Using Datetime Datatypes
- •Using Linguistic Sorts and Searches
- •Summary
- •Exam Essentials
- •Review Questions
- •Answers to Review Questions
- •Lab 1.1: Creating an ASM Instance
- •Lab 1.2: Creating ASM Disk Groups
- •Lab 1.3: Using ASM Disk Groups from a Database
- •Lab 2.2: Putting the Database in ARCHIVELOG Mode
- •Lab 2.3: Executing a Manual Online (Hot) Backup
- •Lab 3.1: Executing a Time-Based Point-in-Time Recovery
- •Lab 3.2: Recovering from Control-File Loss with a Backup Control File
- •Lab 3.3: Recovering from Loss of the Current Online Redo Log
- •Lab 4.1: Creating an RMAN Offline Backup
- •Lab 4.2: Creating an RMAN Incremental Backup
- •Lab 4.3: Creating an Image-Copy Backup
- •Lab 5.1: Implementing RVPC
- •Lab 6.1: Restoring a Datafile Online
- •Lab 6.2: Performing a Change-Based Recovery with RMAN
- •Lab 6.3: Restoring a Control File from an Autobackup
- •Lab 7.1: Monitoring RMAN Backups
- •Lab 7.2: One of My Backups Is Missing!
- •Lab 8.1: Duplicating a Database Using Active Database Duplication
- •Lab 8.2: Duplicating a Database Using Backup-Based Duplication to a Different Point in Time
- •Lab 9.1: Using the Recycle Bin
- •Lab 9.3: Using Flashback Data Archive
- •Lab 10.1: Using Support Workbench to Report a Problem to Oracle Support
- •Lab 11.1: Exporting a Transportable Tablespace
- •Lab 11.2: Testing Resumable Space Allocation
- •Lab 11.3: Manually Configuring the SGA
- •Lab 12.1: Creating a Local External Job
- •Lab 12.2: Creating a Job Window
- •Lab 13.1: Using the Locale Builder to Create a New Linguistic Sort
- •Lab 13.2: Setting NLS Parameters
- •Lab 13.3: Performing Linguistic Sorts
- •What You’ll Find on the CD
- •System Requirements
- •Using the CD
- •Troubleshooting
- •Glossary
- •Index
Lab 9.1: Using the Recycle Bin |
737 |
SQL> select * from dupe_table; ID THE_DATE
---------- ---------
1 11-OCT-08
If you want to run this exercise again after the first successful run, you will need to perform these steps:
1.Shut down the auxiliary instance (now it’s a new database!).
2.Remove the spfile assigned to the auxiliary instance.
3.Mount the auxiliary instance with the Startup nomount command.
Lab 9.1: Using the Recycle Bin
This lab was created using Windows XP. However, it should also work using Unix (and in fact was tested using Linux). This lab shows you how to set up the Recycle Bin and use it to restore a dropped table. The overall steps are as follows: create a table, insert data into the table, enable the Recycle Bin, drop the table, restore the table from the Recycle Bin, and query the table to verify the contents.
1.Create the table.
SQL> create table recycle_test (x number, y varchar2(10)); Table created.
SQL>
2.Next, we’ll add some rows and commit the transaction.
SQL>
insert into recycle_test values (1, ‘row 1’); insert into recycle_test values (2, ‘row 2’); insert into recycle_test values (3, ‘row 3’); insert into recycle_test values (4, ‘row 4’); insert into recycle_test values (5, ‘row 5’); Commit;
SQL>
3.Then, enable the Recycle Bin for the session.
SQL> ALTER SESSION SET recyclebin = ON; Session altered.
738 Appendix A n Lab Exercises
4.Now drop the table.
SQL> drop table recycle_test; Table dropped.
5.Restore the table from the Recycle Bin.
SQL> flashback table recycle_test to before drop; Flashback complete.
6.Finally, query the table and verify the contents.
SQL> select * from recycle_test;
X |
Y |
---------- |
---------- |
1 |
row 1 |
2 |
row 2 |
3 |
row 3 |
4 |
row 4 |
5 |
row 5 |
Lab 9.2: Performing a More Complex
Flashback Query Analysis
This lab shows you how to perform a more complex analysis using the Flashback Query feature. We’ll create and populate a table, then step through adding rows and querying the table at various points in time to demonstrate the feature.
1.Create the table.
SQL> create table flashback_query_test (x number,
y varchar2(10), z date
); Table created.
2.Now insert five rows of data and commit.
SQL>
insert into flashback_query_test values (1, ‘row 1’, sysdate);
Lab 9.2: Performing a More Complex Flashback Query Analysis |
739 |
insert into flashback_query_test values (2, ‘row 2’, sysdate); insert into flashback_query_test values (3, ‘row 3’, sysdate); insert into flashback_query_test values (4, ‘row 4’, sysdate); insert into flashback_query_test values (5, ‘row 5’, sysdate); commit;
Commit complete.
3.Now query the table to view the results.
SQL> alter session set nls_date_format = ‘dd-mon-yy hh24:mi:ss’; Session altered.
SQL> select * from flashback_query_test;
X |
Y |
Z |
|
---------- |
---------- |
-------------------- |
|
1 |
row 1 |
21-nov-2008 13:48:51 |
|
2 |
row 2 |
21-nov-2008 13:48:51 |
|
3 |
row 3 |
21-nov-2008 |
13:48:51 |
4 |
row 4 |
21-nov-2008 |
13:48:51 |
5 |
row 5 |
21-nov-2008 |
13:48:51 |
SQL> |
|
|
|
4.Query the table, specifying a timestamp after the table was created but prior to inserting the first five rows:
SQL> select * from flashback_query_test as of timestamp(to_timestamp(
‘21-nov-2008 13:48:50’,’DD-MON-YYYY HH24:MI:SS’)); no rows selected
SQL>
5.Now insert five more rows, wait five minutes, then insert five more rows, then commit. The results should look similar to this:
insert into flashback_query_test values (6, ‘row 6’, sysdate); insert into flashback_query_test values (7, ‘row 7’, sysdate); insert into flashback_query_test values (8, ‘row 8’, sysdate); insert into flashback_query_test values (9, ‘row 9’, sysdate); insert into flashback_query_test values (10, ‘row 10’, sysdate); commit;
740 Appendix A n Lab Exercises
Wait here five minutes.
insert into flashback_query_test values (11, ‘row 11’, sysdate); insert into flashback_query_test values (12, ‘row 12’, sysdate); insert into flashback_query_test values (13, ‘row 13’, sysdate); insert into flashback_query_test values (14, ‘row 14’, sysdate); insert into flashback_query_test values (15, ‘row 15’, sysdate); commit;
SQL> select * from flashback_query_test;
X |
Y |
Z |
---------- |
---------- |
-------------------- |
1 |
row 1 |
21-nov-2008 13:48:51 |
2 |
row 2 |
21-nov-2008 13:48:51 |
3 |
row 3 |
21-nov-2008 13:48:51 |
4 |
row 4 |
21-nov-2008 13:48:51 |
5 |
row 5 |
21-nov-2008 13:48:51 |
6 |
row 6 |
21-nov-2008 13:50:00 |
7 |
row 7 |
21-nov-2008 13:50:00 |
8 |
row 8 |
21-nov-2008 13:50:00 |
9 |
row 9 |
21-nov-2008 13:50:00 |
10 |
row 10 |
21-nov-2008 13:50:00 |
11 |
row 11 |
21-nov-2008 13:55:00 |
12 |
row 12 |
21-nov-2008 13:55:00 |
13 |
row 13 |
21-nov-2008 13:55:00 |
14 |
row 14 |
21-nov-2008 13:55:00 |
15 |
row 15 |
21-nov-2008 13:55:00 |
15 rows selected.
SQL>
6.Now that you have different discrete insert times, you can run queries that show the state of the table at various points in time. Run an AS OF query that will show only rows 1 through 10, based on the timestamp that was inserted.
SQL> select * from flashback_query_test as of timestamp(to_timestamp(
‘21-nov-2008 13:51:00’,’DD-MON-YYYY HH24:MI:SS’));
X Y Z
---------- ---------- --------------------
1 row 1 21-nov-2008 13:48:51
Lab 9.2: Performing a More Complex Flashback Query Analysis |
741 |
2 row 2 21-nov-2008 13:48:51
3 row 3 21-nov-2008 13:48:51
4 row 4 21-nov-2008 13:48:51
5 row 5 21-nov-2008 13:48:51
6 row 6 21-nov-2008 13:50:00
7 row 7 21-nov-2008 13:50:00
8 row 8 21-nov-2008 13:50:00
9 row 9 21-nov-2008 13:50:00
10 row 10 21-nov-2008 13:50:00
10 rows selected.
SQL>
7.Now insert five more rows, but don’t commit. Run a query showing the new rows in the table, and then an AS OF query with a timestamp following the insert that shows that the data is not committed and not available for Flashback Query.
SQL>
insert into flashback_query_test values (16, ‘row 16’, sysdate); insert into flashback_query_test values (17, ‘row 17’, sysdate); insert into flashback_query_test values (18, ‘row 18’, sysdate); insert into flashback_query_test values (19, ‘row 19’, sysdate); insert into flashback_query_test values (20, ‘row 20’, sysdate);
SQL> select * from flashback_query_test;
X |
Y |
Z |
|
---------- |
---------- |
-------------------- |
|
1 |
row 1 |
21-nov-2008 13:48:51 |
|
2 |
row 2 |
21-nov-2008 13:48:51 |
|
3 |
row 3 |
21-nov-2008 13:48:51 |
|
4 |
row 4 |
21-nov-2008 13:48:51 |
|
5 |
row 5 |
21-nov-2008 13:48:51 |
|
6 |
row 6 |
21-nov-2008 13:50:00 |
|
7 |
row 7 |
21-nov-2008 13:50:00 |
|
8 |
row 8 |
21-nov-2008 13:50:00 |
|
9 |
row 9 |
21-nov-2008 13:50:00 |
|
10 |
row 10 |
21-nov-2008 |
13:50:00 |
11 |
row 11 |
21-nov-2008 |
13:55:00 |
12 |
row 12 |
21-nov-2008 |
13:55:00 |
742 Appendix A n Lab Exercises
13 row 13 21-nov-2008 13:55:00
14 row 14 21-nov-2008 13:55:00
15 row 15 21-nov-2008 13:55:00
16 row 16 21-nov-2008 14:00:00
17 row 17 21-nov-2008 14:00:00
18 row 18 21-nov-2008 14:00:00
19 row 19 21-nov-2008 14:00:00
20 row 20 21-nov-2008 14:00:00
20 rows selected.
SQL>
SQL> select * from flashback_query_test as of timestamp(to_timestamp(
‘21-nov-2008 14:05:00’,’DD-MON-YYYY HH24:MI:SS’));
X |
Y |
Z |
---------- |
---------- |
-------------------- |
1 |
row 1 |
21-nov-2008 13:48:51 |
2 |
row 2 |
21-nov-2008 13:48:51 |
3 |
row 3 |
21-nov-2008 13:48:51 |
4 |
row 4 |
21-nov-2008 13:48:51 |
5 |
row 5 |
21-nov-2008 13:48:51 |
6 |
row 6 |
21-nov-2008 13:50:00 |
7 |
row 7 |
21-nov-2008 13:50:00 |
8 |
row 8 |
21-nov-2008 13:50:00 |
9 |
row 9 |
21-nov-2008 13:50:00 |
10 |
row 10 |
21-nov-2008 13:50:00 |
11 |
row 11 |
21-nov-2008 13:55:00 |
12 |
row 12 |
21-nov-2008 13:55:00 |
13 |
row 13 |
21-nov-2008 13:55:00 |
14 |
row 14 |
21-nov-2008 13:55:00 |
15 |
row 15 |
21-nov-2008 13:55:00 |
15 rows selected.
SQL>
Lab 9.2: Performing a More Complex Flashback Query Analysis |
743 |
8.Commit and then requery, noting that the AS OF timestamp must be after the commit for you to see the committed data using Flashback Query.
SQL> commit;
SQL> select sysdate from dual; SYSDATE
--------------------
21-nov-2008 14:21:41
SQL> select * from flashback_query_test as of timestamp(to_timestamp(
‘21-nov-2008 14:21:41’,’DD-MON-YYYY HH24:MI:SS’));
X |
Y |
Z |
---------- |
---------- |
-------------------- |
1 |
row 1 |
21-nov-2008 13:48:51 |
2 |
row 2 |
21-nov-2008 13:48:51 |
3 |
row 3 |
21-nov-2008 13:48:51 |
4 |
row 4 |
21-nov-2008 13:48:51 |
5 |
row 5 |
21-nov-2008 13:48:51 |
6 |
row 6 |
21-nov-2008 13:50:00 |
7 |
row 7 |
21-nov-2008 13:50:00 |
8 |
row 8 |
21-nov-2008 13:50:00 |
9 |
row 9 |
21-nov-2008 13:50:00 |
10 |
row 10 |
21-nov-2008 13:50:00 |
11 |
row 11 |
21-nov-2008 13:55:00 |
12 |
row 12 |
21-nov-2008 13:55:00 |
13 |
row 13 |
21-nov-2008 13:55:00 |
14 |
row 14 |
21-nov-2008 13:55:00 |
15 |
row 15 |
21-nov-2008 13:55:00 |
16 |
row 16 |
21-nov-2008 14:00:00 |
17 |
row 17 |
21-nov-2008 14:00:00 |
18 |
row 18 |
21-nov-2008 14:00:00 |
19 |
row 19 |
21-nov-2008 14:00:00 |
20 |
row 20 |
21-nov-2008 14:00:00 |
20 rows selected. SQL>