3.3
Write the following inserts, deletes, or updates in SQL, using the university schema.
a. Increase the salary of each instructor in the Comp. Sci. department by 10%.
b. Delete all courses that have never been offered (i.e., do not occur in the section relation).
c. Insert every student whose tot_cred attribute is greater than 100 as an instructor in the same department, with a salary of $10,000.
- Increase the salary of each instructor in the Comp. Sci. department by 10%.
UPDATE instructor
SET salary = salary * 1.10
WHERE dept_name = 'Comp. Sci.'
- Delete all courses that have never been offered (i.e., do not occur in the section relation).
DELETE FROM course
WHERE course_id NOT IN (SELECT course_id FROM section)
- Insert every student whose tot_cred attribute is greater than 100 as an instructor in the same department, with a salary of $10,000.
INSERT INTO instructor
SELECT ID, name, dept_name, 10000
FROM student
WHERE tot_cred > 100