Learning SQL 2nd edition Edition Alan Beaulieu download
Learning SQL 2nd edition Edition Alan Beaulieu download
download
https://ebookultra.com/download/learning-sql-2nd-edition-edition-
alan-beaulieu/
https://ebookultra.com/download/learning-sql-third-edition-alan-
beaulieu/
https://ebookultra.com/download/improving-working-as-learning-
improving-learning-1st-edition-alan-felstead/
https://ebookultra.com/download/mastering-oracle-sql-2nd-edition-
mishra/
https://ebookultra.com/download/social-studies-for-secondary-schools-
teaching-to-learn-learning-to-teach-2003-2nd-edition-alan-j-singer/
SQL for Microsoft Access 2nd Edition Cecelia L. Allison
https://ebookultra.com/download/sql-for-microsoft-access-2nd-edition-
cecelia-l-allison/
https://ebookultra.com/download/alan-simpson-s-windows-xp-reloaded-
bible-2nd-edition-alan-simpson/
https://ebookultra.com/download/mechanical-engineering-2nd-edition-
alan-darbyshire/
https://ebookultra.com/download/sql-server-t-sql-recipes-4th-edition-
jason-brimhall/
https://ebookultra.com/download/microsoft-sql-server-2012-t-sql-1st-
edition-tom-coffing/
Learning SQL 2nd edition Edition Alan Beaulieu Digital
Instant Download
Author(s): Alan Beaulieu
ISBN(s): 9780596520830, 0596520832
Edition: 2nd edition
File Details: PDF, 1.55 MB
Year: 2009
Language: english
Learning SQL, 2nd Edition
By Alan Beaulieu
...............................................
Publisher: O'Reilly Media, Inc.
Pub Date: April 27, 2009
Print ISBN-13: 978-0-596-52083-0
Pages: 336
Slots: 1.0
Table of Contents | Index | Errata
Updated for the latest database management systems -- including MySQL 6.0, Oracle 11g, and
Microsoft's SQL Server 2008 -- this introductory guide will get you up and running with SQL quickly.
Whether you need to write database applications, perform administrative tasks, or generate reports,
Learning SQL, Second Edition, will help you easily master all the SQL fundamentals. Each chapter
presents a self-contained lesson on a key SQL concept or technique, with numerous illustrations and
annotated examples. Exercises at the end of each chapter let you practice the skills you learn. With
this book, you will:
Move quickly through SQL basics and learn several advanced features
Create database objects, such as tables, indexes, and constraints, using SQL schema
statements
Learn how data sets interact with queries, and understand the importance of subqueries
Convert and manipulate data with SQL's built-in functions, and use conditional logic in data
statements
Knowledge of SQL is a must for interacting with data. With Learning SQL, you'll quickly learn how to
put the power and flexibility of this language to work.
[ Team Unknown ]
Copyright
Preface
Chapter 1. A Little Background
Section 1.1. Introduction to Databases
Section 1.2. What Is SQL?
Section 1.3. What Is MySQL?
Section 1.4. What's in Store
Chapter 2. Creating and Populating a Database
Section 2.1. Creating a MySQL Database
Section 2.2. Using the mysql Command-Line Tool
Section 2.3. MySQL Data Types
Section 2.4. Table Creation
Section 2.5. Populating and Modifying Tables
Section 2.6. When Good Statements Go Bad
Section 2.7. The Bank Schema
Chapter 3. Query Primer
Section 3.1. Query Mechanics
Section 3.2. Query Clauses
Section 3.3. The select Clause
Section 3.4. The from Clause
Section 3.5. The where Clause
Section 3.6. The group by and having Clauses
Section 3.7. The order by Clause
orm:knowledge-test 3.8. Test Your Knowledge
Chapter 4. Filtering
Section 4.1. Condition Evaluation
Section 4.2. Building a Condition
Section 4.3. Condition Types
Section 4.4. Null: That Four-Letter Word
orm:knowledge-test 4.5. Test Your Knowledge
Chapter 5. Querying Multiple Tables
Section 5.1. What Is a Join?
Section 5.2. Joining Three or More Tables
Section 5.3. Self-Joins
Section 5.4. Equi-Joins Versus Non-Equi-Joins
Section 5.5. Join Conditions Versus Filter Conditions
orm:knowledge-test 5.6. Test Your Knowledge
Chapter 6. Working with Sets
Section 6.1. Set Theory Primer
Section 6.2. Set Theory in Practice
Section 6.3. Set Operators
Section 6.4. Set Operation Rules
orm:knowledge-test 6.5. Test Your Knowledge
Chapter 7. Data Generation, Conversion, and
Manipulation
Section 7.1. Working with String Data
Section 7.2. Working with Numeric Data
Section 7.3. Working with Temporal Data
Section 7.4. Conversion Functions
orm:knowledge-test 7.5. Test Your Knowledge
Chapter 8. Grouping and Aggregates
Section 8.1. Grouping Concepts
Section 8.2. Aggregate Functions
Section 8.3. Generating Groups
Section 8.4. Group Filter Conditions
orm:knowledge-test 8.5. Test Your Knowledge
Chapter 9. Subqueries
Section 9.1. What Is a Subquery?
Section 9.2. Subquery Types
Section 9.3. Noncorrelated Subqueries
Section 9.4. Correlated Subqueries
Section 9.5. When to Use Subqueries
Section 9.6. Subquery Wrap-up
orm:knowledge-test 9.7. Test Your Knowledge
Chapter 10. Joins Revisited
Section 10.1. Outer Joins
Section 10.2. Cross Joins
Section 10.3. Natural Joins
orm:knowledge-test 10.4. Test Your Knowledge
Chapter 11. Conditional Logic
Section 11.1. What Is Conditional Logic?
Section 11.2. The Case Expression
Section 11.3. Case Expression Examples
orm:knowledge-test 11.4. Test Your Knowledge
Chapter 12. Transactions
Section 12.1. Multiuser Databases
Section 12.2. What Is a Transaction?
orm:knowledge-test 12.3. Test Your Knowledge
Chapter 13. Indexes and Constraints
Section 13.1. Indexes
Section 13.2. Constraints
orm:knowledge-test 13.3. Test Your Knowledge
Chapter 14. Views
Section 14.1. What Are Views?
Section 14.2. Why Use Views?
Section 14.3. Updatable Views
orm:knowledge-test 14.4. Test Your Knowledge
Chapter 15. Metadata
Section 15.1. Data About Data
Section 15.2. Information_Schema
Section 15.3. Working with Metadata
orm:knowledge-test 15.4. Test Your Knowledge
Appendix A. ER Diagram for Example Database
Appendix B. MySQL Extensions to the SQL Language
Section B.1. Extensions to the select Statement
Section B.2. Combination Insert/Update Statements
Section B.3. Ordered Updates and Deletes
Section B.4. Multitable Updates and Deletes
Appendix C. Solutions to Exercises
Section C.1.
Section C.2.
Section C.3.
Section C.4.
Section C.5.
Section C.6.
Section C.7.
Section C.8.
Section C.9.
Section C.10.
Section C.11.
Section C.12.
Section C.13.
Colophon
Index
SQL SQL Databases Programming Alan Beaulieu O'Reilly Media, Inc. Learning SQL, 2nd Edition
Copyright
Copyright © 2009, O'Reilly Media, Inc. All rights reserved.
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 (). For more information, contact our
corporate/institutional sales department: (800) 998-9938 or corporate@oreilly.com.
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 contained herein.
SQL SQL Databases Programming Alan Beaulieu O'Reilly Media, Inc. Learning SQL, 2nd Edition
Preface
Programming languages come and go constantly, and very few languages in use today have
roots going back more than a decade or so. Some examples are Cobol, which is still used quite
heavily in mainframe environments, and C, which is still quite popular for operating system and
server development and for embedded systems. In the database arena, we have SQL, whose
roots go all the way back to the 1970s.
SQL is the language for generating, manipulating, and retrieving data from a relational database.
One of the reasons for the popularity of relational databases is that properly designed relational
databases can handle huge amounts of data. When working with large data sets, SQL is akin to
one of those snazzy digital cameras with the high-power zoom lens in that you can use SQL to
look at large sets of data, or you can zoom in on individual rows (or anywhere in between). Other
database management systems tend to break down under heavy loads because their focus is too
narrow (the zoom lens is stuck on maximum), which is why attempts to dethrone relational
databases and SQL have largely failed. Therefore, even though SQL is an old language, it is
going to be around for a lot longer and has a bright future in store.
Learning SQL has the added benefit of forcing you to confront and understand the data
structures used to store information about your organization. As you become comfortable with
the tables in your database, you may find yourself proposing modifications or additions to your
database schema.
With only a handful of commands, the SQL data statements look deceptively simple. In my
opinion, many of the available SQL books help to foster this notion by only skimming the surface
of what is possible with the language. However, if you are going to work with SQL, it behooves
you to understand fully the capabilities of the language and how different features can be
combined to produce powerful results. I feel that this is the only book that provides detailed
coverage of the SQL language without the added benefit of doubling as a "door stop" (you know,
those 1,250-page "complete references" that tend to gather dust on people's cubicle shelves).
While the examples in this book run on MySQL, Oracle Database, and SQL Server, I had to pick
one of those products to host my sample database and to format the result sets returned by the
example queries. Of the three, I chose MySQL because it is freely obtainable, easy to install, and
simple to administer. For those readers using a different server, I ask that you download and
install MySQL and load the sample database so that you can run the examples and experiment
with the data.
Chapter 1, explores the history of computerized databases, including the rise of the
relational model and the SQL language.
Chapter 2, demonstrates how to create a MySQL database, create the tables used for the
examples in this book, and populate the tables with data.
Chapter 3, introduces the select statement and further demonstrates the most common
clauses (select, from, where).
Chapter 4, demonstrates the different types of conditions that can be used in the where
clause of a select, update, or delete statement.
Chapter 5, shows how queries can utilize multiple tables via table joins.
Chapter 6, is all about data sets and how they can interact within queries.
Chapter 7, demonstrates several built-in functions used for manipulating or converting
data.
Chapter 8, shows how data can be aggregated.
Chapter 9, introduces the subquery (a personal favorite) and shows how and where they
can be utilized.
Chapter 10, further explores the various types of table joins.
Chapter 11, explores how conditional logic (i.e., if-then-else) can be utilized in select,
insert, update, and delete statements.
Chapter 12, introduces transactions and shows how to use them.
Chapter 13, explores indexes and constraints.
Chapter 14, shows how to build an interface to shield users from data complexities.
Chapter 15, demonstrates the utility of the data dictionary.
Appendix A, shows the database schema used for all examples in the book.
Appendix B, demonstrates some of the interesting non-ANSI features of MySQL's SQL
implementation.
Appendix C, shows solutions to the chapter exercises.
Italic
Used for filenames, directory names, and URLs. Also used for emphasis and to indicate the
first use of a technical term.
Constant width
Used for code examples and to indicate SQL keywords within text.
UPPERCASE
Indicates user input in examples showing an interaction. Also indicates emphasized code
elements to which you should pay particular attention.
NOTE
Indicates a tip, suggestion, or general note. For example, I use notes to point you to
useful new features in Oracle9i.
Indicates a warning or caution. For example, I'll tell you if a certain SQL
clause might have unintended consequences if not used carefully.
O'Reilly maintains a web page for this book, which lists errata, examples, and any additional
information. You can access this page at:
To comment or ask technical questions about this book, send email to:
bookquestions@oreilly.com
For more information about O'Reilly books, conferences, Resource Centers, and the O'Reilly
Network, see the website at:
We appreciate, but do not require, attribution. An attribution usually includes the title, author,
publisher, and ISBN. For example, "Learning SQL, Second Edition, by Alan Beaulieu. Copyright
2009 O'Reilly Media, Inc., 978-0-596-52083-0."
If you feel your use of code examples falls outside fair use or the permission given above, feel
free to contact us at permissions@oreilly.com.
NOTE
When you see a Safari® Books Online icon on the cover of your favorite technology book,
that means the book is available online through the O'Reilly Network Safari Bookshelf.
Safari offers a solution that's better than e-books. It's a virtual library that lets you easily search
thousands of top tech books, cut and paste code samples, download chapters, and find quick
answers when you need the most accurate, current information. Try it for free at
http://my.safaribooksonline.com.
P.8. Acknowledgments
I would like to thank my editor, Mary Treseler, for helping to make this second edition a reality,
and many thanks to Kevin Kline, Roy Owens, Richard Sonen, and Matthew Russell, who were
kind enough to review the book for me over the Christmas/New Year holidays. I would also like
to thank the many readers of my first edition who were kind enough to send questions,
comments, and corrections. Lastly, I thank my wife, Nancy, and my daughters, Michelle and
Nicole, for their encouragement and inspiration.
SQL SQL Databases Programming Alan Beaulieu O'Reilly Media, Inc. Learning SQL, 2nd Edition
Finding a person's telephone number can be time-consuming, especially if the telephone book
contains a large number of entries.
A telephone book is indexed only by last/first names, so finding the names of the people living at
a particular address, while possible in theory, is not a practical use for this database.
From the moment the telephone book is printed, the information becomes less and less accurate
as people move into or out of a region, change their telephone numbers, or move to another
location within the same region.
The same drawbacks attributed to telephone books can also apply to any manual data storage system,
such as patient records stored in a filing cabinet. Because of the cumbersome nature of paper
databases, some of the first computer applications developed were database systems , which are
computerized data storage and retrieval mechanisms. Because a database system stores data
electronically rather than on paper, a database system is able to retrieve data more quickly, index data
in multiple ways, and deliver up-to-the-minute information to its user community.
Early database systems managed data stored on magnetic tapes. Because there were generally far
more tapes than tape readers, technicians were tasked with loading and unloading tapes as specific
data was requested. Because the computers of that era had very little memory, multiple requests for
the same data generally required the data to be read from the tape multiple times. While these
database systems were a significant improvement over paper databases, they are a far cry from what is
possible with today's technology. (Modern database systems can manage terabytes of data spread
across many fast-access disk drives, holding tens of gigabytes of that data in high-speed memory, but
I'm getting a bit ahead of myself.)
NOTE
This section contains some background information about pre-relational database systems. For
those readers eager to dive into SQL, feel free to skip ahead a couple of pages to the next
section.
Over the first several decades of computerized database systems, data was stored and represented to
users in various ways. In a hierarchical database system , for example, data is represented as one or
more tree structures. Figure 1-1 shows how data relating to George Blake's and Sue Smith's bank
accounts might be represented via tree structures .
Another common approach, called the network database system , exposes sets of records and sets of
links that define relationships between different records. Figure 1-2 shows how George's and Sue's
same accounts might look in such a system.
2. Follow the link from Sue Smith's customer record to her list of accounts.
3. Traverse the chain of accounts until you find the money market account.
4. Follow the link from the money market record to its list of transactions.
One interesting feature of network database systems is demonstrated by the set of product records on
the far right of Figure 1-2 . Notice that each product record (Checking, Savings, etc.) points to a list of
account records that are of that product type. Account records, therefore, can be accessed from
multiple places (both customer records and product records), allowing a network database to act as a
multiparent hierarchy .
Both hierarchical and network database systems are alive and well today, although generally in the
mainframe world. Additionally, hierarchical database systems have enjoyed a rebirth in the directory
services realm, such as Microsoft's Active Directory and the Red Hat Directory Server, as well as with
Extensible Markup Language (XML). Beginning in the 1970s, however, a new way of representing data
began to take root, one that was more rigorous yet easy to understand and implement.
There are four tables in Figure 1-3 representing the four entities discussed so far: customer , product ,
account , and transaction . Looking across the top of the customer table in Figure 1-3 , you can see
three columns : cust_id (which contains the customer's ID number), fname (which contains the
customer's first name), and lname (which contains the customer's last name). Looking down the side of
the customer table, you can see two rows , one containing George Blake's data and the other
containing Sue Smith's data. The number of columns that a table may contain differs from server to
server, but it is generally large enough not to be an issue (Microsoft SQL Server, for example, allows up
to 1,024 columns per table). The number of rows that a table may contain is more a matter of physical
limits (i.e., how much disk drive space is available) and maintainability (i.e., how large a table can get
before it becomes difficult to work with) than of database server limitations.
Each table in a relational database includes information that uniquely identifies a row in that table
Random documents with unrelated
content Scribd suggests to you:
asetettiin heitä kolmeen riviin toinen toistensa taakse ja ammuttiin ja
talot poltettiin. Päänahan nylkemistä lukuunottamatta eivät intiaanit
olisi voineet tehdä villimmin. Kunnianarvoiset saksalaiset sotilaat…
15.
Cissie ei käynyt Dower Housessa sinä iltapäivänä, joten mr Direck
lähti Teddyn tuvalle, esitettyään ensin joitakin epämääräisiä ja
läpinäkyviä puolusteluja.
"Heistä voisi joutua surman suuhun kolme kertaa niin paljon kuin
koko
Englannin armeijassa on väkeä heidän öitä oikeastaan
huomaamatta.
Siellä ovat kaikki mukana. Koko maa on aseissa."
"Metsästyspyssyjä on."
"Miten."
16.
17.
18.
Updated editions will replace the previous one—the old editions will
be renamed.
1.D. The copyright laws of the place where you are located also
govern what you can do with this work. Copyright laws in most
countries are in a constant state of change. If you are outside the
United States, check the laws of your country in addition to the
terms of this agreement before downloading, copying, displaying,
performing, distributing or creating derivative works based on this
work or any other Project Gutenberg™ work. The Foundation makes
no representations concerning the copyright status of any work in
any country other than the United States.
1.E.6. You may convert to and distribute this work in any binary,
compressed, marked up, nonproprietary or proprietary form,
including any word processing or hypertext form. However, if you
provide access to or distribute copies of a Project Gutenberg™ work
in a format other than “Plain Vanilla ASCII” or other format used in
the official version posted on the official Project Gutenberg™ website
(www.gutenberg.org), you must, at no additional cost, fee or
expense to the user, provide a copy, a means of exporting a copy, or
a means of obtaining a copy upon request, of the work in its original
“Plain Vanilla ASCII” or other form. Any alternate format must
include the full Project Gutenberg™ License as specified in
paragraph 1.E.1.
• You pay a royalty fee of 20% of the gross profits you derive
from the use of Project Gutenberg™ works calculated using the
method you already use to calculate your applicable taxes. The
fee is owed to the owner of the Project Gutenberg™ trademark,
but he has agreed to donate royalties under this paragraph to
the Project Gutenberg Literary Archive Foundation. Royalty
payments must be paid within 60 days following each date on
which you prepare (or are legally required to prepare) your
periodic tax returns. Royalty payments should be clearly marked
as such and sent to the Project Gutenberg Literary Archive
Foundation at the address specified in Section 4, “Information
about donations to the Project Gutenberg Literary Archive
Foundation.”
• You comply with all other terms of this agreement for free
distribution of Project Gutenberg™ works.
1.F.
1.F.4. Except for the limited right of replacement or refund set forth
in paragraph 1.F.3, this work is provided to you ‘AS-IS’, WITH NO
OTHER WARRANTIES OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO WARRANTIES OF
MERCHANTABILITY OR FITNESS FOR ANY PURPOSE.
Please check the Project Gutenberg web pages for current donation
methods and addresses. Donations are accepted in a number of
other ways including checks, online payments and credit card
donations. To donate, please visit: www.gutenberg.org/donate.
Most people start at our website which has the main PG search
facility: www.gutenberg.org.
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
ebookultra.com