Database Reference
In-Depth Information
Summary
￿
Structured Query Language (SQL) is a language that is used to manipulate relational databases.
￿
The basic form of an SQL query is SELECT-FROM-WHERE.
114
￿
Use the CREATE TABLE command to describe a table's layout to the DBMS, which creates the table in
the database.
￿
In SQL retrieval commands, fields are listed in the SELECT clause, tables are listed in the FROM clause,
and conditions are listed in the WHERE clause.
￿
In conditions, character values must be enclosed in single quotation marks.
￿
Compound conditions are formed by combining simple conditions using either or both of the following
operators: AND and OR.
￿
Sorting is accomplished using the ORDER BY clause. The field on which the records are sorted is called
the sort key. When the data is sorted in more than one field, the more important field is called the major
sort key or primary sort key. The less important field is called the minor sort key or secondary sort key.
￿
Grouping is accomplished in SQL by using the GROUP BY clause. To restrict the rows to be displayed,
use the HAVING clause.
￿
Joining tables is accomplished in SQL by using a condition that relates matching rows in the tables to be
joined.
￿
SQL has the built-in (also called aggregate) functions COUNT, SUM, AVG, MAX, and MIN.
￿
One SQL query can be placed inside another. The subquery is evaluated first.
￿
The union of the results of two queries is specified by placing the UNION operator between the two
queries.
￿
Computed fields are specified in SQL queries by including the expression, followed by the word
AS
, fol-
lowed by the name of the computed field.
￿
The INSERT command is used to add a new row to a table.
￿
The UPDATE command is used to change existing data.
￿
The DELETE command is used to delete records.
￿
The INTO clause is used in a SELECT command to create a table containing the results of the query.
Key Terms
CHAR(
)
command
compound condition
CREATE TABLE
DATE
DECIMAL(
n
INTO clause
ORDER BY clause
reserved word
SELECT clause
simple condition
SMALLINT
SQL (Structured Query Language)
statement history
subquery
UPDATE
WHERE clause
p,q
)
DELETE
FROM clause
GROUP BY clause
HAVING clause
INSERT
INTEGER
Search WWH ::




Custom Search