Learning SQL, 2nd edition - Alan Beulieu - OReilly - 2009.pdf

(2044 KB) Pobierz
790765696.027.png
Download at WoweBook.Com
790765696.028.png
SECOND EDITION
Learning SQL
Alan Beaulieu
Beijing
Cambridge
Farnham
Köln
Sebastopol
Taipei
Tokyo
Download at WoweBook.Com
790765696.029.png 790765696.030.png 790765696.001.png 790765696.002.png 790765696.003.png 790765696.004.png 790765696.005.png 790765696.006.png 790765696.007.png 790765696.008.png
 
Learning SQL, Second Edition
by Alan Beaulieu
Copyright © 2009 O’Reilly Media, Inc. All rights reserved.
Printed in the United States of America.
Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472.
O’Reilly books may be purchased for educational, business, or sales promotional use. Online editions
are also available for most titles ( http://safari.oreilly.com ) . For more information, contact our corporate/
institutional sales department: (800) 998-9938 or corporate@oreilly.com .
Editor: Mary E. Treseler
Production Editor: Loranah Dimant
Copyeditor: Audrey Doyle
Proofreader: Nancy Reinhardt
Indexer: Ellen Troutman Zaig
Cover Designer: Karen Montgomery
Interior Designer: David Futato
Illustrator: Robert Romano
Printing History:
August 2005:
First Edition.
April 2009:
Second Edition.
Nutshell Handbook, the Nutshell Handbook logo, and the O’Reilly logo are registered trademarks of
O’Reilly Media, Inc. Learning SQL , the image of an Andean marsupial tree frog, and related trade dress
are trademarks of O’Reilly Media, Inc.
Many of the designations used by manufacturers and sellers to distinguish their products are claimed as
trademarks. Where those designations appear in this book, and O’Reilly Media, Inc. was aware of a
trademark claim, the designations have been printed in caps or initial caps.
While every precaution has been taken in the preparation of this book, the publisher and author assume
no responsibility for errors or omissions, or for damages resulting from the use of the information con-
tained herein.
TM
This book uses RepKover™, a durable and flexible lay-flat binding.
ISBN: 978-0-596-52083-0
[M]
1239115419
Download at WoweBook.Com
790765696.009.png 790765696.010.png 790765696.011.png 790765696.012.png 790765696.013.png 790765696.014.png 790765696.015.png 790765696.016.png
 
Table of Contents
Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ix
1.
A Little Background . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Introduction to Databases
1
Nonrelational Database Systems
2
The Relational Model
4
Some Terminology
6
What Is SQL?
7
SQL Statement Classes
7
SQL: A Nonprocedural Language
9
SQL Examples
10
What Is MySQL?
12
What’s in Store
13
2.
Creating and Populating a Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Creating a MySQL Database
15
Using the mysql Command-Line Tool
17
MySQL Data Types
18
Character Data
18
Numeric Data
21
Temporal Data
23
Table Creation
25
Step 1: Design
25
Step 2: Refinement
26
Step 3: Building SQL Schema Statements
27
Populating and Modifying Tables
30
Inserting Data
31
Updating Data
35
Deleting Data
35
When Good Statements Go Bad
36
Nonunique Primary Key
36
Nonexistent Foreign Key
36
iii
Download at WoweBook.Com
790765696.017.png 790765696.018.png 790765696.019.png 790765696.020.png 790765696.021.png 790765696.022.png 790765696.023.png 790765696.024.png 790765696.025.png 790765696.026.png
Zgłoś jeśli naruszono regulamin