Oracle Database 12c DBA Handbook

745
www.allitebooks.com

Transcript of Oracle Database 12c DBA Handbook

  • www.allitebooks.com

    http://www.allitebooks.org

  • Oracle TIGHT / Oracle Database 12c DBA Handbook / Bob Bryla / 878-1/ Blind folio: i

    Oracle Database 12c DBA Handbook

    00-FM.indd 1 27/04/15 11:13 AM

    www.allitebooks.com

    http://www.allitebooks.org

  • Oracle TIGHT / Oracle Database 12c DBA Handbook / Bob Bryla / 878-1 / Blind folio: ii

    About the AuthorBob Bryla is an Oracle 9i, 10g, 11g, and 12c Certified Professional with more than 20 years of experience in database design, database application development, training, and Oracle database administration. He is the primary Oracle DBA and database systems engineer at Epic in Verona, Wisconsin. He is a technical editor for a number of Oracle Press books, including several certification study guides for Oracle Database 10g, 11g, and 12c. He has also been known to watch science fiction movies and tinker with Android devices in his spare time.

    About the Technical EditorScott Gossett is a technical director in the Oracle Advanced Technologies Solutions organization with more than 23 years of experience specializing in Oracle RAC, performance tuning, and high-availability databases. Prior to becoming a technical director, Scott was a senior principal instructor for Oracle Education for over 12 years, primarily teaching Oracle internals, performance tuning, RAC, and database administration. In addition, Scott is one of the architects and primary authors of the Oracle Certified Master exam. Scott has been a technical editor for twelve Oracle Press books.

    00-FM.indd 2 27/04/15 11:13 AM

    www.allitebooks.com

    http://www.allitebooks.org

  • Oracle TIGHT / Oracle Database 12c DBA Handbook / Bob Bryla / 878-1/ Blind folio: iii

    Oracle Database 12c DBA Handbook

    Bob Bryla

    New York Chicago San Francisco Athens London Madrid Mexico City Milan New Delhi Singapore Sydney Toronto

    00-FM.indd 3 27/04/15 11:13 AM

    www.allitebooks.com

    http://www.allitebooks.org

  • Copyright 2015 by McGraw-Hill Education (Publisher). All rights reserved. Except as permitted under the United States Copyright Act of 1976, no part of this publication may be reproduced or distributed in any form or by any means, or stored in a database or retrieval system, without the prior written permission of the publisher, with the exception that the program listings may be entered, stored, and executed in a computer system, but they may not be reproduced for publication.

    ISBN: 978-0-07-179879-2

    MHID: 0-07-179879-X

    The material in this eBook also appears in the print version of this title: ISBN: 978-0-07-179878-5,MHID: 0-07-179878-1.

    eBook conversion by codeMantraVersion 1.0

    All trademarks are trademarks of their respective owners. Rather than put a trademark symbol after every occurrence of a trademarked name, we use names in an editorial fashion only, and to the benefit of the trademark owner, with no intention of infringement of the trademark. Where such designations appear in this book, they have been printed with initial caps.

    McGraw-Hill Education eBooks are available at special quantity discounts to use as premiums and sales promotions or for use in corporate training programs. To contact a representative, please visit the Contact Us page at www.mhprofessional.com.

    Oracle is a registered trademark of Oracle Corporation and/or its affiliates. All other trademarks are the property of their respective owners, and McGraw-Hill Education makes no claim of ownership by the mention of products that contain these marks.

    Screen displays of copyrighted Oracle software programs have been reproduced herein with the permission of Oracle Corporation and/or its affiliates.

    Information has been obtained by Publisher from sources believed to be reliable. However, because of the possibility of human or mechanical error by our sources, Publisher, or others, Publisher does not guarantee to the accuracy, adequacy, or completeness of any information included in this work and is not responsible for any errors or omissions or the results obtained from the use of such information.

    Oracle Corporation does not make any representations or warranties as to the accuracy, adequacy, or completeness of any information contained in this Work, and is not responsible for any errors or omissions.

    TERMS OF USE

    This is a copyrighted work and McGraw-Hill Education and its licensors reserve all rights in and to the work. Use of this work is subject to these terms. Except as permitted under the Copyright Act of 1976 and the right to store and retrieve one copy of the work, you may not decompile, disassemble, reverse engineer, reproduce, modify, create derivative works based upon, transmit, distribute, disseminate, sell, publish or sublicense the work or any part of it without McGraw-Hill Educations prior consent. You may use the work for your own noncommercial and personal use; any other use of the work is strictly prohibited. Your right to use the work may be terminated if you fail to comply with these terms.

    THE WORK IS PROVIDED AS IS. McGRAW-HILL EDUCATION AND ITS LICENSORS MAKE NO GUARANTEES OR WARRANTIES AS TO THE ACCURACY, ADEQUACY OR COMPLETENESS OF OR RESULTS TO BE OBTAINED FROM USING THE WORK, INCLUDING ANY INFORMATION THAT CAN BE ACCESSED THROUGH THE WORK VIA HYPERLINK OR OTHERWISE, AND EXPRESSLY DISCLAIM ANY WARRANTY, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. McGraw-Hill Education and its licensors do not warrant or guarantee that the functions contained in the work will meet your requirements or that its operation will be uninterrupted or error free. Neither McGraw-Hill Education nor its licensors shall be liable to you or anyone else for any inaccuracy, error or omission, regardless of cause, in the work or for any damages resulting therefrom. McGraw-Hill Education has no responsibility for the content of any information accessed through the work. Under no circumstances shall McGraw-Hill Education and/or its licensors be liable for any indirect, incidental, special, punitive, consequential or similar damages that result from the use of or inability to use the work, even if any of them has been advised of the possibility of such damages. This limitation of liability shall apply to any claim or cause whatsoever whether such claim or cause arises in contract, tort or otherwise.

    www.allitebooks.com

    http://www.mhprofessional.comhttp://www.allitebooks.org

  • Oracle TIGHT / Oracle Database 12c DBA Handbook / Bob Bryla / 878-1 / Blind folio: v

    To the gang at home: I couldnt have done it without you! And the pizzas. And the

    heavy metal. And several shows on the BBC.

    BB

    00-FM.indd 5 27/04/15 11:13 AM

    www.allitebooks.com

    http://www.allitebooks.org

  • This page intentionally left blank

    www.allitebooks.com

    http://www.allitebooks.org

  • Oracle TIGHT / Oracle Database 12c DBA Handbook / Bob Bryla / 878-1 Oracle TIGHT / Oracle Database 12c DBA Handbook / Bob Bryla / 878-1

    Contents at a Glance

    PART IDatabase Architecture

    1 Getting Started with the Oracle Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

    2 Upgrading to Oracle Database 12c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51

    3 Planning and Managing Tablespaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61

    4 Physical Database Layouts and Storage Management . . . . . . . . . . . . . . . . . . . . . . 77

    PART IIDatabase Management

    5 Developing and Implementing Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117

    6 Monitoring Space Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157

    7 Managing Transactions with Undo Tablespaces . . . . . . . . . . . . . . . . . . . . . . . . . . . 209

    8 Database Tuning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245

    9 In-Memory Option . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293

    10 Database Security and Auditing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303

    11 Multitenant Database Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 371

    PART IIIHigh Availability

    12 Real Application Clusters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 441

    13 Backup and Recovery Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 453

    14 Using Recovery Manager (RMAN) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 481

    vii

    00-FM.indd 7 27/04/15 11:13 AM

    www.allitebooks.com

    http://www.allitebooks.org

  • Oracle TIGHT / Oracle Database 12c DBA Handbook / Bob Bryla / 878-1 Oracle TIGHT / Oracle Database 12c DBA Handbook / Bob Bryla / 878-1

    viii Oracle Database 12c DBA Handbook

    15 Oracle Data Guard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 537

    16 Miscellaneous High Availability Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 559

    PART IVNetworked Oracle

    17 Oracle Net . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 577

    18 Managing Large Databases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 611

    19 Managing Distributed Databases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 657

    Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 697

    00-FM.indd 8 27/04/15 11:13 AM

    www.allitebooks.com

    http://www.allitebooks.org

  • Oracle TIGHT / Oracle Database 12c DBA Handbook / Bob Bryla / 878-1 Oracle TIGHT / Oracle Database 12c DBA Handbook / Bob Bryla / 878-1

    Contents

    Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxiIntroduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxiii

    PART IDatabase Architecture

    1 Getting Started with the Oracle Architecture . . . . . . . . . . . . . . . . . . . . . . . . 3An Overview of Databases and Instances . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

    Databases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5Instances . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

    Oracle Logical Storage Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6Tablespaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7Extents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7Segments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

    Oracle Logical Database Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9Constraints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16Indexes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18Views . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20Users and Schemas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22Profiles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22Sequences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23Synonyms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23PL/SQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23External File Access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24Database Links and Remote Databases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25

    Oracle Physical Storage Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26Datafiles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27Redo Log Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27

    ix

    00-FM.indd 9 27/04/15 11:13 AM

    www.allitebooks.com

    http://www.allitebooks.org

  • Oracle TIGHT / Oracle Database 12c DBA Handbook / Bob Bryla / 878-1 Oracle TIGHT / Oracle Database 12c DBA Handbook / Bob Bryla / 878-1

    x Oracle Database 12c DBA Handbook

    Control Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28Archived Log Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28Initialization Parameter Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28Alert and Trace Log Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29Backup Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30Oracle Managed Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30Password Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30

    Multiplexing Database Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31Automatic Storage Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31Manual Multiplexing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31

    Oracle Memory Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33System Global Area . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33Program Global Area . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36Software Code Area . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36Background Processes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37

    Backup/Recovery Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39Export/Import . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39Offline Backups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40Online Backups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40RMAN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40

    Security Capabilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41Privileges and Roles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41Auditing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41Fine-Grained Auditing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42Virtual Private Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42Label Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42

    Real Application Clusters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42Oracle Streams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43Oracle Enterprise Manager . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43Oracle Initialization Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44

    Basic Initialization Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44Advanced Initialization Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49

    Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49

    2 Upgrading to Oracle Database 12c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51Choosing an Upgrade Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53Before Upgrading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54Using the Database Upgrade Assistant . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55Performing a Manual Direct Upgrade . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56Using Data Pump Export and Import . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58

    Export and Import Versions to Use . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58Performing the Upgrade . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58

    Using the Data-Copying Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59After Upgrading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60

    00-FM.indd 10 27/04/15 11:13 AM

  • Oracle TIGHT / Oracle Database 12c DBA Handbook / Bob Bryla / 878-1 Oracle TIGHT / Oracle Database 12c DBA Handbook / Bob Bryla / 878-1

    Contents xix Oracle Database 12c DBA Handbook

    3 Planning and Managing Tablespaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61Tablespace Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62

    Tablespace Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62Optimal Flexible Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68

    Oracle Installation Tablespaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73SYSTEM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74SYSAUX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74TEMP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74UNDOTBS1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74USERS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75EXAMPLE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75

    Segment Segregation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76

    4 Physical Database Layouts and Storage Management . . . . . . . . . . . . . . . . . . 77Traditional Disk Space Storage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78

    Resizing Tablespaces and Datafiles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78Moving Datafiles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86Moving Online Redo Log Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90Moving Control Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91

    Automatic Storage Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93ASM Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94Creating an ASM Instance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94ASM Instance Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97ASM Dynamic Performance Views . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99ASM Filename Formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99ASM File Types and Templates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102Administering ASM Disk Groups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102

    Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114

    PART IIDatabase Management

    5 Developing and Implementing Applications . . . . . . . . . . . . . . . . . . . . . . . . . 117Tuning by Design: Best Practices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118

    Do As Little As Possible . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119Do It As Simply As Possible . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121Tell the Database What It Needs to Know . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123Maximize the Throughput in the Environment . . . . . . . . . . . . . . . . . . . . . . . . . 124Divide and Conquer Your Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124Test Correctly . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125Standard Deliverables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127

    Resource Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130Implementing the Database Resource Manager . . . . . . . . . . . . . . . . . . . . . . . . 130Sizing Database Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135Using Global Temporary Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142

    00-FM.indd 11 27/04/15 11:13 AM

  • Oracle TIGHT / Oracle Database 12c DBA Handbook / Bob Bryla / 878-1 Oracle TIGHT / Oracle Database 12c DBA Handbook / Bob Bryla / 878-1

    xii Oracle Database 12c DBA Handbook

    Supporting Tables Based on Abstract Datatypes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142Using Object Views . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143Security for Abstract Datatypes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146Indexing Abstract Datatype Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148

    Quiescing and Suspending the Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149Supporting Iterative Development . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151

    Iterative Column Definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151Forcing Cursor Sharing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152

    Managing Package Development . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153Generating Diagrams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153Space Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153Tuning Goals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153Security Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153Data Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154Version Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154Execution Plans . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154Acceptance Test Procedures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154The Testing Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155

    Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155

    6 Monitoring Space Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157Common Space Management Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158

    Running Out of Free Space in a Tablespace . . . . . . . . . . . . . . . . . . . . . . . . . . . 159Insufficient Space for Temporary Segments . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159Too Much or Too Little Undo Space Allocated . . . . . . . . . . . . . . . . . . . . . . . . . 159Fragmented Tablespaces and Segments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160

    Oracle Segments, Extents, and Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161Data Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161Extents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163Segments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164

    Data Dictionary Views and Dynamic Performance Views . . . . . . . . . . . . . . . . . . . . . . . 165DBA_TABLESPACES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165DBA_SEGMENTS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166DBA_EXTENTS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166DBA_FREE_SPACE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167DBA_LMT_FREE_SPACE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167DBA_THRESHOLDS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167DBA_OUTSTANDING_ALERTS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168DBA_OBJECT_USAGE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168DBA_ALERT_HISTORY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168V$ALERT_TYPES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169V$UNDOSTAT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169V$SORT_SEGMENT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169V$TEMPSEG_USAGE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170

    00-FM.indd 12 27/04/15 11:13 AM

  • Oracle TIGHT / Oracle Database 12c DBA Handbook / Bob Bryla / 878-1 Oracle TIGHT / Oracle Database 12c DBA Handbook / Bob Bryla / 878-1

    Contents xiiixii Oracle Database 12c DBA Handbook

    Space Management Methodologies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170Locally Managed Tablespaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170Using OMF to Manage Space . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172Bigfile Tablespaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173Automatic Storage Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174Undo Management Considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176

    SYSAUX Monitoring and Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177Archived Redo Log File Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179Built-in Space Management Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179

    Segment Advisor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179Undo Advisor and the Automatic Workload Repository . . . . . . . . . . . . . . . . . . 182Index Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184Space Usage Warning Levels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185Resumable Space Allocation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187Managing Alert and Trace Files with ADR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190OS Space Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193

    Space Management Scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193Segments That Cannot Allocate Additional Extents . . . . . . . . . . . . . . . . . . . . . . 193Used and Free Space by Tablespace and Datafile . . . . . . . . . . . . . . . . . . . . . . . 194

    Automating and Streamlining the Notification Process . . . . . . . . . . . . . . . . . . . . . . . . . 195Using DBMS_SCHEDULER . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195Cloud Control and Monitoring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196

    Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207

    7 Managing Transactions with Undo Tablespaces . . . . . . . . . . . . . . . . . . . . . . . 209Transaction Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210Undo Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211

    Rollback . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211Read Consistency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211Database Recovery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212Flashback Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212

    Managing Undo Tablespaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212Creating Undo Tablespaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212Undo Tablespace Dynamic Performance Views . . . . . . . . . . . . . . . . . . . . . . . . 219Undo Tablespace Initialization Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219Multiple Undo Tablespaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221Sizing and Monitoring the Undo Tablespace . . . . . . . . . . . . . . . . . . . . . . . . . . . 223Read Consistency vs. Successful DML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227

    Flashback Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227Flashback Query . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228DBMS_FLASHBACK . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230Flashback Transaction Backout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232Flashback Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232Flashback Version Query . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234Flashback Transaction Query . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237

    00-FM.indd 13 27/04/15 11:13 AM

  • Oracle TIGHT / Oracle Database 12c DBA Handbook / Bob Bryla / 878-1 Oracle TIGHT / Oracle Database 12c DBA Handbook / Bob Bryla / 878-1

    xiv Oracle Database 12c DBA Handbook

    Flashback Data Archive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 238Flashback and LOBs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242

    Migrating to Automatic Undo Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243

    8 Database Tuning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245Tuning Application Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 247

    Effective Table Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 247Distribution of CPU Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 248Effective Application Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249

    Tuning SQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251Impact of Order on Load Rates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252Additional Indexing Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253Generating Explain Plans . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254

    Tuning Memory Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257Managing SGA Pools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257Specifying the Size of the SGA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 260Using the Cost-Based Optimizer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261

    Tuning Data Access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262Identifying Chained Rows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262Using Index-Organized Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263Tuning Issues for Index-Organized Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 264

    Tuning Data Manipulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265Bulk Inserts: Using the SQL*Loader Direct Path Option . . . . . . . . . . . . . . . . . . 265Bulk Data Moves: Using External Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267Bulk Inserts: Common Traps and Successful Tricks . . . . . . . . . . . . . . . . . . . . . . 267Bulk Deletes: The TRUNCATE Command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268Using Partitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269

    Reducing Network Traffic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 270Replication of Data Using Materialized Views . . . . . . . . . . . . . . . . . . . . . . . . . 270Using Remote Procedure Calls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272

    Using the Automatic Workload Repository . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273Managing Snapshots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274Managing Baselines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274Generating AWR Reports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274Running the Automatic Database Diagnostic Monitor Reports . . . . . . . . . . . . . 275Using Automatic SQL Tuning Advisor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275

    Performance Tuning in a Multitenant Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . 277Tuning Methodology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279Sizing the CDB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279Using Memory Advisors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 282Leveraging AWR Reports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283Using the SQL Tuning Advisor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283

    Managing Resource Allocation Within a PDB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 284Using Shares to Manage Inter-PDB Resources . . . . . . . . . . . . . . . . . . . . . . . . . . 284Creating and Modifying Resource Manager Plans . . . . . . . . . . . . . . . . . . . . . . . 284

    00-FM.indd 14 27/04/15 11:13 AM

  • Oracle TIGHT / Oracle Database 12c DBA Handbook / Bob Bryla / 878-1 Oracle TIGHT / Oracle Database 12c DBA Handbook / Bob Bryla / 878-1

    Contents xvxiv Oracle Database 12c DBA Handbook

    Performing Database Replay . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289Analyze the Source Database Workloads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289Capture Source Database Workloads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 290Process Workloads on Target System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 290Replay Workloads on Target CDB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 290Verify Replay Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 290

    Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 290

    9 In-Memory Option . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293Overview of Oracle In-Memory Option . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294

    System Requirements and Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294In-Memory Case Study . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295

    Data Dictionary Views . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 299V$IM_SEGMENTS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 299V$INMEMORY_AREA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 300V$SGA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 300

    Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 301

    10 Database Security andAuditing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303Non-database Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 305Database Authentication Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 305

    Database Authentication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 306Database Administrator Authentication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 306Operating System Authentication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 309Network Authentication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3103-Tier Authentication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 312Client-Side Authentication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 312User Accounts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 313

    Database Authorization Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 318Profile Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 319System Privileges . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 326Object Privileges . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 329Creating, Assigning, and Maintaining Roles . . . . . . . . . . . . . . . . . . . . . . . . . . . 333Using a VPD to Implement Application Security Policies . . . . . . . . . . . . . . . . . 340

    Auditing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 358Auditing Locations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 358Statement Auditing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 360Privilege Auditing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 364Schema Object Auditing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 365Fine-Grained Auditing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 366Auditing-Related Data Dictionary Views . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 368Protecting the Audit Trail . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 368

    Data Encryption Techniques . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 369DBMS_CRYPTO Package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 369Transparent Data Encryption . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 369

    Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 370

    00-FM.indd 15 27/04/15 11:13 AM

  • Oracle TIGHT / Oracle Database 12c DBA Handbook / Bob Bryla / 878-1 Oracle TIGHT / Oracle Database 12c DBA Handbook / Bob Bryla / 878-1

    xvi Oracle Database 12c DBA Handbook

    11 Multitenant Database Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 371Understanding the Multitenant Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 373

    Leveraging Multitenant Databases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 373Understanding Multitenant Configurations . . . . . . . . . . . . . . . . . . . . . . . . . . . . 374

    Provisioning in a Multitenant Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 376Understanding Pluggable Database Provisioning . . . . . . . . . . . . . . . . . . . . . . . 376Configuring and Creating a CDB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 379Understanding New Data Dictionary Views: The Sequel . . . . . . . . . . . . . . . . . . 384Creating PDBs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 387Unplugging and Dropping a PDB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 392

    Managing CDBs and PDBs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 395Understanding CDB and PDB Service Names . . . . . . . . . . . . . . . . . . . . . . . . . . 395Connecting to a CDB or PDB Using SQL Developer . . . . . . . . . . . . . . . . . . . . . 396Creating Services for CDBs or PDBs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 397Switching Connections Within a CDB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 398Starting Up and Shutting Down CDBs and PDBs . . . . . . . . . . . . . . . . . . . . . . . 399Changing Parameters in a CDB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 406Manage Permanent and Temporary Tablespaces in CDB and PDBs . . . . . . . . . . 407

    Multitenant Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 410Managing Common and Local Users . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 410Managing Common and Local Privileges . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 412Managing Common and Local Roles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 413Enabling Common Users to Access Data in Specific PDBs . . . . . . . . . . . . . . . . 414

    Backup and Recovery in Multitenant Environments . . . . . . . . . . . . . . . . . . . . . . . . . . . 416Performing Backups of a CDB and All PDBs . . . . . . . . . . . . . . . . . . . . . . . . . . . 416Backing Up CDBs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 420Backing Up PDBs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 422Recovering from PDB Datafile Loss . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 424Using the Data Recovery Advisor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 432Identifying Block Corruption . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 436Duplicating PDBs Using RMAN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 437

    Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 438

    PART IIIHigh Availability

    12 Real Application Clusters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 441Overview of Real Application Clusters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 442

    Hardware Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 443Software Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 443Network Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 443Disk Storage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 444

    RAC Characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 444Server Parameter File Characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 445RAC-Related Initialization Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 446Dynamic Performance Views . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 446

    00-FM.indd 16 27/04/15 11:13 AM

  • Oracle TIGHT / Oracle Database 12c DBA Handbook / Bob Bryla / 878-1 Oracle TIGHT / Oracle Database 12c DBA Handbook / Bob Bryla / 878-1

    Contents xviixvi Oracle Database 12c DBA Handbook

    RAC Maintenance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 448Starting Up a RAC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 448Redo Logs in a RAC Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 448Undo Tablespaces in a RAC Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 449Failover Scenarios and TAF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 449Tuning a RAC Node . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 451

    Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 451

    13 Backup and Recovery Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 453Backup Capabilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 454Logical Backups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 454Physical Backups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 455

    Offline Backups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 455Online Backups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 456

    Using Data Pump Export and Import . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 457Creating a Directory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 457Data Pump Export Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 458Starting a Data Pump Export Job . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 462Data Pump Import Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 466

    Implementing Offline Backups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 474Implementing Online Backups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 475

    Getting Started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 475Performing Online Database Backups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 477

    Integration of Backup Procedures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 478Integration of Logical and Physical Backups . . . . . . . . . . . . . . . . . . . . . . . . . . . 478Integration of Database and Operating System Backups . . . . . . . . . . . . . . . . . . 479

    Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 480

    14 Using Recovery Manager(RMAN) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 481RMAN Features and Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 482

    RMAN Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 483RMAN vs. Traditional Backup Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 484Backup Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 486

    Overview of RMAN Commands and Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 487Running SQL Commands in RMAN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 487Frequently Used Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 488Setting Up a Repository . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 490Registering a Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 491Persisting RMAN Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 493Initialization Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 497Data Dictionary and Dynamic Performance Views . . . . . . . . . . . . . . . . . . . . . . 498

    Backup Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 500Full Database Backups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 500Tablespace Backups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 503Datafile Backups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 506Image Copy Backups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 506

    00-FM.indd 17 27/04/15 11:13 AM

  • Oracle TIGHT / Oracle Database 12c DBA Handbook / Bob Bryla / 878-1 Oracle TIGHT / Oracle Database 12c DBA Handbook / Bob Bryla / 878-1

    xviii Oracle Database 12c DBA Handbook

    Control File, SPFILE Backup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 507Archived Redo Log Backup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 509Incremental Backups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 509Incrementally Updated Backups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 511Incremental Backup Block Change Tracking . . . . . . . . . . . . . . . . . . . . . . . . . . . 513Using a Fast Recovery Area . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 515Validating Backups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 516

    Recovery Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 519Block Media Recovery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 519Restoring a Control File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 520Restoring a Tablespace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 520Restoring a Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 522Restoring a Datafile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 524Restoring an Entire Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 524Validating Restore Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 525Point-in-Time Recovery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 527Data Recovery Advisor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 527

    Miscellaneous Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 531Cataloging Other Backups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 531Catalog Maintenance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 532REPORT and LIST . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 533

    Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 534

    15 Oracle Data Guard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 537Data Guard Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 538

    Physical vs. Logical Standby Databases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 539Data Protection Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 539

    LOG_ARCHIVE_DEST_n Parameter Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 540Creating the Standby Database Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 542

    Preparing the Primary Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 543Creating Logical Standby Databases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 547

    Using Real-Time Apply . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 549Managing Gaps in Archive Log Sequences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 550Managing Roles: Switchovers and Failovers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 550

    Switchovers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 550Failovers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 554

    Administering the Databases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 555Startup and Shutdown of Physical Standby Databases . . . . . . . . . . . . . . . . . . . . 555Opening Physical Standby Databases in Read-Only Mode . . . . . . . . . . . . . . . . 556Managing Datafiles in Data Guard Environments . . . . . . . . . . . . . . . . . . . . . . . 556Performing DDL on a Logical Standby Database . . . . . . . . . . . . . . . . . . . . . . . . 557

    Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 557

    16 Miscellaneous High Availability Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . 559Recovering Dropped Tables Using Flashback Drop . . . . . . . . . . . . . . . . . . . . . . . . . . . . 560The Flashback Database Command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 562

    00-FM.indd 18 27/04/15 11:13 AM

  • Oracle TIGHT / Oracle Database 12c DBA Handbook / Bob Bryla / 878-1 Oracle TIGHT / Oracle Database 12c DBA Handbook / Bob Bryla / 878-1

    Contents xixxviii Oracle Database 12c DBA Handbook

    Using LogMiner . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 564How LogMiner Works . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 565Extracting the Data Dictionary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 565Analyzing One or More Redo Log Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 566

    Online Object Reorganization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 569Creating Indexes Online . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 570Rebuilding Indexes Online . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 570Coalescing Indexes Online . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 570Rebuilding Index-Organized Tables Online . . . . . . . . . . . . . . . . . . . . . . . . . . . 570Redefining Tables Online . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 570Moving a Datafile Online . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 572

    Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 573

    PART IVNetworked Oracle

    17 Oracle Net . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 577Overview of Oracle Net . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 578

    Connect Descriptors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 581Net Service Names . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 582Replacing tnsnames.ora with Oracle Internet Directory . . . . . . . . . . . . . . . . . . 583Listeners . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 583

    Using the Oracle Net Configuration Assistant . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 588Configuring the Listener . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 588Naming Methods Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 590Local Net Service Name Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 590Directory Usage Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 591

    Using the Oracle Net Manager . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 592Starting the Listener Server Process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 594Controlling the Listener Server Process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 596The Oracle Connection Manager . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 598

    Using the Oracle Connection Manager . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 599Configuring the Oracle Connection Manager . . . . . . . . . . . . . . . . . . . . . . . . . . 600Using the Connection Manager Control Utility (CMCTL) . . . . . . . . . . . . . . . . . 601

    Directory Naming with Oracle Internet Directory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 603Oracle Internet Directory Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 603Setting Up an Oracle Internet Directory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 604

    Using Easy Connect Naming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 604Using Database Links . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 605Tuning Oracle Net . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 607

    Limiting Resource Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 608Using Compression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 609Debugging Connection Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 609

    Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 610

    00-FM.indd 19 27/04/15 11:13 AM

  • Oracle TIGHT / Oracle Database 12c DBA Handbook / Bob Bryla / 878-1 Oracle TIGHT / Oracle Database 12c DBA Handbook / Bob Bryla / 878-1

    xx Oracle Database 12c DBA Handbook

    18 Managing Large Databases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 611Creating Tablespaces in a VLDB Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 613

    Bigfile Tablespace Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 613Creating and Modifying Bigfile Tablespaces . . . . . . . . . . . . . . . . . . . . . . . . . . . 614Bigfile Tablespace ROWID Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 615DBMS_ROWID and Bigfile Tablespaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 616Using DBVERIFY with Bigfile Tablespaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . 618Bigfile Tablespace Initialization Parameter Considerations . . . . . . . . . . . . . . . . 619Bigfile Tablespace Data Dictionary Changes . . . . . . . . . . . . . . . . . . . . . . . . . . . 620

    Advanced Oracle Table Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 620Index-Organized Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 621Global Temporary Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 622External Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 624Partitioned Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 625Materialized Views . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 652

    Using Bitmap Indexes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 653Understanding Bitmap Indexes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 653Using Bitmap Indexes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 654Using Bitmap Join Indexes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 654

    Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 655

    19 Managing Distributed Databases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 657Remote Queries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 659Remote Data Manipulation: Two-Phase Commit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 660Dynamic Data Replication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 661Managing Distributed Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 662

    The Infrastructure: Enforcing Location Transparency . . . . . . . . . . . . . . . . . . . . . 663Managing Database Links . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 667Managing Database Triggers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 669Managing Materialized Views . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 670Using DBMS_MVIEW and DBMS_ADVISOR . . . . . . . . . . . . . . . . . . . . . . . . . . 674What Kind of Refreshes Can Be Performed? . . . . . . . . . . . . . . . . . . . . . . . . . . . 685Using Materialized Views to Alter Query Execution Paths . . . . . . . . . . . . . . . . . 689

    Managing Distributed Transactions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 690Resolving In-Doubt Transactions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 691Commit Point Strength . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 691

    Monitoring Distributed Databases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 692Tuning Distributed Databases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 693Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 695

    Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 697

    00-FM.indd 20 27/04/15 11:13 AM

  • Oracle TIGHT / Oracle Database 12c DBA Handbook / Bob Bryla / 878-1 Oracle TIGHT / Oracle Database 12c DBA Handbook / Bob Bryla / 878-1

    Acknowledgments

    Many technical books need the expertise of more than one person, and this one is no exception. The people I collaborated with for this book at Oracle Open World, Oracle Support, and in the Oracle Partner Network are too numerous to mention but all played an important role in this book.

    Thanks also go out to all the people at McGraw-Hill Education who kept this book ona reasonable schedule and learned to be even more patient with me than ever before, including Paul Carlstroem and Amanda Russell. Thanks also to Scott Gossett, who gave me good advice when the theoretical met the practical.

    Many of my professional colleagues at Epic were a source of both inspiration and guidance: James Slager, Scott Hinman, Joe Obbish, and Lonny Niederstadt. In this case, thewhole is truly greater than the sum of its parts.

    If you have any questions or comments about any part of this book, please do not hesitate to contact me at [email protected].

    Bob Bryla

    xxi

    00-FM.indd 21 27/04/15 11:13 AM

  • This page intentionally left blank

  • Oracle TIGHT / Oracle Database 12c DBA Handbook / Bob Bryla / 878-1 Oracle TIGHT / Oracle Database 12c DBA Handbook / Bob Bryla / 878-1

    Introduction

    Whether youre an experienced DBA, a new DBA, or an application developer, you need to understand how Oracle Database 12cs features can help you best meet your customers needs. In this book, you will find coverage of the newest features (including the In-Memory option) as well as ways of merging those features into the management of an Oracle database. The emphasis throughout is on managing the databases capabilities in an effective, efficient manner to deliver a quality product. The end result will be a database that is dependable, robust, secure, and extensible.

    Several components are critical to this goal, and youll see all of them covered here in depth after you are introduced to the Oracle Architecture, Oracle 12c upgrade issues, and tablespace planning in Part I; a well-designed logical and physical database architecture will improve performance and ease administration by properly distributing database objects.

    Youll see appropriate monitoring, security, and tuning strategies for standalone and networked databases in Part II of this book. Backup and recovery strategies are provided to help ensure the databases recoverability. Each section focuses on both the features and the proper planning and management techniques for each area. Scalability and manageability are undeniably the biggest enhancements in Oracle Database 12c. Using pluggable databases (also known as multitenant or container databases) utilizes your server resources more effectively than single-instance pre-Oracle Database 12c databases, which means you can run many more database instances on a given server with the same performance as if you were running them on different servers. Because its easy and fast to unplug a pluggable database from a container database and plug it back into another container database, youcan migrate one or more pluggable databases to other servers when the need arises.

    High availability is covered in all of its flavors in Part III: an introduction to Real Application Clusters (RAC), an extensive exposition on Recovery Manager (RMAN), and an overview ofhow to administer an Oracle Data Guard environment are a few of the topics covered in Part III.

    xxiii

    00-FM.indd 23 27/04/15 11:13 AM

  • Oracle TIGHT / Oracle Database 12c DBA Handbook / Bob Bryla / 878-1 Oracle TIGHT / Oracle Database 12c DBA Handbook / Bob Bryla / 878-1

    xxiv Oracle Database 12c DBA Handbook

    Networking issues and the management of distributed and client/server databases are thoroughly covered. Oracle Net, networking configurations, materialized views, location transparency, and everything else you need to successfully implement a distributed or client/server database are described in detail in Part IV of this book. Youll also find real-world examples for every major configuration.

    In addition to the commands needed to perform DBA activities, you will also see the Oracle Enterprise Manager Cloud Control 12c web pages from which you can perform similar functions. By following the techniques in this book, your systems can be designed and implemented so well that tuning efforts will be minimal. Administering the database will become easier as the users get a better product, while the database worksand works well.

    Last but not least, no book with code samples would be complete without providing you the source code for the examples. Please visit www.OraclePressBooks.com to get the code sample file 12c DBA Handbook Code Listings .zip .

    00-FM.indd 24 27/04/15 11:13 AM

    http://www.OraclePressBooks.com

  • Oracle TIGHT / Oracle Database 12c DBA Handbook / Bob Bryla / 878-1 / Blind folio 1

    PARTI

    Database Architecture

    01-ch01.indd 1 13/05/15 9:53 AM

  • This page intentionally left blank

  • Oracle TIGHT / Oracle Database 12c DBA Handbook / Bob Bryla / 878-1 Blind folio: 3

    CHAPTER1

    Getting Started with the Oracle Architecture

    01-ch01.indd 3 13/05/15 9:54 AM

  • Oracle TIGHT / Oracle Database 12c DBA Handbook / Bob Bryla / 878-1 Oracle TIGHT / Oracle Database 12c DBA Handbook / Bob Bryla / 878-1

    4 Oracle Database 12c DBA Handbook

    Oracle Database 12c is an evolutionary step from the previous release, Oracle Database 11g, which, in turn, was a truly revolutionary step from Oracle Database 10g in terms of its set it and forget it features. Oracle 12c continues the tradition of feature enhancement by making execution plan management more automated, adding new virtualization features, and significantly improving availability and failover capabilities. Part I of this book covers the basics of the Oracle architecture and lays the foundation for deploying a successful Oracle infrastructure by giving practical advice for a new installation or upgrading from a previous release of Oracle. Toprovide a good foundation for the Oracle 12c software, I cover server hardware and operating system configuration issues in the relevant sections.

    In Part II of this book, I will cover several areas relevant to the day-to-day maintenance and operation of an Oracle 12c database. The first chapter in Part II discusses the requirements that a DBA needs to gather long before you mount the Oracle ISO image on your server. Successive chapters deal with ways the DBA can manage disk space, CPU usage, and adjust Oracle parameters to optimize the servers resources, using a variety of tools at the DBAs disposal for monitoring database performance. Query optimization in Oracle 12c is more automated than ever with the option to change a query plan on the fly if the optimizer sees that its original estimates for cardinality were off by a significant factor.

    Part III of this book focuses on the high-availability aspects of Oracle 12c. This includes using Oracles Recovery Manager (RMAN) to perform and automate database backups and recovery, along with other features, such as Oracle Data Guard, to provide a reliable and easy way to recover from a database failure. Features new to Oracle 12c such as container databases (multitenant databases) with their corresponding pluggable databases extend the concept of transportable tablespaces to the entire database in addition to more efficiently using the resources of a server hosting one or more container databases. Last, but certainly not least, we will explore how Oracle 12c Real Application Clusters (RAC) can at the same time provide extreme scalability and transparent failover capabilities to a database environment. Even if you dont use Oracle 12cs RAC features, the standby features make Oracle 12c almost as available as a clustered solution; being able to easily switch between standby and primary databases as well as query aphysical standby database provides a robust high-availability solution until you are ready to implement a RAC database.

    In Part IV of this book, we will cover a variety of issues revolving around Networked Oracle. We cover not only how Oracle Net can be configured in an N-tier environment, but also howwe manage large and distributed databases that may reside in neighboring cities or around the world.

    In this chapter, we cover the basics of Oracle Database 12c, highlighting many of the features we will cover in the rest of the book as well as the basics of installing Oracle 12c using Oracle Universal Installer (OUI) and the Database Configuration Assistant (DBCA). We will take a tour of the elements that compose an instance of Oracle 12c, ranging from memory structures and disk structures to initialization parameters, tables, indexes, and PL/SQL. Each of these elements plays a large role in making Oracle 12c a highly scalable, available, and secure environment.

    An Overview of Databases and InstancesAlthough the terms database and instance are often used interchangeably, they are quite different. They are very distinct entities in an Oracle datacenter, as you shall see in the following sections.

    01-ch01.indd 4 13/05/15 9:54 AM

  • Oracle TIGHT / Oracle Database 12c DBA Handbook / Bob Bryla / 878-1 Oracle TIGHT / Oracle Database 12c DBA Handbook / Bob Bryla / 878-1

    Chapter 1: Getting Started with the Oracle Architecture 5

    DatabasesA database is a collection of data on disk in one or more files on a database server that collects and maintains related information. The database consists of various physical and logical structures, the table being the most important logical structure in the database. A table consists of rows and columns containing related data. At a minimum, a database must have at least tables to store useful information. Figure 1-1 shows a sample table containing four rows and three columns. The data in each row of the table is related: Each row contains information about a particular employee in the company.

    In addition, a database provides a level of security to prevent unauthorized access to the data. Oracle Database 12c provides many mechanisms to facilitate the security necessary to keep confidential data confidential. Oracle Security and access control are covered in more detail in Chapter 9.

    Files composing a database fall into two broad categories: database files and non-database files. The distinction lies in what kind of data is stored in each. Database files contain data and metadata; non-database files contain initialization parameters, logging information, and so forth. Database files are critical to the ongoing operation of the database on a moment-by-moment basis. Each of these physical storage structures is discussed later, in the section titled Oracle Physical Storage Structures.

    InstancesThe main components of a typical enterprise server are one or more CPUs (each with multiple cores), disk space, and memory. Whereas the Oracle database is stored on a servers disk, an Oracle instance exists in the servers memory. An Oracle instance is composed of a large block of memory allocated in an area called the System Global Area (SGA), along with a number of background processes that interact between the SGA and the database files on disk.

    FIGURE 1-1. Sample database table

    01-ch01.indd 5 13/05/15 9:54 AM

    www.allitebooks.com

    http://www.allitebooks.org

  • Oracle TIGHT / Oracle Database 12c DBA Handbook / Bob Bryla / 878-1 Oracle TIGHT / Oracle Database 12c DBA Handbook / Bob Bryla / 878-1

    6 Oracle Database 12c DBA Handbook

    In an Oracle RAC, more than one instance will use the same database. Although the instances that share the database can be on the same server, most likely the instances will be on separate servers that are connected by a high-speed interconnect and access a database that resides on a specialized RAID-enabled disk subsystem. An Oracle Exadata database appliance is an example of database servers, I/O servers, and disk storage combined into one or more cabinets and is optimized for a RAC environment including dual InfiniBand interfaces to connect all of these devices at speeds up to 40 Gbps per interface. More details on how a RAC installation is configured are provided in Chapter 11.

    Oracle Logical Storage StructuresThe datafiles in an Oracle database are grouped together into one or more tablespaces. Within each tablespace, the logical database structures, such as tables and indexes, are segments that are further subdivided into extents and blocks. This logical subdivision of storage allows Oracle to have more efficient control over disk space usage. Figure 1-2 shows the relationship between the logical storage structures in a database.

    TablespacesAn Oracle tablespace consists of one or more datafiles; a datafile can be a part of one and only one tablespace. For an installation of Oracle 12c, a minimum of two tablespaces are created: theSYSTEM tablespace and the SYSAUX tablespace; a default installation of Oracle 12c creates six tablespaces.

    FIGURE 1-2. Logical storage structures

    01-ch01.indd 6 13/05/15 9:54 AM

  • Oracle TIGHT / Oracle Database 12c DBA Handbook / Bob Bryla / 878-1 Oracle TIGHT / Oracle Database 12c DBA Handbook / Bob Bryla / 878-1

    Chapter 1: Getting Started with the Oracle Architecture 7

    Oracle Database 10g and later allow you to create a special kind of tablespace called a bigfile tablespace, which can be as large as 128TB (terabytes). Using bigfiles makes tablespace management completely transparent to the DBA; in other words, the DBA can manage the tablespace as a unit without worrying about the size and structure of the underlying datafiles.

    Using Oracle Managed Files (OMF) can make tablespace datafile management even easier. With OMF, the DBA specifies one or more locations in the file system where datafiles, control files, and redo log files will reside, and Oracle automatically handles the naming and management of these files. I discuss OMF in more detail in Chapter 4.

    If a tablespace is temporary, the tablespace itself is permanent; only the segments saved in the tablespace are temporary. A temporary tablespace can be used for sorting operations and for tables that exist only for the duration of the users session. Dedicating a tablespace for these kinds of operations helps to reduce the I/O contention between temporary segments and permanent segments stored in another tablespace, such as tables.

    Tablespaces can be either dictionary managed or locally managed. In a dictionary-managed tablespace, extent management is recorded in data dictionary tables. Therefore, even if all application tables are in the USERS tablespace, the SYSTEM tablespace will still be accessed for managing Data Manipulation Language (DML) on application tables. Because all users and applications must use the SYSTEM tablespace for extent management, this creates a potential bottleneck for write-intensive applications. In a locally managed tablespace, Oracle maintains a bitmap in each datafile of the tablespace to track space availability. Only quotas are managed in the data dictionary, dramatically reducing the contention for data dictionary tables. There is really no good reason for creating dictionary-managed tablespaces. When you install Oracle 12c, the SYSTEM and SYSAUX tablespaces must be locally managed. For importing transportable tablespaces, a tablespace can be dictionary managed but it will be read-only.

    BlocksA database block is the smallest unit of storage in the Oracle database. The size of a block is a specific number of bytes of storage within a given tablespace within the database.

    A block is usually a multiple of the operating system block size to facilitate efficient disk I/O. The default block size is specified by the Oracle initialization parameter DB_BLOCK_SIZE. As many as four other block sizes may be defined for other tablespaces in the database, although the blocks in the SYSTEM, SYSAUX, and any temporary tablespaces must be of the size DB_BLOCK_SIZE.

    The default block size is 8K and all Oracle testing is performed using 8K blocks. Oracle best practices suggest using an 8K block size for all tablespaces unless there is a compelling reason to use a different size. One reason could be that the average row length for a table is 20K. Therefore, you might choose to use 32K blocks, but you should fully test to see if there is a performance gain.

    ExtentsThe extent is the next level of logical grouping in the database. An extent consists of one or more database blocks. When you enlarge a database object, the space added to the object is allocated as an extent.

    SegmentsThe next level of logical grouping in a database is the segment. A segment is a group of extents that form a database object that Oracle treats as a unit, such as a table or index. As a result, this is typically the smallest unit of storage that an end user of the database will deal with. Four types of

    01-ch01.indd 7 13/05/15 9:54 AM

  • Oracle TIGHT / Oracle Database 12c DBA Handbook / Bob Bryla / 878-1 Oracle TIGHT / Oracle Database 12c DBA Handbook / Bob Bryla / 878-1

    8 Oracle Database 12c DBA Handbook

    segments are found in an Oracle database: table segments (non-partitioned tables and each partition of a partitioned table), index segments, temporary segments, and rollback segments.

    Data SegmentEvery table in the database resides in a single data segment, consisting of one or more extents; Oracle allocates more than one segment for a table if it is a partitioned table or a clustered table. Partitioned and clustered tables are discussed later in this chapter. Data segments include LOB (large object) segments that store LOB data referenced by a LOB locator column in a table segment (if the LOB is not stored inline in the table).

    Index SegmentEach index is stored in its own index segment. As with partitioned tables, each partition of a partitioned index is stored in its own segment. Included in this category are LOB index segments; a tables non-LOB columns, a tables LOB columns, and the LOBs associated indexes can all reside in their own tablespace to improve performance.

    Temporary SegmentWhen a users SQL statement needs disk space to complete an operation, such as a sorting operatio