Lab 2 - Part I II - Studentes
Lab 2 - Part I II - Studentes
Lab 2 - Part I II - Studentes
Overview:
Total 100 points.
There are three tasks in this assignment: A) create tables, B) insert data, and C) query single table. For
each task, you need to write SQL command and run it in Oracle SQLPlus Worksheet. What you need
to submit are:
1. the SQL command;
2. the results copy and paste from Oracle SQLPlus Worksheet result window.
A. Create Tables
Hint: you have two ways to define foreign key, one is to define foreign key within the CREATE
TABLE statement as in SQL Lab 1, for example:
Table Name: employee
1
Mid Name CHAR
Last Name VARCHAR(15) NOT NULL
SSN Number CHAR(9) NOT NULL
Birthday DATE
Address VARCHAR(50)
Sex CHAR Sex IN ('M',
'F', 'm', 'f')
Salary DECIMAL(10,2) DEFAULT
'800'
Supervisor SSN CHAR(9) employee (SSN)
Department Number INT
2
Table Name: dependent
B. Insert Data
5 points for each table.
Mini
FName LName SSN BDate Address Sex Salary SuperSSN DepNo
t
Doug E Gilbert 554433221 09-JUN-60 11 S 59 E, Salt Lake City, UT M 80000 NULL 3
Joyce PAN 543216789 07-FEB-78 35 S 18 E, Salt Lake City, UT F 70000 NULL 2
Frankin T Wong 333445555 08-DEC-45 638 Voss, Houston, TX M 40000 554433221 5
Jennifer S Wallace 987654321 20-JUN-31 291 Berry, Bellaire, TX F 43000 554433221 4
John B Smith 123456789 09-JAN-55 731 Fondren, Houston, TX M 30000 333445555 5
Ramesh K Narayan 666884444 15-SEP-52 975 Fire Oak, Humble, TX M 38000 333445555 5
Joyce A English 453453453 31-JUL-62 5631 Rice, Houston, TX F 25000 333445555 5
James E Borg 888665555 10-NOV-27 450 Stone, Houston, TX M 55000 543216789 1
Alicia J Zelaya 999887777 19-JUL-58 3321 Castle, Spring, TX F 25000 987654321 4
Ahmad V Jabbar 987987987 29-MAR-59 980 Dallas, Houston, TX M 25000 987654321 4
DepNo DLocation
1 Houston
1 Chicago
2 New York
2 San Francisco
3 Salt Lake City
4 Stafford
4 Bellaire
3
5 Sugarland
5 Houston
4
C. Query Single Table
4 points each.
3. List the name of employees whose salary is between 30000 and 50000.
6. List department number and number of employees in each department, ordered by number of
employees in each department.
7. List department number and number of employees in departments that have more than 2
employees, ordered by department number (USING HAVING).
8. List the ESSN of employees who works on project 3388 or project 1945