Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Standard view
Full view
of .
Look up keyword
Like this
0 of .
Results for:
No results containing your search query
P. 1


Ratings: (0)|Views: 27|Likes:
Published by api-3728238

More info:

Published by: api-3728238 on Nov 28, 2009
Copyright:Attribution Non-commercial


Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less





Inside Oracle Database 10g
Oracle Database 10g: The Top 20 Features for DBAs
by Arup Nanda

Over the last 27 years, Oracle has made tremendous improvements in its core database product. Now, that product is not only the world's most reliable and performant database, but also part of a complete software infrastructure for enterprise computing. With each new release comes a sometimes dizzying display of new capabilities and features, sometimes leaving developers, IT managers, and even seasoned DBAs wondering which new features will benefit them most.

With the introduction of Oracle Database 10g, DBAs will have in their hands one of the most profound new releases ever from Oracle. So, DBAs
who take the time to understand the proper application of new Oracle technology to their everyday jobs will enjoy many time-saving, and ultimately,
money-saving new capabilities.

Oracle Database 10g offers many new tools that help DBAs work more efficiently (and perhaps more enjoyably), freeing them for more strategic,
creative endeavors\u2014not to mention their nights and weekends. Oracle Database 10g reallyis that big of a deal for DBAs.

Over the new 20 weeks, I will help you through the ins and outs of this powerful new release by presenting what I consider to be the top 20 new Oracle Database 10g features for database administration tasks. This list ranges from the rudimentary, such as setting a default tablespace for creating users, to the advanced, such as the new Automatic Storage Management feature.

In this series, I will provide brief, focused analyses of these interesting new tools and techniques. The goal is to outline the functions and benefits of
the feature so that you can put it into action in your environment as quickly as possible.
I welcome your thoughts, comments, and questions about this series. Enjoy!

Week 1\u2014Flashback Versions Query
Week 2\u2014Rollback Monitoring
Week 3\u2014Tablespace Management
Week 4\u2014Oracle Data Pump
Week 5\u2014Flashback Table
Week 6\u2014Automatic Workload Repository
Week 7\u2014SQL*Plus Rel 10.1
Week 8\u2014Automatic Storage Management
Week 9\u2014RMAN
Week 10\u2014Auditing

Week 11\u2014Wait Interface
Week 12\u2014Materialized Views
Week 13\u2014Enterprise Manager 10g
Week 14\u2014Virtual Private Database
Week 15\u2014Automatic Segment Management
Week 16\u2014Transportable Tablespaces
Week 17\u2014Automatic Shared Memory Management
Week 18\u2014ADDM and SQL Tuning Advisor
Week 19\u2014Scheduler
Week 20\u2014Best of the Rest

Release 2 Features AddendumNew!
Week 1
Get a Movie, Not a Picture: Flashback Versions Query
Immediately identify all the changes to a row, with zero setup required.

In Oracle9i Database, we saw the introduction of the "time machine" manifested in the form of Flashback Query. The feature allows the DBA to see
the value of a column as of a specific time, as long as the before-image copy of the block is available in the undo segment. However, Flashback
Query only provides a fixed snapshot of the data as of a time, not a running representation of changed data between two time points. Some
applications, such as those involving the management of foreign currency, may need to see the value data changes in a period, not just at two
points of time. Thanks to the Flashback Versions Query feature, Oracle Database 10gcan perform that task easily and efficiently.

Querying Changes to a Table
In this example, I have used a bank's foreign currency management application. The database has a table called RATES to record exchange rate
on specific times.
SQL> desc rates
----------------- -------- ------------

This table shows the exchange rate of US$ against various other currencies as shown in the CURRENCY column. In the financial services industry, exchange rates are not merely updated when changed; rather, they are recorded in a history. This approach is required because bank transactions can occur as applicable to a "past time," to accommodate the loss in time because of remittances. For example, for a transaction that occurs at 10:12AM but is effective as of 9:12AM, the applicable rate is that at 9:12AM, not now.

Up until now, the only option was to create a rate history table to store the rate changes, and then query that table to see if a history is available. Another option was to record the start and end times of the applicability of the particular exchange rate in the RATES table itself. When the change occurred, the END_TIME column in the existing row was updated to SYSDATE and a new row was inserted with the new rate with the END_TIME as NULL.

In Oracle Database 10g, however, the Flashback Versions Query feature may obviate the need to maintain a history table or store start and end times. Rather, using this feature, you can get the value of a row as of a specific time in the past with no additional setup. Bear in mind, however, that it depends on the availability of the undo information in the database, so if the undo information has been aged out, this approach will fail.

For example, say that the DBA, in the course of normal business, updates the rate several times\u2014or even deletes a row and reinserts it:

insert into rates values ('EURO',1.1012);
update rates set rate = 1.1014;
update rates set rate = 1.1013;
delete rates;
insert into rates values ('EURO',1.1016);
update rates set rate = 1.1011;

After this set of activities, the DBA would get the current committed value of RATE column by
SQL> select * from rates;
---- ----------

This output shows the current value of the RATE, not all the changes that have occurred since the first time the row was created. Thus using
Flashback Query, you can find out the value at a given point in time; but we are more interested in building an audit trail of the changes\u2014somewhat
like recording changes through a camcorder, not just as a series of snapshots taken at a certain point.

The following query shows the changes made to the table:

select versions_starttime, versions_endtime, versions_xid,
versions_operation, rate
from rates versions between timestamp minvalue and maxvalue

---------------------- ---------------------- ---------------- - ----------
01-DEC-03 03.57.12 PM 01-DEC-03 03.57.30 PM 0002002800000C61 I
01-DEC-03 03.57.30 PM 01-DEC-03 03.57.39 PM 000A000A00000029 U
01-DEC-03 03.57.39 PM 01-DEC-03 03.57.55 PM 000A000B00000029 U
01-DEC-03 03.57.55 PM
000A000C00000029 D
01-DEC-03 03.58.07 PM 01-DEC-03 03.58.17 PM 000A000D00000029 I
01-DEC-03 03.58.17 PM
000A000E00000029 U
Note that all the changes to the row are shown here, even when the row was deleted and reinserted. The VERSION_OPERATION column shows
what operation (Insert/Update/Delete) was performed on the row. This was done without any need of a history table or additional columns.

In the above query, the columns versions_starttime, versions_endtime, versions_xid, versions_operation are pseudo-columns, similar to other
familiar ones such as ROWNUM, LEVEL. Other pseudo-columns\u2014such as VERSIONS_STARTSCN and VERSIONS_ENDSCN\u2014show the
System Change Numbers at that time. The column versions_xid shows the identifier of the transaction that changed the row. More details about the
transaction can be found from the view FLASHBACK_TRANSACTION_QUERY, where the column XID shows the transaction id. For instance,
using the VERSIONS_XID value 000A000D00000029 from above, the UNDO_SQL value shows the actual statement.

WHERE XID = '000A000D00000029';

insert into "ANANDA"."RATES"("CURRENCY","RATE") values ('EURO','1.1013');
In addition to the actual statement, this view also shows the timestamp and SCN of commit and the SCN and timestamp at the start of the query,
among other information.
Finding Out Changes During a Period
Now, let's see how we can use the information effectively. Suppose we want to find out the value of the RATE column at 3:57:54 PM. We can issue:

select rate, versions_starttime, versions_endtime
from rates versions
between timestamp
to_date('12/1/2003 15:57:54','mm/dd/yyyy hh24:mi:ss')
and to_date('12/1/2003 16:57:55','mm/dd/yyyy hh24:mi:ss')

---------- ---------------------- ----------------------

This query is similar to the flashback queries. In the above example, the start and end times are null, indicating that the rate did not change during the time period; rather, it includes a time period. You could also use the SCN to find the value of a version in the past. The SCN numbers can be obtained from the pseudo-columns VERSIONS_STARTSCN and VERSIONS_ENDSCN. Here is an example:

select rate, versions_starttime, versions_endtime
from rates versions
between scn 1000 and 1001

Using the keywords MINVALUE and MAXVALUE, all the changes that are available from the undo segments is displayed. You can even give a specific date or SCN value as one of the end points of the ranges and the other as the literal MAXVALUE or MINVALUE. For instance, here is a query that tells us the changes from 3:57:52 PM only; not the complete range:

select versions_starttime, versions_endtime, versions_xid,
versions_operation, rate
from rates versions between timestamp
to_date('12/11/2003 15:57:52', 'mm/dd/yyyy hh24:mi:ss')

You're Reading a Free Preview

/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->