Module2 Chapter2
Module2 Chapter2
Basic SQL
UNIQUE clause
Specifies alternate (secondary) keys
Dname VARCHAR(15) UNIQUE;
Fully qualified attribute names can be used for clarity even if there is no
ambiguity in attribute names.
Query: For each employee, retrieve the employee’s first and last name
and the first and last name of his or her immediate supervisor
Set operations
UNION, EXCEPT (difference), INTERSECT
Corresponding multiset operations: UNION ALL, EXCEPT ALL,
INTERSECT ALL)
Another feature allows the use of arithmetic in queries. The standard arithmetic
operators for addition (+), subtraction (−), multiplication (*), and division (/) can be
applied to numeric values or attributes with numeric domains.
Query: Retrieve a list of employees and the projects they are working on,
ordered by department and, within each department, ordered
alphabetically by last name, then first name
Specify the relation name and a list of values for the tuple
For example, to create a temporary table that has the employee last name,
project name, and hours per week for each employee working on a project, we
can write the statements in U3A and U3B: