You are previewing Sams Teach Yourself SQL in 24 Hours, Second Edition.
O'Reilly logo
Sams Teach Yourself SQL in 24 Hours, Second Edition

Book Description

Written by college instructors, Sams Teach Yourself SQL in 24 Hours quickly teaches beginning- to intermediate-level SQL users how to create, store, access and manipulate data using a proven step-by-step format that teaches SQL by example. This book contains a thorough explanation of database concepts, SQL procedures, and low-level programming, enabling readers to gain an understanding of the whys as well as the hows behind SQL.

This book presents complete code listings and output, followed with analysis that explains exactly what the listings are doing. These practical code examples can be incorporated easily by the reader into other projects. Coverage includes SQL, as well as SQL in an enterprise setting and on the Web and Intranet.

Authors Ryan Stephens and Ronald Plew are President and Vice President of Perpetual Technologies, Inc., where their duties include Oracle database administration and consulting and Oracle, SQL, and UNIX training. They have both been teaching at the collegiate level for over three years as adjunct professors at Indiana University-Purdue University in Indianapolis. Both are Oracle Certified Professionals, having specialized in Oracle and UNIX for more than 10 years each.

Table of Contents

  1. Copyright
  2. Acknowledgments
  3. About the Authors
  4. Tell Us What You Think!
  5. Introduction
  6. A SQL Concepts Overview
    1. Welcome to the World of SQL
      1. SQL Definition and History
      2. SQL Sessions
      3. DISCONNECT
      4. Types of SQL Commands
      5. An Introduction to the Database Used in This Book
      6. Summary
      7. Q&A
      8. Workshop
  7. Building Your Database
    1. Defining Data Structures
      1. What Is Data?
      2. Basic Data Types
      3. Summary
      4. Q&A
      5. Workshop
    2. Managing Database Objects
      1. What Are Database Objects?
      2. What Is a Schema?
      3. A Table: The Primary Storage for Data
      4. Integrity Constraints
      5. Summary
      6. Q&A
      7. Workshop
    3. The Normalization Process
      1. Normalizing a Database
      2. Summary
      3. Q&A
      4. Workshop
    4. Manipulating Data
      1. Overview of Data Manipulation
      2. Populating Tables with New Data
      3. Updating Existing Data
      4. Deleting Data from Tables
      5. Summary
      6. Q&A
      7. Workshop
    5. Managing Database Transactions
      1. What Is a Transaction?
      2. What Is Transactional Control?
      3. Transactional Control and Database Performance
      4. Summary
      5. Q&A
      6. Workshop
  8. Getting Effective Results from Queries
    1. Introduction to the Database Query
      1. What Is a Query?
      2. Introduction to the SELECT Statement
      3. Examples of Simple Queries
      4. Summary
      5. Q&A
      6. Workshop
    2. Using Operators to Categorize Data
      1. What Is an Operator in SQL?
      2. Comparison Operators
      3. Logical Operators
      4. Conjunctive Operators
      5. Negating Conditions with the NOT Operator
      6. Arithmetic Operators
      7. Summary
      8. Q&A
      9. Workshop
    3. Summarizing Data Results from a Query
      1. What Are Aggregate Functions?
      2. Summary
      3. Q&A
      4. Workshop
    4. Sorting and Grouping Data
      1. Why Group Data?
      2. The GROUP BY Clause
      3. GROUP BY Versus ORDER BY
      4. The HAVING Clause
      5. Summary
      6. Q&A
      7. Workshop
    5. Restructuring the Appearance of Data
      1. The Concepts of ANSI Character Functions
      2. Various Common Character Functions
      3. Miscellaneous Character Functions
      4. Mathematical Functions
      5. Conversion Functions
      6. The Concept of Combining Character Functions
      7. Summary
      8. Q&A
      9. Workshop
    6. Understanding Dates and Times
      1. How Is a Date Stored?
      2. Date Functions
      3. Date Conversions
      4. Summary
      5. Q&A
      6. Workshop
  9. Building Sophisticated Database Queries
    1. Joining Tables in Queries
      1. Selecting Data from Multiple Tables
      2. Types of Joins
      3. Join Considerations
      4. Summary
      5. Q&A
      6. Workshop
    2. Using Subqueries to Define Unknown Data
      1. What Is a Subquery?
      2. Embedding a Subquery Within a Subquery
      3. Summary
      4. Q&A
      5. Workshop
    3. Combining Multiple Queries into One
      1. Single Queries Versus Compound Queries
      2. Why Would I Ever Want to Use a Compound Query?
      3. Compound Query Operators
      4. Using an ORDER BY with a Compound Query
      5. Using a GROUP BY with a Compound Query
      6. Retrieving Accurate Data
      7. Summary
      8. Q&A
      9. Workshop
  10. SQL Performance Tuning
    1. Using Indexes to Improve Performance
      1. What Is an Index?
      2. How Do Indexes Work?
      3. The CREATE INDEX Command
      4. Types of Indexes
      5. When Should Indexes Be Considered?
      6. When Should Indexes Be Avoided?
      7. Summary
      8. Q&A
      9. Workshop
    2. Improving Database Performance
      1. What Is SQL Statement Tuning?
      2. Database Tuning Versus SQL Tuning
      3. Formatting Your SQL Statement
      4. Full Table Scans
      5. Other Performance Considerations
      6. Performance Tools
      7. Summary
      8. Q&A
      9. Workshop
  11. Using SQL to Manage Users and Security
    1. Managing Database Users
      1. Users Are the Reason
      2. The Management Process
      3. Tools Utilized by Database Users
      4. Summary
      5. Q&A
      6. Workshop
    2. Managing Database Security
      1. What Is Database Security?
      2. How Does Security Differ from User Management?
      3. What Are Privileges?
      4. Controlling User Access
      5. Controlling Privileges Through Roles
      6. Summary
      7. Q&A
      8. Workshop
  12. Summarized Data Structures
    1. Creating and Using Views and Synonyms
      1. What Is a View?
      2. Creating Views
      3. Dropping a View
      4. What Is a Synonym?
      5. Summary
      6. Q&A
      7. Workshop
    2. Working with the System Catalog
      1. What Is the System Catalog?
      2. How Is the System Catalog Created?
      3. What Is Contained in the System Catalog?
      4. Examples of System Catalog Tables by Implementation
      5. Querying the System Catalog
      6. Updating System Catalog Objects
      7. Summary
      8. Q&A
      9. Workshop
  13. Applying SQL Fundamentals in Today's World
    1. Advanced SQL Topics
      1. Advanced Topics
      2. Cursors
      3. Stored Procedures and Functions
      4. Triggers
      5. Dynamic SQL
      6. Call-Level Interface
      7. Using SQL to Generate SQL
      8. Direct Versus Embedded SQL
      9. Summary
      10. Q&A
      11. Workshop
    2. Extending SQL to the Enterprise, the Internet, and the Intranet
      1. SQL and the Enterprise
      2. Accessing a Remote Database
      3. Accessing a Remote Database Through a Web Interface
      4. SQL and the Internet
      5. SQL and the Intranet
      6. Summary
      7. Q&A
      8. Workshop
    3. Extensions to Standard SQL
      1. Various Implementations
      2. Examples of Extensions from Some Implementations
      3. Interactive SQL Statements
      4. Summary
      5. Q&A
      6. Workshop
  14. Appendixes
    1. Common SQL Commands
      1. SQL Statements
      2. SQL Clauses
    2. ASCII Table
    3. Answers to Quizzes and Exercises
      1. Hour 1, "Welcome to the World of SQL"
      2. Hour 2, "Defining Data Structures"
      3. Hour 3, "Managing Database Objects"
      4. Hour 4, "The Normalization Process"
      5. Hour 5, "Manipulating Data"
      6. Hour 6, "Managing Database Transactions"
      7. Hour 7, "Introduction to the Database Query"
      8. Hour 8, "Using Operators to Categorize Data"
      9. Hour 9, "Summarizing Data Results from a Query"
      10. Hour 10, "Sorting and Grouping Data"
      11. Hour 11, "Restructuring the Appearance of Data"
      12. Hour 12, "Understanding Dates and Time"
      13. Hour 13, "Joining Tables in Queries"
      14. Hour 14, "Using Subqueries to Define Unknown Data"
      15. Hour 15, "Combining Multiple Queries into One"
      16. Hour 16, "Using Indexes to Improve Performance"
      17. Hour 17, "Improving Database Performance"
      18. Hour 18, "Managing Database Users"
      19. Hour 19, "Managing Database Security"
      20. Hour 20, "Creating and Using Views and Synonyms"
      21. Hour 21, "Working with the System Catalog"
      22. Hour 22, "Advanced SQL Topics"
      23. Hour 23, "Extending SQL to the Enterprise, the Internet, and the Intranet"
      24. Hour 24, "Extensions to Standard SQL"
    4. CREATE TABLE Statements for Book Examples
      1. EMPLOYEE_TBL
      2. EMPLOYEE_PAY_TBL
      3. CUSTOMER_TBL
      4. ORDERS_TBL
      5. PRODUCTS_TBL
    5. INSERT Statements for Data in Book Examples
      1. INSERT Statements
    6. Glossary
  15. Index