Write SQL query for each of the above-given steps. Create a new empty table employee2 the same
Question:
Write SQL query for each of the above-given steps.
Create a new empty table employee2 the same as table employees. Use a single statement to create the table and insert the data at the same time.
Modify table employee2 and add a new column username to this table. The value of this column is not required and does not have to be unique. Delete all the data in the employee2 table.
Re-insert all data from the employee's table into your new table employee2 using a single statement.
Create a statement that will insert yourself as an employee into employee2.
Use a unique employee number of your choice (Hint: Find the highest value of the employee number in the employee's table, increase the value by one and use it as your employee number.)
Create a query that displays your, and only your, employee data.
Create a statement to update your job ID to “Head_Cashier”.
Hint: Be careful. You may update other rows or all rows in the employee table. You only need to update one row which belongs to you and update your job title. Make sure that your query updates only one employee using a WHERE clause.
Create a statement to insert another fictional employee into employee2. This employee will be a “Cashier” and will report to you. Make up fake data for the other fields. Create a statement to delete yourself from employee2. Did it work? If not, why?
Create a statement to delete the fake employee from employee2 and then rerun the statement to delete yourself. Did it work? Explain why?
Create a single statement that will insert both yourself and the fake employee at the same time. This time you and the fake employee will report to 1088.
Add a new column “Hobby” into the employee2 table. Use the datatype of your choice. Then add your hobby for the row corresponding to your information. Create a single statement to delete both yourself and the fake employee from employee2.
Database Systems A Practical Approach to Design Implementation and Management
ISBN: 978-0132943260
6th Edition Global
Authors: Thomas Connolly, Carolyn Begg