Beginning Oracle SQL.pdf

(3555 KB) Pobierz
www.it-ebooks.info
Beginning Oracle SQL
Lex de Haan
Daniel Fink
Tim Gorman
Inger Jørgensen
Karen Morton
www.it-ebooks.info
Beginning Oracle SQL
Copyright © 2009 by Lex de Haan, Daniel Fink, Tim Gorman, Inger Jørgensen, Karen Morton
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-7197-0
ISBN-13 (electronic): 978-1-4302-7196-3
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.
President and Publisher: Paul Manning
Lead Editor: Jonathan Gennick
Technical Reviewers: Tim Gorman, Daniel Fink
Editorial Board: Clay Andres, 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: Jim Markham
Copy Editor: Seth Kline
Compositor: Bytheway Publishing Services
Indexer: Brenda Miller
Artist: April Milne
Cover Designer: Anna Ishchenko
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 2855 Telegraph Avenue, Suite
600, Berkeley, CA 94705. Phone 510-549-5930, fax 510-549-5939, e-mail
info@apress.com
, or visit
http://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
http://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.
The source code for this book is available to readers from this book’s catalog page at
http://www.apress.com
. The exact link as of this writing is:
http://apress.com/book/view/1430271970.
www.it-ebooks.info
Contents at a Glance
Contents at a Glance..............................................................................................iii
Contents................................................................................................................. iv
About the Authors............................................................................................... xvii
Acknowledgments ............................................................................................... xix
Introduction ......................................................................................................... xxi
Chapter 1: Relational Database Systems and Oracle..............................................1
Chapter 2: Introduction to SQL, AQL*Plus, and SQL Developer.............................25
Chapter 3: Data Definition, Part I..........................................................................71
Chapter 4: Retrieval: The Basics...........................................................................83
Chapter 5: Retrieval: Functions ..........................................................................117
Chapter 6: Data Manipulation .............................................................................145
Chapter 7: Data Definition, Part II.......................................................................163
Chapter 8: Retrieval: Multiple Tables and Aggregation ......................................195
Chapter 9: Retrieval: Some Advanced Features .................................................233
Chapter 10: Views...............................................................................................265
Chapter 11: Writing and Automating SQL*Plus Scripts ......................................287
Chapter 12: Object-Relational Features..............................................................329
Appendix A: The Seven Case Tables ...................................................................349
Appendix B: Answers to the Exercises ...............................................................359
Index ...................................................................................................................405
iii
www.it-ebooks.info
CONTENTS
Contents
Contents at a Glance ..............................................................................................iii
Contents................................................................................................................. iv
About the Authors............................................................................................... xvii
Acknowledgments ............................................................................................... xix
Introduction ......................................................................................................... xxi
Chapter 1: Relational Database Systems and Oracle..............................................1
1.1 Information Needs and Information Systems ..............................................................1
1.2 Database Design..........................................................................................................2
Entities and Attributes .............................................................................................................................. 2
Generic vs. Specific .................................................................................................................................. 3
Redundancy.............................................................................................................................................. 4
Consistency, Integrity, and Integrity Constraints...................................................................................... 5
Data Modeling Approach, Methods, and Techniques ............................................................................... 6
Semantics................................................................................................................................................. 7
Information Systems Terms Review......................................................................................................... 7
1.3 Database Management Systems .................................................................................7
DBMS Components................................................................................................................................... 8
Kernel .................................................................................................................................................. 8
Data Dictionary .................................................................................................................................... 8
Query Languages................................................................................................................................. 8
DBMS Tools ......................................................................................................................................... 9
iv
www.it-ebooks.info
Zgłoś jeśli naruszono regulamin