Oracle Logminer Viewer and Flashback Transaction

Total Page:16

File Type:pdf, Size:1020Kb

Oracle Logminer Viewer and Flashback Transaction DBA Tips Archive for Oracle Oracle LogMiner Viewer and Flashback Transaction by Jeff Hunter, Sr. Database Administrator Contents • Introduction • Requirements • Flashback Transaction Example Using Oracle LogMiner Viewer • About the Author Introduction LogMiner is a built-in database tool introduced in Oracle8i that provides a relational interface for users to query redo records found in online and archived redo log files. LogMiner is most often used for auditing purposes, data analysis, or recovering data from a user error. The LogMiner utility can be accessed through SQL statements (command-line) or through the Oracle LogMiner Viewer graphical user interface (GUI). Prior to Oracle Database 11g, Oracle LogMiner Viewer was a separate Java client application that provided a GUI to the the LogMiner utility. Starting with Oracle Database 11g, Oracle LogMiner Viewer has been incorporated into the Oracle Enterprise Manager web-based interface and also integrated with the new Flashback Transaction feature, making it simple to recover transactions that may have been modified by mistake. New to Oracle Database 11g, Flashback Transaction allows the changes made by a transaction to be undone, optionally including changes made by dependent transactions, while the database remains online. This tutorial provides an example-based approach on how to use Oracle LogMiner Viewer and Flashback Transaction. The example will be based on Oracle Database 11g Release 2 (11.2.0.3.0) and Oracle Enterprise Manager Database Control running on the Linux platform. Consult the following two guides for an overview of the LogMiner tool and a tutorial on how to use the LogMiner command-line interface. • Understanding LogMiner • LogMiner by Example Requirements The following are requirements for the source database that LogMiner will mine. Oracle LogMiner Viewer and Flashback Transaction The source/mining database must be Oracle Database 11g or higher with Oracle Enterprise Manager Database Control or Grid Manager configured. Archivelog Mode Archivelog mode must be enabled in order to generate usable redo log files. SQL> select log_mode from v$database; LOG_MODE ------------ NOARCHIVELOG SQL> shutdown immediate Database closed. Database dismounted. ORACLE instance shut down. SQL> startup mount ORACLE instance started. Total System Global Area 1653518336 bytes Fixed Size 2228904 bytes Variable Size 1291849048 bytes Database Buffers 352321536 bytes Redo Buffers 7118848 bytes Database mounted. SQL> alter database archivelog; Database altered. SQL> alter database open; Database altered. SQL> select log_mode from v$database; LOG_MODE ------------ ARCHIVELOG Security A new role named LOGMNR_ADMIN will be created and assigned the appropriate privileges for LogMiner analysis. This role will be assigned to a new user named MINER that will be used to perform the LogMiner examples presented in this guide. SQL> create role logmnr_admin; Role created. SQL> grant create session to logmnr_admin; Grant succeeded. SQL> grant select on v_$logmnr_contents to logmnr_admin; Grant succeeded. SQL> grant select on v_$logmnr_dictionary to logmnr_admin; Grant succeeded. SQL> grant select on v_$logmnr_parameters to logmnr_admin; Grant succeeded. SQL> grant select on v_$logmnr_logs to logmnr_admin; Grant succeeded. SQL> grant select on v_$archived_log to logmnr_admin; Grant succeeded. SQL> grant execute_catalog_role , select any dictionary , select any transaction , select any table , create tablespace , drop tablespace to logmnr_admin; Grant succeeded. SQL> create user miner identified by miner; User created. SQL> grant logmnr_admin to miner; Grant succeeded. -- Needed for Flashback Transaction. SQL> grant execute on dbms_flashback to miner; Grant succeeded. -- Needed for Flashback Transaction. SQL> grant select any transaction to miner; Grant succeeded. -- Needed for Flashback Transaction. SQL> grant create any table to miner; Grant succeeded. -- Needed for Flashback Transaction. SQL> grant flashback any table to miner; Grant succeeded. Supplemental Logging LogMiner is a redo-based application and as such, requires at least minimal supplemental logging be enabled on the source database. Oracle does not enable any supplemental logging by default. Additionally, supplemental logging for primary key columns must be enabled for Flashback Transaction to work. After verifying supplemental logging is enabled, force a log switch in order for the new supplemental log configuration to begin archiving the additional column data to the redo logs. 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 from v$database; SUPPLEMENTAL_LOG_DATA_MIN SUPPLEMENTAL_LOG_DATA_PK -------------------------- ------------------------- YES YES SQL> alter system switch logfile; System altered. Remember that supplemental logging must be enabled on the source database before generating redo log files that will be analyzed by LogMiner. Flashback Transaction Example Using Oracle LogMiner Viewer This section demonstrates how to use Oracle LogMiner Viewer to capture DDL and DML activity and how to use Flashback Transaction to backout a bad transaction (including dependent transactions). Initiate Example Data In order to test the LogMiner and Flashback Transaction functionality, create a test environment in the source database. Use the following script to create a test table and perform a few transactions against it that will be analyzed by LogMiner. oracle_logminer_viewer_script1.sql CONNECT scott/tiger Connected. SET PAGESIZE 9000 SET LINESIZE 125 COLUMN "Current User" FORMAT A13 COLUMN "Current Time" FORMAT A19 COLUMN "Current SCN" FORMAT 99999999999 COLUMN first_name FORMAT A10 COLUMN last_name FORMAT A11 COLUMN email FORMAT A21 COLUMN phone_number FORMAT A13 -- Get current user, date/time, and SCN. SELECT user AS "Current User" , TO_CHAR(systimestamp, 'MM/DD/YYYY HH24:MI:SS') AS "Current Time" , dbms_flashback.get_system_change_number AS "Current SCN" FROM dual; Current User Current Time Current SCN ------------- ------------------- ------------ SCOTT 10/15/2012 16:01:10 102229443 -- Create new table and initialize with test data. PAUSE Create table SCOTT.EMPLOYEES. Hit <ENTER> to continue. Create table SCOTT.EMPLOYEES. Hit <ENTER> to continue. CREATE TABLE scott.employees ( employee_id NUMBER(6) , first_name VARCHAR2(20) , last_name VARCHAR2(25) NOT NULL , email VARCHAR2(25) NOT NULL , phone_number VARCHAR2(20) , CONSTRAINT employees_pk1 PRIMARY KEY (employee_id) ); Table created. PAUSE Initialize new table with test data. Hit <ENTER> to continue. Initialize new table with test data. Hit <ENTER> to continue. INSERT INTO scott.employees VALUES (1001, 'Julia', 'Desai', '[email protected]', '209-555-1214'); 1 row created. INSERT INTO scott.employees VALUES (1002, 'Franklin', 'Vick', '[email protected]', '209-555-1219'); 1 row created. INSERT INTO scott.employees VALUES (1003, 'Beth', 'Walton', '[email protected]', '209-555-1212'); 1 row created. INSERT INTO scott.employees VALUES (1004, 'Pat', 'Allen', '[email protected]', '209-555-1213'); 1 row created. INSERT INTO scott.employees VALUES (1005, 'Stacy', 'Olsen', '[email protected]', '209-555-1224'); 1 row created. COMMIT; Commit complete. SELECT employee_id , first_name , last_name , email , phone_number FROM scott.employees ORDER BY employee_id; EMPLOYEE_ID FIRST_NAME LAST_NAME EMAIL PHONE_NUMBER ----------- ---------- ----------- --------------------- ------------- 1001 Julia Desai [email protected] 209-555-1214 1002 Franklin Vick [email protected] 209-555-1219 1003 Beth Walton [email protected] 209-555-1212 1004 Pat Allen [email protected] 209-555-1213 1005 Stacy Olsen [email protected] 209-555-1224 -- The following transaction (TRANSACTION 1) will be backed out -- using Oracle LogMiner Viewer and Flashback Transaction. -- Flashback Transaction will detect a dependent transaction -- (TRANSACTION 2) and prompt the user with a list of options on -- how to continue. -- [TRANSACTION 1] PAUSE Modify test data (TRANSACTION 1). Hit <ENTER> to continue. Modify test data (TRANSACTION 1). Hit <ENTER> to continue. UPDATE scott.employees SET phone_number='209-555-9999' WHERE employee_id=1005; 1 row updated. DELETE FROM scott.employees WHERE employee_id=1001; 1 row deleted. COMMIT; Commit complete. -- [TRANSACTION 2] PAUSE Modify test data (TRANSACTION 2). Hit <ENTER> to continue. Modify test data (TRANSACTION 2). Hit <ENTER> to continue. DELETE FROM scott.employees WHERE employee_id=1005; 1 row deleted. COMMIT; Commit complete. SELECT employee_id , first_name , last_name , email , phone_number FROM scott.employees ORDER BY employee_id; EMPLOYEE_ID FIRST_NAME LAST_NAME EMAIL PHONE_NUMBER ----------- ---------- ----------- --------------------- ------------- 1002 Franklin Vick [email protected] 209-555-1219 1003 Beth Walton [email protected] 209-555-1212 1004 Pat Allen [email protected] 209-555-1213 -- Get current user, date/time, and SCN. SELECT user AS "Current User" , TO_CHAR(systimestamp, 'MM/DD/YYYY HH24:MI:SS') AS "Current Time" , dbms_flashback.get_system_change_number AS "Current SCN" FROM dual; Current User Current Time Current SCN ------------- ------------------- ------------ SCOTT 10/15/2012 16:03:31 102229949 Notice how the above script contains a number of SQL*Plus PAUSE commands. I inserted the PAUSE commands as a method to provide an interval of time between the different SQL
Recommended publications
  • (Yukon) and Oracle 10G Databases
    Features, strengths and weaknesses comparison between MS SQL 2005 (Yukon) and Oracle 10g databases A Technical White Paper By David Gornshtein Boris Tamarkin WisdomForce Technologies, Inc http://www.wisdomforce.com Revision 1.2 ©2004 WisdomForce Technologies, Inc. All rights reserved. 1 Note*: The latest copy of the document is available at http://www.wisdomforce.com/dweb/resources/docs/MSSQL2005_ORACLE10g_compare.pdf This topic contains alternative comparison between latest versions of Oracle 10g and Microsoft SQL Server 2005 databases. Table of Contents Preface............................................................................................................................................. 4 Major limitations of MSSQL prior to Yukon (such as MSSQL 2000)........................................... 5 Locking strategy.......................................................................................................................... 5 Online space reorganization and table/index partitioning .......................................................... 6 Statistics ...................................................................................................................................... 7 Clustering and high availability.................................................................................................. 7 Administration ................................................................................................................................ 9 Locking ........................................................................................................................................
    [Show full text]
  • Oracle Enterprise Manager Configuration Guide, Release 9.2.0.2
    Oracle Enterprise Manager Configuration Guide Release 9.2.0.2 October 2002 Part No. A96673-02 Oracle Enterprise Manager Configuration Guide, Release 9.2.0.2 Part No. A96673-02 Copyright © 1996, 2002 Oracle Corporation. All Rights Reserved. The Programs (which include both the software and documentation) contain proprietary information of Oracle Corporation; they are provided under a license agreement containing restrictions on use and disclosure and are also protected by copyright, patent and other intellectual and industrial property laws. Reverse engineering, disassembly or decompilation of the Programs, except to the extent required to obtain interoperability with other independently created software or as specified by law, is prohibited. The information contained in this document is subject to change without notice. If you find any problems in the documentation, please report them to us in writing. Oracle Corporation does not warrant that this document is error-free. Except as may be expressly permitted in your license agreement for these Programs, no part of these Programs may be reproduced or transmitted in any form or by any means, electronic or mechanical, for any purpose, without the express written permission of Oracle Corporation. If the Programs are delivered to the U.S. Government or anyone licensing or using the programs on behalf of the U.S. Government, the following notice is applicable: Restricted Rights Notice Programs delivered subject to the DOD FAR Supplement are "commercial computer software" and use, duplication, and disclosure of the Programs, including documentation, shall be subject to the licensing restrictions set forth in the applicable Oracle license agreement. Otherwise, Programs delivered subject to the Federal Acquisition Regulations are "restricted computer software" and use, duplication, and disclosure of the Programs shall be subject to the restrictions in FAR 52.227-19, Commercial Computer Software - Restricted Rights (June, 1987).
    [Show full text]
  • Oracle Enterprise Manager Concepts Guide, Release 9.2.0
    Oracle Enterprise Manager Concepts Guide Release 9.2.0 March 2002 Part No. A96674-01 Oracle Enterprise Manager Concepts Guide, Release 9.2.0 Part No. A96674-01 Copyright © 1996, 2002, Oracle Corporation. All rights reserved. The Programs (which include both the software and documentation) contain proprietary information of Oracle Corporation; they are provided under a license agreement containing restrictions on use and disclosure and are also protected by copyright, patent and other intellectual and industrial property laws. Reverse engineering, disassembly or decompilation of the Programs, except to the extent required to obtain interoperability with other independently created software or as specified by law, is prohibited. The information contained in this document is subject to change without notice. If you find any problems in the documentation, please report them to us in writing. Oracle Corporation does not warrant that this document is error-free. Except as may be expressly permitted in your license agreement for these Programs, no part of these Programs may be reproduced or transmitted in any form or by any means, electronic or mechanical, for any purpose, without the express written permission of Oracle Corporation. If the Programs are delivered to the U.S. Government or anyone licensing or using the programs on behalf of the U.S. Government, the following notice is applicable: Restricted Rights Notice Programs delivered subject to the DOD FAR Supplement are "commercial computer software" and use, duplication, and disclosure of the Programs, including documentation, shall be subject to the licensing restrictions set forth in the applicable Oracle license agreement. Otherwise, Programs delivered subject to the Federal Acquisition Regulations are "restricted computer software" and use, duplication, and disclosure of the Programs shall be subject to the restrictions in FAR 52.227-19, Commercial Computer Software - Restricted Rights (June, 1987).
    [Show full text]
  • Oracle Audit Vault Auditor's Guide, Release 10.3 E16813-01
    Oracle® Audit Vault Auditor's Guide Release 10.3 E16813-01 November 2011 Oracle Audit Vault Auditor's Guide, Release 10.3 E16813-01 Copyright © 2007, 2011, Oracle and/or its affiliates. All rights reserved. Primary Author: Patricia Huey Contributing Author: Rodney Ward Contributors: Tammy Bednar, Janet Blowney, Raghavendran Hanumantharau, Ravi Kumar, Srivatsan Kannan, K. Karun, Anurag Prasad, Vipul Shah, Prahlada Varadan Thirumalai, Lok Sheung, Srividya Tata This software and related documentation are provided under a license agreement containing restrictions on use and disclosure and are protected by intellectual property laws. Except as expressly permitted in your license agreement or allowed by law, you may not use, copy, reproduce, translate, broadcast, modify, license, transmit, distribute, exhibit, perform, publish, or display any part, in any form, or by any means. Reverse engineering, disassembly, or decompilation of this software, unless required by law for interoperability, is prohibited. The information contained herein is subject to change without notice and is not warranted to be error-free. If you find any errors, please report them to us in writing. If this is software or related documentation that is delivered to the U.S. Government or anyone licensing it on behalf of the U.S. Government, the following notice is applicable: U.S. GOVERNMENT RIGHTS Programs, software, databases, and related documentation and technical data delivered to U.S. Government customers are "commercial computer software" or "commercial technical data" pursuant to the applicable Federal Acquisition Regulation and agency-specific supplemental regulations. As such, the use, duplication, disclosure, modification, and adaptation shall be subject to the restrictions and license terms set forth in the applicable Government contract, and, to the extent applicable by the terms of the Government contract, the additional rights set forth in FAR 52.227-19, Commercial Computer Software License (December 2007).
    [Show full text]
  • Oracle9i Database Administrator's Guide
    Oracle9i Database Administrator’s Guide Release 2 (9.2) March 2002 Part No. A96521-01 Oracle9i Database Administrator’s Guide, Release 2 (9.2) Part No. A96521-01 Copyright © 2001, 2002 Oracle Corporation. All rights reserved. Primary Author: Ruth Baylis Contributing Authors: Kathy Rich Graphic Designer: Valarie Moore Contributors: Lance Ashdown, Allen Brumm, Michele Cyran, Mary Ann Davidson, Harvey Eneman, Amit Ganesh, Carolyn Gray, Wei Huang, Robert Jenkins, Mark Kennedy, Sushil Kumar, Bill Lee, Yunrui Li, Diana Lorentz, Sujatha Muthulingam, Gary Ngai, Waleed Ojeil, Lois Price, Ananth Raghavan, Ann Rhee, Rajiv Sinha, Jags Srinivasan, Anh-Tuan Tran, Deborah Steiner, Janet Stern, Michael Stewart, Alex Tsukerman, Kothanda Umamageswaran, Steven Wertheimer, Daniel Wong The Programs (which include both the software and documentation) contain proprietary information of Oracle Corporation; they are provided under a license agreement containing restrictions on use and disclosure and are also protected by copyright, patent and other intellectual and industrial property laws. Reverse engineering, disassembly or decompilation of the Programs, except to the extent required to obtain interoperability with other independently created software or as specified by law, is prohibited. The information contained in this document is subject to change without notice. If you find any problems in the documentation, please report them to us in writing. Oracle Corporation does not warrant that this document is error-free. Except as may be expressly permitted in your license agreement for these Programs, no part of these Programs may be reproduced or transmitted in any form or by any means, electronic or mechanical, for any purpose, without the express written permission of Oracle Corporation.
    [Show full text]
  • Oracle Audit Vault
    Oracle Audit Vault presentation for: Utah Oracle Users Group © Puget Sound Oracle Users Group Education Is Our Passion Who am I? Daniel Morgan Oracle Ace Director University of Washington Wrote UW Oracle curricula Primary program instructor - 8 years Education Chair: PSOUG Member: UKOUG Frequent speaker – OOW and user group events 10g, 11g, and TimesTen Beta tester Oracle since version 6 Too many years of Fortran and COBOL Contact: [email protected] © Puget Sound Oracle Users Group Education Is Our Passion I will try to avoid this ... © Puget Sound Oracle Users Group Education Is Our Passion What Your Management Is Hearing © Puget Sound Oracle Users Group Education Is Our Passion Sarbanes Oxley Act (SOX, SarbOx) Passed by Congress on January 23rd, 2002 and signed by President Bush on July 30th, 2002 Industrial engine manufacturing FUD © Puget Sound Oracle Users Group Education Is Our Passion SOX Requirements Sarbanes-Oxley Section 302 and 404 Internal Control Requirements Requires the CEO and CFO of a public company to certify quarterly and annually that they: Are responsible for disclosure controls, Have designed controls to ensure that material information is known to them, Have evaluated the effectiveness of controls, Have presented their conclusions in the filing, Section 302 Have disclosed to the audit committee and auditors significant control deficiencies and acts of fraud, Have indicated in the report significant changes to controls. Requires the CEO and CFO to annually: State their responsibility for establishing and maintaining an adequate internal control structure and procedures for financial reporting, Conduct and provide an assessment of the effectiveness of the internal controls.
    [Show full text]
  • Oracle Database Utilities, 11G Release 2 (11.2) E22490-08 Copyright © 1996, 2018, Oracle And/Or Its Affiliates
    1[Oracle®] Database Utilities 11g Release 2 (11.2) E22490-08 April 2018 Oracle Database Utilities, 11g Release 2 (11.2) E22490-08 Copyright © 1996, 2018, Oracle and/or its affiliates. All rights reserved. Primary Author: Kathy Rich Contributors: Lee Barton, Ellen Batbouta, Janet Blowney, Steve DiPirro, Bill Fisher, Steve Fogel, Dean Gagne, John Kalogeropoulos, Jonathan Klein, Cindy Lim, Brian McCarthy, Rod Payne, Rich Phillips, Mike Sakayeda, Francisco Sanchez, Marilyn Saunders, Jim Stenoish, Randy Urbano, Hui-ling Yu This software and related documentation are provided under a license agreement containing restrictions on use and disclosure and are protected by intellectual property laws. Except as expressly permitted in your license agreement or allowed by law, you may not use, copy, reproduce, translate, broadcast, modify, license, transmit, distribute, exhibit, perform, publish, or display any part, in any form, or by any means. Reverse engineering, disassembly, or decompilation of this software, unless required by law for interoperability, is prohibited. The information contained herein is subject to change without notice and is not warranted to be error-free. If you find any errors, please report them to us in writing. If this is software or related documentation that is delivered to the U.S. Government or anyone licensing it on behalf of the U.S. Government, then the following notice is applicable: U.S. GOVERNMENT END USERS: Oracle programs, including any operating system, integrated software, any programs installed on the hardware, and/or documentation, delivered to U.S. Government end users are "commercial computer software" pursuant to the applicable Federal Acquisition Regulation and agency-specific supplemental regulations.
    [Show full text]
  • Oracle Database Utilities, 12C Release 1 (12.1) E41528-04
    Oracle®[1] Database Utilities 12c Release 1 (12.1) E41528-04 July 2014 Oracle Database Utilities, 12c Release 1 (12.1) E41528-04 Copyright © 1996, 2014, Oracle and/or its affiliates. All rights reserved. Primary Author: Kathy Rich Contributors: Lee Barton, George Claborn, Steve DiPirro, Dean Gagne, John Kalogeropoulos, Joydip Kundu, Rod Payne, Ray Pfau, Rich Phillips, Mike Sakayeda, Marilyn Saunders, Jim Stenoish, Roy Swonger, Randy Urbano, William Wright, Hui-ling Yu Contributor: The Oracle Database 12c documentation is dedicated to Mark Townsend, who was an inspiration to all who worked on this release. This software and related documentation are provided under a license agreement containing restrictions on use and disclosure and are protected by intellectual property laws. Except as expressly permitted in your license agreement or allowed by law, you may not use, copy, reproduce, translate, broadcast, modify, license, transmit, distribute, exhibit, perform, publish, or display any part, in any form, or by any means. Reverse engineering, disassembly, or decompilation of this software, unless required by law for interoperability, is prohibited. The information contained herein is subject to change without notice and is not warranted to be error-free. If you find any errors, please report them to us in writing. If this is software or related documentation that is delivered to the U.S. Government or anyone licensing it on behalf of the U.S. Government, the following notice is applicable: U.S. GOVERNMENT END USERS: Oracle programs, including any operating system, integrated software, any programs installed on the hardware, and/or documentation, delivered to U.S. Government end users are "commercial computer software" pursuant to the applicable Federal Acquisition Regulation and agency-specific supplemental regulations.
    [Show full text]