Bob Bryla - Oracle Database.pdf

(8963 KB) Pobierz
Oracle Database Foundations
Oracle Database
Foundations
Bob Bryla
San Francisco
London
15731615.143.png 15731615.154.png 15731615.165.png 15731615.176.png 15731615.001.png 15731615.012.png 15731615.023.png 15731615.034.png 15731615.045.png 15731615.056.png 15731615.067.png 15731615.078.png 15731615.089.png 15731615.100.png 15731615.103.png 15731615.104.png 15731615.105.png 15731615.106.png 15731615.107.png 15731615.108.png 15731615.109.png 15731615.110.png 15731615.111.png 15731615.112.png 15731615.113.png 15731615.114.png 15731615.115.png 15731615.116.png 15731615.117.png 15731615.118.png 15731615.119.png 15731615.120.png 15731615.121.png 15731615.122.png 15731615.123.png 15731615.124.png 15731615.125.png 15731615.126.png
Associate Publisher: Neil Edde
Acquisitions and Developmental Editor: Maureen Adams
Production Editor: Susan Berge
Copyeditor: Linda S. Recktenwald
Compositor: Craig Woods, Happenstance Type-O-Rama
Graphic Illustrator: Jeff Wilson, Happenstance Type-O-Rama
Proofreaders: Amy J. Rasmussen, Nancy Riddiough
Indexer: Ted Laux
Book Designer: Judy Fung
Cover Designer: Ingalls + Associates
Cover Photo: Jerry Driendl, Taxi
Copyright © 2004 SYBEX Inc., 1151 Marina Village Parkway, Alameda, CA 94501. World rights reserved. No part of this
publication may be stored in a retrieval system, transmitted, or reproduced in any way, including but not limited to photo-
copy, photograph, magnetic, or other record, without the prior agreement and written permission of the publisher.
An earlier version of this book was published under the title Oracle9i DBA JumpStart © 2003 SYBEX Inc.
Library of Congress Card Number: 2004109313
ISBN: 0-7821-4372-5
SYBEX and the SYBEX logo are either registered trademarks or trademarks of SYBEX Inc. in the United States and/or other countries.
Screen reproductions produced with FullShot 99. FullShot 99 © 1991-1999 Inbit Incorporated. All rights reserved.
FullShot is a trademark of Inbit Incorporated.
Internet screen shot(s) using Microsoft Internet Explorer 6 reprinted by permission from Microsoft Corporation.
TRADEMARKS: SYBEX has attempted throughout this book to distinguish proprietary trademarks from descriptive terms by fol-
lowing the capitalization style used by the manufacturer.
The author and publisher have made their best efforts to prepare this book, and the content is based upon final release software
whenever possible. Portions of the manuscript may be based upon pre-release versions supplied by software manufacturer(s). The
author and the publisher make no representation or warranties of any kind with regard to the completeness or accuracy of the con-
tents herein and accept no liability of any kind including but not limited to performance, merchantability, fitness for any particular
purpose, or any losses or damages of any kind caused or alleged to be caused directly or indirectly from this book.
Manufactured in the United States of America
10 9 8 7 6 5 4 3 2 1
15731615.127.png 15731615.128.png 15731615.129.png 15731615.130.png 15731615.131.png 15731615.132.png 15731615.133.png 15731615.134.png 15731615.135.png 15731615.136.png 15731615.137.png 15731615.138.png 15731615.139.png 15731615.140.png 15731615.141.png 15731615.142.png 15731615.144.png 15731615.145.png 15731615.146.png 15731615.147.png 15731615.148.png 15731615.149.png 15731615.150.png 15731615.151.png 15731615.152.png 15731615.153.png 15731615.155.png 15731615.156.png 15731615.157.png 15731615.158.png 15731615.159.png 15731615.160.png 15731615.161.png 15731615.162.png 15731615.163.png 15731615.164.png 15731615.166.png
For MCL and the kids.
15731615.167.png 15731615.168.png 15731615.169.png 15731615.170.png 15731615.171.png 15731615.172.png 15731615.173.png 15731615.174.png 15731615.175.png 15731615.177.png 15731615.178.png 15731615.179.png 15731615.180.png 15731615.181.png 15731615.182.png 15731615.183.png 15731615.184.png 15731615.185.png 15731615.186.png 15731615.002.png 15731615.003.png 15731615.004.png 15731615.005.png 15731615.006.png 15731615.007.png 15731615.008.png 15731615.009.png 15731615.010.png 15731615.011.png 15731615.013.png 15731615.014.png 15731615.015.png 15731615.016.png 15731615.017.png 15731615.018.png 15731615.019.png 15731615.020.png
Acknowledgments
I couldn’t have written this book without the help of many talented and creative people.
I would like to thank Neil Edde, associate publisher, and Maureen Adams, acquisitions editor, for recognizing
the need for an introductory Oracle DBA text. Many thanks to production editor Susan Berge and copyeditor
Linda Recktenwald for their valuable advice. Thanks also to technical editor Betty MacEwen for her attention
to detail and helpful suggestions throughout the book.
The nature of this book required a great deal of artwork. Jeff Wilson and the rest of Happenstance Type-O-Rama
did an excellent job of creating artwork that was appropriate for the book. They say a picture is worth a thousand
words, and their art is an essential part of this book. Somehow they were able to decipher my Microsoft Word
cave drawings and turn them into real graphics.
Many of my professional colleagues at both Lands’ End and Greenbrier & Russel were a source of both inspi-
ration and guidance. Also, regards to my long-lost friend from fourth grade, Janice, who I’m sure is a DBA out
there somewhere.
Finally, I want to thank my family for all of their support and patience. I was still able to give the kids a bath,
play some cards, and read books at bedtime, even with the short deadlines. The journey wouldn’t have been
half the fun without them.
15731615.021.png 15731615.022.png 15731615.024.png 15731615.025.png 15731615.026.png 15731615.027.png 15731615.028.png 15731615.029.png 15731615.030.png 15731615.031.png 15731615.032.png 15731615.033.png 15731615.035.png 15731615.036.png 15731615.037.png 15731615.038.png 15731615.039.png 15731615.040.png 15731615.041.png 15731615.042.png 15731615.043.png 15731615.044.png 15731615.046.png 15731615.047.png 15731615.048.png 15731615.049.png 15731615.050.png 15731615.051.png 15731615.052.png 15731615.053.png 15731615.054.png 15731615.055.png 15731615.057.png 15731615.058.png 15731615.059.png 15731615.060.png 15731615.061.png
Contents
Introduction
xiii
Chapter 1
Relational Database Concepts
1
Are Spreadsheets Like Databases? . . . . . . . . . . . . . . . . . . . 2
Relational Databases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Tables, Rows, and Columns . . . . . . . . . . . . . . . . . . . . . 4
Primary Keys, Datatypes, and Foreign Keys . . . . . . . . . 4
Data Modeling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Object-Relational Databases . . . . . . . . . . . . . . . . . . . . . . . 8
Abstraction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Methods and Encapsulation . . . . . . . . . . . . . . . . . . . . . 9
Inheritance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Object-Relational Support . . . . . . . . . . . . . . . . . . . . . . 10
Terms to Know . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Chapter 2
SQL*Plus and iSQL*Plus Basics
13
Some SQL Formalities . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Tools for Running SQL . . . . . . . . . . . . . . . . . . . . . . . . . . 14
SQL*Plus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
iSQL*Plus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
SQL*Plus Worksheet . . . . . . . . . . . . . . . . . . . . . . . . . . 20
Third-Party Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
ODBC/JDBC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
OCI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
The Ubiquitous
SELECT
UPDATE
Statement . . . . . . . . . . . . . . . . . . . . . . . 29
The
INSERT
Statement . . . . . . . . . . . . . . . . . . . . . . . . 31
The
DELETE
Statement . . . . . . . . . . . . . . . . . . . . . . . 32
Statement . . . . . . . . . . . . . . . . . . . . . . . . 33
DDL for Handling Database Objects . . . . . . . . . . . . . . . . 34
The
MERGE
CREATE
Statement . . . . . . . . . . . . . . . . . . . . . . . 34
The
ALTER
Statement . . . . . . . . . . . . . . . . . . . . . . . . 36
The
DROP
Statement . . . . . . . . . . . . . . . . . . . . . . . . . 37
Statement . . . . . . . . . . . . . . . . . 23
Column Specification . . . . . . . . . . . . . . . . . . . . . . . . . 24
Column Renaming . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
Duplicate Removal . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
DML for Making Changes . . . . . . . . . . . . . . . . . . . . . . . . 29
The
The
15731615.062.png 15731615.063.png 15731615.064.png 15731615.065.png 15731615.066.png 15731615.068.png 15731615.069.png 15731615.070.png 15731615.071.png 15731615.072.png 15731615.073.png 15731615.074.png 15731615.075.png 15731615.076.png 15731615.077.png 15731615.079.png 15731615.080.png 15731615.081.png 15731615.082.png 15731615.083.png 15731615.084.png 15731615.085.png 15731615.086.png 15731615.087.png 15731615.088.png 15731615.090.png 15731615.091.png 15731615.092.png 15731615.093.png 15731615.094.png 15731615.095.png 15731615.096.png 15731615.097.png 15731615.098.png 15731615.099.png 15731615.101.png 15731615.102.png
Zgłoś jeśli naruszono regulamin