BC remote Oracle DBA - Call (800) 766-1884
Free Oracle Tips

Oracle Consulting Oracle Training Development
Oracle Training
SQL Tuning Consulting
Oracle Tuning Consulting
Data Warehouse Consulting
Oracle Project Management
Oracle Security Assessment
Unix Consulting
Burleson Books
Burleson Articles
Burleson Web Courses
Burleson Qualifications
Oracle Internals Magazine
Oracle Links
Oracle Monitoring
Remote Support Benefits
Remote Plans & Prices
Our Automation Strategy
What We Monitor
Oracle Apps Support
Print Our Brochure
Contact Us (e-mail)
Oracle Job Opportunities
Oracle Consulting Prices





   

 

 

 

 

 

Oracle Row Level Flashback Features

Oracle Tips by Burleson Consulting

This is an excerpt from "Oracle 10g New Features for Administrators" by Ahmed Baraka.

The value of the UNDO_RETENTION parameter determines the length of time your users can flashback their queries.

Flashback Query (SELECT…AS OF)

SELECT * FROM persons AS OF TIMESTAMP
TO_TIMESTAMP('2004-07-04 08:05:00', 'YYYY-MM-DD
HH:MI:SS') WHERE NAME = 'ALAPATI'

Flashback Versions Query

When you issue a SELECT statement using the VERSIONS clause, Oracle will return the different committed versions of the same row between two SCNs or two timestamps.

VERSIONS BETWEEN
{SCN | TIMESTAMP} start|MINVALUE AND
end|MAXVALUE
[AS OF {SCN|TIMESTAMP expr}]

Here is a brief explanation of pseudocolumns that will be part of the flashback versions query output:

VERSIONS_STARTSCN and VERSIONS_STARTTIME  - This pseudocolumn tells you the SCN and timestamp when this particular row was first created.

VERSIONS_ENDSCN and VERSIONS_ENDTIME - These pseudocolumns tell you when this particular row expired.

VERSIONS_OPERATION - This pseudocolumn provides you with information as to the type of DML activity that was performed on the particular row. The DML activities are indicated by letters: I stands for insert, D for delete, and U for update.

VERSIONS_XID - This pseudocolumn stands for the unique transaction identifier of the transaction that resulted in this row version.

Note: If the VERSIONS_STARTSCN and the VERSIONS_STARTTIME are NULL, then the row was created before the lower bound specified by your BETWEEN clause.

Note: If the VERSIONS_ENDSCN and the VERSIONS_ENDTIME are NULL, this means that this row version is current when you tried to use the Flashback Versions Query operation, or the row was part of a delete operation.

Note: An index-organized table (IOT) will show an update operation as a separate insert and a delete operation.

Example:

SELECT VERSIONS_XID XID, VERSIONS_STARTSCN
START_SCN, VERSIONS_ENDSCN END_SCN,
VERSIONS_OPERATION OPERATION, empname, salary
FROM hr.emp
VERSIONS BETWEEN SCN MINVALUE AND MAXVALUE
AS OF SCN 113900
WHERE empno = 111

Flashback Transaction Query

FLASHBACK_TRANSACTION_QUERY - lets you identify which transaction or transactions were responsible for certain changes during a certain interval.

Its columns are:

XID, START_SCN, START_TIMESTAMP, COMMIT_SCN, COMMIT_TIMESTAMP, LOGON_USER, UNDO_CHANGE#,
OPERATION, TABLE_NAME, TABLE_OWNER, ROW_ID, UNDO_SQL

Note: You must have the SELECT ANY TRANSACTION system privilege to query the
FLASHBACK_TRANSACTION_QUERY view.

Using Flashback Transaction Query and Flashback Versions Query

SELECT XID, START_SCN START, COMMIT_SCN COMMIT,OPERATION OP, LOGON_USER USER, UNDO_SQL FROM FLASHBACK_TRANSACTION_QUERY
WHERE XID = HEXTORAW('000200030000002D')

Value passed to HEXTORAW function obtained from Flashback versions query of an old row version to undo or audit.

Flashback Transaction Query Considerations

• Flashback Transaction Query on a transaction underlying a DDL displays the changes made to the data dictionary.

• When you use Flashback Transaction Query on a dropped table, object number ( not the table name) will be displayed.

• When you use Flashback Transaction Query on a dropped table, userid (not the username) will be displayed.

• If you query a transaction involving an IOT, an update operation is always shown as a two-step delete/insert operation.

• Sometimes you’ll notice a value of UNKNOWN under the OPERATION column, if the transaction didn’t have enough undo information to correctly identify its operation type.

• You may want to turn on minimal supplemental logging in order to support operations involving chained rows and special storage structures such as clustered tables.

ALTER DATABASE ADD SUPPLEMENT LOG DATA

 

If you like Oracle tuning, see the book "Oracle Tuning: The Definitive Reference", with 950 pages of tuning tips and scripts. 

You can buy it direct from the publisher for 30%-off and get instant access to the code depot of Oracle tuning scripts.


Download your Oracle scripts now:

www.oracle-script.com

The definitive Oracle Script collection for every Oracle professional DBA

 

 


 

Free Oracle dictionary reference poster

BC Oracle support

Oracle books by Rampant

Oracle monitoring software

North Carolina Oracle Users Group

 

 Arabian horse breeder

Seeing eye horses

 

 

BC Remote Oracle Support
P.O. Box 511 • Kittrell, NC, 27544

Copyright © 2007 by Burleson Enterprises, Inc. All rights reserved.

Hit Counter