Pro Oracle Database 11
g
Administration
■ ■ ■
Darl Kuhn
Pro Oracle Database 11
g
Administration
Copyright © 2010 by Darl Kuhn
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-13 (pbk): 978-1-4302-2970-4
ISBN-13 (electronic): 978-1-4302-2971-1
Printed and bound in the United States of America 9 8 7 6 5 4 3 2 1
Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark.
The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to proprietary rights.
President and Publisher: Paul Manning
Lead Editor: Jonathan Gennick
Technical Reviewer: Bernard Lopuz
Editorial Board: Steve Anglin, Mark Beckner, Ewan Buckingham, Gary Cornell, Jonathan Gennick, Jonathan Hassell, Michelle Lowman, Matthew Moodie, Duncan Parkes, Jeffrey Pepper, Frank Pohlmann, Douglas Pundick, Ben Renow-Clarke, Dominic Shakeshaft, Matt Wade, Tom Welsh
Coordinating Editor: Anita Castro
Copy Editors: Mary Behr and Tiffany Taylor
Compositor: MacPS, LLC
Indexer: BIM Indexing & Proofreading Services
Artist: April Milne
Cover Designer: Anna Ishchenko
Distributed to the book trade worldwide by Springer Science+Business Media, LLC., 233
Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail [email protected], or visit www.springeronline.com.
For information on translations, please e-mail [email protected] or visit www.apress.com.
Apress and friends of ED books may be purchased in bulk for academic, corporate, or promotional use. eBook versions and licenses are also available for most titles. For more information, reference our Special Bulk Sales–eBook Licensing web page at www.apress.com/info/bulksales.
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 indirectly by the information contained in this work.
■ CONTENTS
Upgrading Oracle Software ........................................................................................... 15
Reinstalling After Failed Installation ............................................................................. 16
Applying Interim Patches .............................................................................................. 17
Installing Remotely with the Graphical Installer ........................................................... 18
Step 1. Install X Software and Networking Utilities on the Local PC ................................................... 19
Step 2. Start an X Session on the Local Computer .............................................................................. 19
Step 3. Copy the Oracle Installation Media to the Remote Server ....................................................... 20
Step 4. Run the xhost Command .......................................................................................................... 21
Step 5. Log In to the Remote Computer from X ................................................................................... 21
Step 6. Ensure that the DISPLAY Variable Is Set Correctly on the Remote Computer .......................... 21
Step 7. Execute the runInstaller Utility ................................................................................................. 22
Step 8. Troubleshoot ............................................................................................................................ 22
Summary ....................................................................................................................... 23
■Chapter 2: Implementing a Database .................................................................. 25
Setting Operating System Variables ............................................................................. 25
A Manually Intensive Approach ............................................................................................................ 26
Oracle’s Approach to Setting OS Variables .......................................................................................... 26
My Approach to Setting OS Variables .................................................................................................. 27
Creating a Database ...................................................................................................... 29
Step 1. Set the Operating System Variables ........................................................................................ 29
Step 2: Configure the Initialization File ................................................................................................ 30
Step 3: Create the Required Directories ............................................................................................... 32
Step 4: Create the Database ................................................................................................................ 32
Step 5. Create a Data Dictionary .......................................................................................................... 36
Configuring and Implementing the Listener .................................................................. 37
Creating a Password File .............................................................................................. 39
Starting and Stopping the Database ............................................................................. 40
Understanding Authentication .............................................................................................................. 41
Starting the Database .......................................................................................................................... 41
vi
■ CONTENTS
Stopping the Database ......................................................................................................................... 43
Using a Response File to Create a Database ................................................................ 45
Dropping a Database ..................................................................................................... 46
How Many Databases on One Server? .......................................................................... 47
Summary ....................................................................................................................... 50
■Chapter 3: Configuring an Efficient Environment ................................................ 51
Customizing Your Operating System Command Prompt ............................................... 52
Customizing Your SQL Prompt ...................................................................................... 54
Creating Shortcuts for Frequently Used Commands ..................................................... 55
Using Aliases ........................................................................................................................................ 55
Using a Function .................................................................................................................................. 56
Rerunning Commands Quickly ...................................................................................... 57
Scrolling with the Up and Down Arrow Keys ....................................................................................... 58
Pressing Ctrl+P and Ctrl+N .................................................................................................................. 58
Listing the Command History ............................................................................................................... 58
Searching in Reverse ........................................................................................................................... 59
Setting the Command Editor ......................................................................................... 59
Developing Standard Scripts ........................................................................................ 60
dba_setup ............................................................................................................................................ 60
dba_fcns .............................................................................................................................................. 61
tbsp_chk.bsh ....................................................................................................................................... 62
conn.bsh .............................................................................................................................................. 64
filesp.bsh ............................................................................................................................................. 65
login.sql ................................................................................................................................................ 66
top.sql .................................................................................................................................................. 66
lock.sql ................................................................................................................................................. 67