This preview shows page 1. Sign up to view the full content.
Unformatted text preview: CT [DISTINCT] select-list
fromWHERE qualification; ALTER TABLE Students CHANGE SSN ID CHAR(9);
(Changes name of SSN column to ID; possibly also changed type.) ALTER TABLE Students CHANGE ID ID INTEGER;
(Changes type of the ID column.) 31
31 32 Query Evaluation Query Examples
4. Compute cross-product of tables in from-list.
crossfromDelete rows that fail qualification.
Delete columns not in select-list.
selectIf DISTINCT, delete duplicate rows. Find names of sailors who have reserved boat
SELECT DISTINCT S.sname
Sailors S, Reserves R
WHERE S.sid=R.sid AND R.bid=103;
SELECT DISTINCT sname
WHERE Sailors.sid=Reserves.sid AND bid=103;
Sailors.sid= 33 Query Examples (continued)
(Q1) Query Examples (continued)
(Q1) Find the names of sailors who have reserved
boat 103. Find the names of sailors who have reserved
Can be done using EXISTS: Can be done as nested query:
View Full Document
- Fall '12