Week2 & 3 (Part 1)
Week2 & 3 (Part 1)
• Data-manipulation language (DML). The SQL DML provides the ability to query information from the
database and to insert tuples into, delete tuples from, and modify tuples in the database.
• Integrity. The SQL DDL includes commands for specifying integrity constraints that the data stored in
the database must satisfy. Updates that violate integrity constraints are disallowed.
• View definition. The SQL DDL includes commands for defining views.
• Embedded SQL and dynamic SQL. Embedded and dynamic SQL define how SQL statements can be
embedded within general-purpose programming languages, such as C, C++, and Java.
The SQL DDL allows specification of not only a set of relations, but also information about each relation, including:
d -
Q
⑭
③
③
..
-
Now consider another query, “Find the department names of all instructors,” which can be written as:
SQL allows us to use the keyword all to specify explicitly that duplicates are
not removed:
· T
The Natural Join
For example, suppose we wish to answer the query “List the names of instructors along with the the titles of courses that they teach.”
The query can be written in SQL as follows:
The Rename Operation
The names of the attributes in the result are derived from the names of the attributes in the relations in the from clause.
SQL provides a way of renaming the attributes of a result relation. It uses the as clause, taking the form:
String Operations
Set Comparison
As an example of the ability of a nested subquery to compare sets, consider the query “Find the names of all instructors
whose salary is greater than at least one instructor in the Biology department.”
Same
L
Let us find the names of all instructors that have a salary value greater than that of each instructor in the
Biology department. The construct > all corresponds to the phrase “greater than all.” Using this construct, we
write the query as follows:
.
The With Clause
Complex query for
with statement ,
-