APress - Expert Oracle Database Architecture 9I And 10G Programming Techniques And Solutions.pdf

(4868 KB) Pobierz
30297370 UNPDF
30297370.004.png
Expert Oracle Database
Architecture
9 i and 10 g Programming
Techniques and Solutions
Thomas Kyte
30297370.005.png 30297370.006.png 30297370.007.png
Expert Oracle Database Architecture: 9 i and 10 g Programming Techniques and Solutions
Copyright © 2005 by Thomas Kyte
All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means,
electronic or mechanical, including photocopying, recording, or by any information storage or retrieval
system, without the prior written permission of the copyright owner and the publisher.
ISBN (pbk): 1-59059-530-0
Printed and bound in the United States of America 9 8 7 6 5 4 3 2 1
Trademarked names may appear in this book. Rather than use a trademark symbol with every occurrence
of a trademarked name, we use the names only in an editorial fashion and to the benefit of the trademark
owner, with no intention of infringement of the trademark.
Lead Editor: Tony Davis
Technical Reviewer: Jonathan Lewis, Roderick Manalac, Michael Möller, Gabe Romanescu
Editorial Board: Steve Anglin, Dan Appleman, Ewan Buckingham, Gary Cornell, Tony Davis,
Jason Gilmore, Jonathan Hassell, Chris Mills, Dominic Shakeshaft, Jim Sumser
Associate Publisher: Grace Wong
Project Manager: Sofia Marchant
Copy Edit Manager: Nicole LeClerc
Assistant Production Director: Kari Brooks-Copony
Production Editor: Katie Stence
Compositor: Dina Quan
Proofreader: Linda Marousek
Indexer: Broccoli Information Management
Artist: Kinetic Publishing Services, LLC
Interior Designer: Van Winkle Design Group
Cover Designer: Kurt Krames
Manufacturing Director: Tom Debolski
Distributed to the book trade worldwide by Springer-Verlag New York, Inc., 233 Spring Street, 6th Floor,
New York, NY 10013. Phone 1-800-SPRINGER, fax 201-348-4505, e-mail orders-ny@springer-sbm.com , or
visit http://www.springeronline.com .
For information on translations, please contact Apress directly at 2560 Ninth Street, Suite 219, Berkeley,
CA 94710. Phone 510-549-5930, fax 510-549-5939, e-mail info@apress.com , or visit http://www.apress.com .
The information in this book is distributed on an “as is” basis, without warranty. Although every precaution
has been taken in the preparation of this work, neither the author(s) nor Apress shall have any liability to
any person or entity with respect to any loss or damage caused or alleged to be caused directly or indi-
rectly by the information contained in this work.
The source code for this book is available to readers at http://www.apress.com in the Source Code section.
30297370.001.png
Contents
Foreword . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xi
About the Author . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiv
About the Technical Reviewers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xv
Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvi
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvii
Setting Up Your Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxv
CHAPTER 1 Developing Successful Oracle Applications . . . . . . . . . . . . . . . 1
My Approach . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
The Black Box Approach . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
How (and How Not) to Develop Database Applications . . . . . . . . . . . . . . . . 9
Understanding Oracle Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Understanding Concurrency Control . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Multi-Versioning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
Database Independence? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
“How Do I Make It Run Faster?” . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
The DBA–Developer Relationship . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
CHAPTER 2 Architecture Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
Defining Database and Instance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
The SGA and Background Processes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
Connecting to Oracle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
Dedicated Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
Shared Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
Mechanics of Connecting over TCP/IP . . . . . . . . . . . . . . . . . . . . . . . . 60
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
iii
30297370.002.png
iv
CONTENTS
CHAPTER 3 Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
Parameter Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
What Are Parameters? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
Legacy init.ora Parameter Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
Server Parameter Files (SPFILEs) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
Parameter File Wrap-Up . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
Trace Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
Requested Trace Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
Trace Files Generated in Response to Internal Errors . . . . . . . . . . . . 83
Trace File Wrap-Up . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
Alert File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
Data Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
A Brief Review of File System Mechanisms . . . . . . . . . . . . . . . . . . . . 89
The Storage Hierarchy in an Oracle Database . . . . . . . . . . . . . . . . . . 90
Dictionary-Managed and Locally-Managed Tablespaces . . . . . . . . 94
Temp Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
Control Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
Redo Log Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
Online Redo Log . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
Archived Redo Log . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
Password Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
Change Tracking File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
Flashback Log Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
Flashback Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
Flash Recovery Area . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
DMP Files (EXP/IMP Files) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
Data Pump Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
Flat Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
CHAPTER 4 Memory Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
The Process Global Area and User Global Area . . . . . . . . . . . . . . . . . . . . . 115
Manual PGA Memory Management . . . . . . . . . . . . . . . . . . . . . . . . . 116
Automatic PGA Memory Management . . . . . . . . . . . . . . . . . . . . . . . 123
Choosing Between Manual and Auto Memory Management . . . . 133
PGA and UGA Wrap-Up . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135
The System Global Area . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135
Fixed SGA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
Redo Buffer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140
30297370.003.png
Zgłoś jeśli naruszono regulamin