Specifications

Using MySQL
P
ART II
208
In this chapter, well discuss Structured Query Language (SQL) and its use in querying data-
bases. Well continue developing the Book-O-Rama database by seeing how to insert, delete,
and update data, and how to ask the database questions.
Topics we will cover include
What is SQL?
Inserting data into the database
Retrieving data from the database
Joining tables
Updating records from the database
Altering tables after creation
Deleting records from the database
Dropping tables
Well begin by talking about what SQL is and why its a useful thing to understand.
If you havent set up the Book-O-Rama database, youll need to do that before you can run the
SQL queries in this chapter. Instructions for doing this are in Chapter 8, Creating Your Web
Database.
What Is SQL?
SQL stands for Structured Query Language. Its the most standard language for accessing rela-
tional database management systems (RDBMS). SQL is used to store and retrieve data to and
from a database. It is used in database systems such as MySQL, Oracle, PostgreSQL, Sybase,
and Microsoft SQL Server among others.
Theres an ANSI standard for SQL, and database systems such as MySQL implement this stan-
dard. They also typically add some bells and whistles of their own. The privilege system in
MySQL is one of these.
You might have heard the phrases Data Definition Languages (DDL), used for defining data-
bases, and Data Manipulation Languages (DML), used for querying databases. SQL covers
both of these bases. In Chapter 8, we looked at data definition (DDL) in SQL, so weve already
been using it a little. You use DDL when youre initially setting up a database.
You will use the DML aspects of SQL far more frequently because these are the parts that we
use to store and retrieve real data in a database.
12 7842 CH09 3/6/01 3:36 PM Page 208