Synopses & Reviews
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
- Use SQL data statements to generate, manipulate, and retrieve data
- 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.
SQL (Structured Query Language) is a standard programming language for generating, manipulating, and retrieving information from a relational database. This introductory guide is designed for developers new to the program.
About the Author
Alan Beaulieu has been designing, building, and implementing custom database applications for over 13 years. He currently runs his own consulting company that specializes in designing Oracle databases and supporting services in the fields of Financial Services and Telecommunications. In building large databases for both OLTP and OLAP environments, Alan utilizes such Oracle features as Parallel Query, Partitioning, and Parallel Server. Alan has a Bachelor of Science degree in Operations Research from the Cornell University School of Engineering. He lives in Massachusetts with his wife and two daughters and can be reached at email@example.com.
Table of Contents
Preface; Why Learn SQL?; Why Use This Book to Do It?; Structure of This Book; Conventions Used in This Book; How to Contact Us; Using Code Examples; Safari® Books Online; Acknowledgments; Chapter 1: A Little Background; 1.1 Introduction to Databases; 1.2 What Is SQL?; 1.3 What Is MySQL?; 1.4 What's in Store; Chapter 2: Creating and Populating a Database; 2.1 Creating a MySQL Database; 2.2 Using the mysql Command-Line Tool; 2.3 MySQL Data Types; 2.4 Table Creation; 2.5 Populating and Modifying Tables; 2.6 When Good Statements Go Bad; 2.7 The Bank Schema; Chapter 3: Query Primer; 3.1 Query Mechanics; 3.2 Query Clauses; 3.3 The select Clause; 3.4 The from Clause; 3.5 The where Clause; 3.6 The group by and having Clauses; 3.7 The order by Clause; 3.8 Test Your Knowledge; Chapter 4: Filtering; 4.1 Condition Evaluation; 4.2 Building a Condition; 4.3 Condition Types; 4.4 Null: That Four-Letter Word; 4.5 Test Your Knowledge; Chapter 5: Querying Multiple Tables; 5.1 What Is a Join?; 5.2 Joining Three or More Tables; 5.3 Self-Joins; 5.4 Equi-Joins Versus Non-Equi-Joins; 5.5 Join Conditions Versus Filter Conditions; 5.6 Test Your Knowledge; Chapter 6: Working with Sets; 6.1 Set Theory Primer; 6.2 Set Theory in Practice; 6.3 Set Operators; 6.4 Set Operation Rules; 6.5 Test Your Knowledge; Chapter 7: Data Generation, Conversion, and Manipulation; 7.1 Working with String Data; 7.2 Working with Numeric Data; 7.3 Working with Temporal Data; 7.4 Conversion Functions; 7.5 Test Your Knowledge; Chapter 8: Grouping and Aggregates; 8.1 Grouping Concepts; 8.2 Aggregate Functions; 8.3 Generating Groups; 8.4 Group Filter Conditions; 8.5 Test Your Knowledge; Chapter 9: Subqueries; 9.1 What Is a Subquery?; 9.2 Subquery Types; 9.3 Noncorrelated Subqueries; 9.4 Correlated Subqueries; 9.5 When to Use Subqueries; 9.6 Subquery Wrap-up; 9.7 Test Your Knowledge; Chapter 10: Joins Revisited; 10.1 Outer Joins; 10.2 Cross Joins; 10.3 Natural Joins; 10.4 Test Your Knowledge; Chapter 11: Conditional Logic; 11.1 What Is Conditional Logic?; 11.2 The Case Expression; 11.3 Case Expression Examples; 11.4 Test Your Knowledge; Chapter 12: Transactions; 12.1 Multiuser Databases; 12.2 What Is a Transaction?; 12.3 Test Your Knowledge; Chapter 13: Indexes and Constraints; 13.1 Indexes; 13.2 Constraints; 13.3 Test Your Knowledge; Chapter 14: Views; 14.1 What Are Views?; 14.2 Why Use Views?; 14.3 Updatable Views; 14.4 Test Your Knowledge; Chapter 15: Metadata; 15.1 Data About Data; 15.2 Information_Schema; 15.3 Working with Metadata; 15.4 Test Your Knowledge; ER Diagram for Example Database; MySQL Extensions to the SQL Language; Extensions to the select Statement; Combination Insert/Update Statements; Ordered Updates and Deletes; Multitable Updates and Deletes; Solutions to Exercises; Chapter 3; Chapter 4; Chapter 5; Chapter 6; Chapter 7; Chapter 8; Chapter 9; Chapter 10; Chapter 11; Chapter 12; Chapter 13; Chapter 14; Chapter 15; Colophon;