Академический Документы
Профессиональный Документы
Культура Документы
Basic Structure
A relational database is a collection of tables. Each table has its own unique name.
The select clause which corresponds to the projection operation. It is the list of
attributes that will appear in the resulting table.
The from clause which corresponds to the Cartesian-product operation. It is the list
of tables that will be joined in the resulting table.
The where clause which corresponds to the selection operation. It is the expression
that controls the which rows appear in the resulting table.
Formal query languages are based on the mathematical notion of a relation being a set.
Duplicate tuples never appear in relations. In practice, duplicate elimination is relatively
time consuming. SQL allows duplicates in relations as well as the results of SQL
expressions.
In those cases where we want to force the elimination of duplicates, we insert the
keyword distinct after select. The default is to retain duplicates. This can be explicitly
required with the keyword all.
The asterisk symbol "*" can be used in place of listing all the attributes.
The clause can also contain arithmetic expressions involving the operators +, -, *, and /.
A dot notation is used when explicitly identifying the table that the attribute comes
from: borrower.loan-number
The from Clause
The from clause defines a Cartesian product of the tables in the clause.
SQL uses and, or and not (not symbols) and the comparison operators <, <=, >, >=, = , and
<>. Also available is between:
old_name as new_name
You can do pattern matching on strings, using like and special characters:
SQL uses the order by clause to control the order of the display of rows, either
ascending (asc) or descending (desc):
Sorting a large number of tuples may be costly and its use should be limited.