Professional Documents
Culture Documents
ANSWERS: (A) Create/Alter/Drop Table Commands
ANSWERS: (A) Create/Alter/Drop Table Commands
ANSWERS: (A) Create/Alter/Drop Table Commands
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
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'
5. Remove the JOB table and all of it's data
6. Remove the employees from the employee table WHERE the hiredate is before 1-Jan-90
DELETE
FROM emp
WHERE hiredate < '1-Jan-90'
1. Show the employee first and last names and their job class description and hourly charge.
SELECT emp.emp_fname ,
emp.emp_lname ,
job.job_class ,
job.chg_hour
FROM emp, job
WHERE emp.job_class = job.job_code
2. Same question as above, but only show the records WHERE the chg_hour is <100
SELECT emp.emp_fname ,
emp.emp_lname ,
job.job_class ,
job.chg_hour
FROM emp, job
WHERE emp.job_class = job.job_code
AND 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 emp.emp_lname ,
emp.hiredate ,
proj_emp.hour
FROM emp, proj_emp
WHERE 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)
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)
6. Select employee fname and lname and all projects that they are working on for
project 18.
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
AND 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
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
9. Select customer first and last name, credit limit, and salesrep first and last name WHERE the credit
limit is >= 1500.