Professional Documents
Culture Documents
4.
5.
6.
7.
8.
charge_ck
9.
10.
11.
12.
2. Update the employee fname to Jim instead of James for employee 118
(Note: if no WHERE clause is used, then all records are updated)
UPDATE emp
SET emp_fname = 'Jim'
WHERE emp_num = 118
3. Update the Database Designer chg_hour value by 10%
UPDATE job
SET chg_hour = chg_hour * 1.1
WHERE job_class = 'Database Designer'
4. Remove the row from the job table for job code PRG
( Note: if no WHERE clause is used, then all records are deleted )
DELETE
FROM job
WHERE job_code = 'PRG'
6. Remove the employees from the employee table WHERE the hiredate is before 1-Jan-90
DELETE
FROM emp
WHERE hiredate < '1-Jan-90'
FROM
WHERE
emp.emp_fname ,
emp.emp_lname ,
job.job_class ,
job.chg_hour
emp, job
emp.job_class = job.job_code
2. Same question as above, but only show the records WHERE the chg_hour is <100
SELECT
FROM
WHERE
AND
emp.emp_fname ,
emp.emp_lname ,
job.job_class ,
job.chg_hour
emp, job
emp.job_class = job.job_code
job.chg_hour = < 100
3. Select the hours worked and lastname and hiredate for all employees.
(Note: the default for all selects is to show all records that are joined. The above statement has no
further conditions for the WHERE clause)
SELECT
FROM
WHERE
emp.emp_lname ,
emp.hiredate ,
proj_emp.hour
emp, proj_emp
emp.emp_num = proj_emp.emp_num
4. Create a view called: WORK_INFO which will select the hours worked and lastname and hiredate for
all employees hired before 1-jan-02.
(Note: the default for all selects is to show all records that are joined. The above statement has no
further conditions for the WHERE clause)
CREATE VIEW WORK_INFO as
SELECT
emp.emp_lname ,
emp.hiredate ,
proj_emp.hour
FROM
emp, proj_emp
WHERE
emp.emp_num = proj_emp.emp_num
AND
emp.hiredate < '1-jan-02'
5. Select employee fname and lname and all projects that they are working on. Save this select statement
as a view called: EMP_PROJECTS
(Note: the default for all selects is to show all records that are joined. The above statement has no
further conditions for the WHERE clause)
CREATE VIEW EMP_PROJECTS as
SELECT
emp.emp_fname ,
emp.emp_lname ,
project.proj_name
FROM
emp, project , proj_emp
WHERE
proj_emp.proj_num = project.proj_num
AND
proj_emp.emp_num = emp.emp_num
6. Select employee fname and lname and all projects that they are working on for
project 18.
SELECT
FROM
WHERE
AND
AND
emp.emp_fname ,
emp.emp_lname ,
project.proj_name
emp, project , proj_emp
proj_emp.proj_num = project.proj_num
proj_emp.emp_num = emp.emp_num
project.proj_num = 18
7. Select all project names and job class descriptions that the project requires.
Save this select statement as a view called: EMP_JOB_SKILLS
CREATE VIEW EMP_JOB_SKILLS as
SELECT
project.proj_name , job.job_class
FROM
project , job , emp, proj_emp
WHERE
proj_emp.proj_num = project.proj_num
AND
proj_emp.emp_num = emp.emp_num
AND
emp.job_class = job.job_code
8. Select all project names and job class descriptions that the project requires for only the job code of
DBD. Save this statement as a view called: DATABASE_DESIGNERS
CREATE VIEW DATABASE_DESIGNERS as
SELECT
project.proj_name ,
job.job_class
FROM
project , job , emp, proj_emp
WHERE
proj_emp.proj_num = project.proj_num
AND
proj_emp.emp_num = emp.emp_num
AND
emp.job_class = job.job_code
AND
emp.job_class = 'DBD'
9. Select customer first and last name, credit limit, and salesrep first and last name WHERE the credit
limit is >= 1500.
SELECT
customer.first_name, customer.last_name,
customer.credit_limit,
salesrep.last_name as salesLastName,
salesrep.first_name as salesFirstName
FROM premiere/customer, premiere/salesrep
WHERE customer.credit_limit >= 1500