Question: Write an SQL statement which copies all of the data in the departments table into a new table that is called department_copy. But, only copy
Write an SQL statement which copies all of the data in the departments table into a new table that is called department_copy. But, only copy those rows with a department_id not less than 20 or greater than 60. Also alter the table by writing the SQL statement that will add a primary key constraint which will be called dep_pk_2, which adds the department ID column as the primary key for the newly created table. Next, Update the department_copy table and set the manager id to NULL for all the departments having the department name as 'Shipping' and 'Marketing' (these departments no longer will have a manager managing it). In addition, update the manager_id on the departments table for the Accounting department with the values that are of employee by the last name of 'Lorentz' (write the query using a subquery).
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
