You are previewing Sams Teach Yourself SQL in One Hour a Day, Fifth Edition.
O'Reilly logo
Sams Teach Yourself SQL in One Hour a Day, Fifth Edition

Book Description

The Fifth Edition of Sams Teach Yourself SQL in 21 Days

More than 48,000 sold!

In just one hour a day, you’ll have all the skills you need to begin creating effective SQL queries, reports, and database applications. With this complete tutorial, you’ll quickly master the basics and then move on to more advanced features and concepts:

  • Quickly apply essential SQL techniques in useful, real-world queries

  • Design trustworthy, high-performance databases

  • Manipulate your data with views and transactions

  • Leverage powerful features including stored procedures, triggers, and cursors

  • Work with new objects introduced with the latest SQL standards

  • Get practical, expert tips on implementing SQL in your business environment

  • Learn on your own time, at your own pace

  • No previous SQL or database experience required

  • Learn techniques that work with any current version of SQL

  • Discover how to write faster, more efficient queries

  • Secure your data using best practices from experienced database administrators

  • Build more powerful databases with features exclusive to Oracle SQL*Plus, Oracle PL/SQL, and Microsoft Transact-SQL

  • Write queries for the free, open source MySQL database

  • Embed your SQL code in other applications

  • Ryan Stephens and Ron Plew are President and VP of Perpetual Technologies, Inc. (PTI) in Indianapolis, IN, providing managed services and consulting for top database implementations running Oracle, SQL Server, and other leading technologies. They taught for 5+ years as adjunct professors at Indiana University-Purdue University. Their books include Sams Teach Yourself SQL in 24 Hours, First through Fourth Editions, Sams Teach Yourself SQL in 21 Days, Second through Fourth Editions, and Database Design.

    Table of Contents

    Introduction  1

    PART I: Introducing SQL

    LESSON 1: Getting Started with SQL     5

         A Brief History of SQL     5

         A Brief History of Databases     6

         Today’s Database Landscape     11

         A Cross-Product Language     12

             Early Implementations     12

             SQL and Client/Server Application Development     13

        An Overview of SQL     13

        Popular SQL Implementations     14

             MySQL     14

             Oracle     14

             Microsoft SQL Server and Sybase     15

             IBM DB2     16

        Open Database Connectivity     16

        Embedding SQL in Application Programming     17

    LESSON 2: Introducing the Query     21

        Exploring SQL’s Background     21

        Learning Basic Query Syntax     22

        The Building Blocks of Data Retrieval: SELECT and FROM     23

        Applying Query Concepts     25

        Writing Your First Query     26

             Terminating a SQL Statement     28

             Selecting Individual Columns     28

             Changing the Order of the Columns     29

             Selecting Different Tables     31

        Selecting Distinct Values     31

             Exercises  37

    LESSON 3: Expressions, Conditions, and Operators     39

        Working with Query Expressions     40

        Placing Conditions on Queries     40

        Learning How to Use Operators     42

            Arithmetic Operators     42

            Comparison Operators     55

            Character Operators     63

            Logical Operators     70

            Set Operators     75

            Miscellaneous Operators: IN and BETWEEN     78

    LESSON 4: Clauses in SQL Queries     85

        Specifying Criteria with the WHERE Clause     87

        Order from Chaos: The ORDER BY Clause     89

        The GROUP BY Clause     98

        The HAVING Clause     105

        Combining Clauses     112

            Example 4.1     112

            Example 4.2     113

            Example 4.3     113

            Example 4.4     115

    LESSON 5: Joining Tables     121

    Table of Contents

    1. Title Page
    2. Copyright
    3. Contents at a Glance
    4. Table of Contents
    5. About the Author
    6. Dedication
    7. Acknowledgments
    8. Introduction
    9. PART I: Introducing SQL
      1. LESSON 1 Getting Started with SQL
      2. LESSON 2 Introducing the Query
      3. LESSON 3 Expressions, Conditions, and Operators
      4. LESSON 4 Clauses in SQL Queries
      5. LESSON 5 Joining Tables
      6. LESSON 6 Embedding Subqueries into Queries
      7. LESSON 7 Molding Data with Built-in Functions
    10. PART II: Database Design
      1. LESSON 8 Database Normalization
      2. LESSON 9 Creating and Maintaining Tables
      3. LESSON 10 Controlling Data Integrity
    11. PART III: Data Manipulation
      1. LESSON 11 Manipulating Data
      2. LESSON 12 Dates and Time in SQL
      3. LESSON 13 Creating Views
      4. LESSON 14 Controlling Transactions
    12. PART IV: Database Administration
      1. LESSON 15 Creating Indexes on Tables to Improve Performance
      2. LESSON 16 Streamlining SQL Statements for Improved Performance
      3. LESSON 17 Database Security
      4. LESSON 18 Exploring the Data Dictionary (System Catalog)
    13. PART V: More SQL Objects
      1. LESSON 19 Temporary Tables, Stored Proceudres, Triggers, and Cursors
      2. LESSON 20 New Objects in the Latest Standard
    14. PART VI: Advanced SQL Programming
      1. LESSON 21 Using SQL to Generate SQL Statements
      2. LESSON 22 Creating Complex SQL Queries
      3. LESSON 23 Debugging Your SQL Statements
      4. LESSON 24 Embedding SQL in Application Programming
    15. PART VII: SQL in Various Database Implementations
      1. LESSON 25 Using Oracle SQL*Plus to Satisfy Reporting Needs
      2. LESSON 26 An Introduction to Oracle PL/SQL
      3. LESSON 27 An Introduction to Transact-SQL
      4. LESSON 28 Using MySQL on a UNIX-based System
    16. PART VIII: Appendices
      1. APPENDIX A Answers
      2. APPENDIX B Code Examples to Create Tables
      3. APPENDIX C Code Examples to Populate Tables
      4. APPENDIX D Using MySQL for Exercises
    17. Index
    18. Online Appendixes
      1. APPENDIX E Glossary of Common SQL Commands
      2. APPENDIX F Glossary of Common SQL Functions