R22 Lab Exercise
R22 Lab Exercise
Figure 2: Boats
Figure 1: Sailors
Figure 3: Reservation
b) Given the database you created, write the SQL queries that answer the following
questions.
LEVEL -1: WEEK- 3, 4
(Select, update, alter, drop, and truncate operations on the single table)
1. Show all the records of Sailors, Boats, and Reservation
2. Find the names and ages of all sailors.
3. Find all sailors with a rating above 8.
4. Display all the names & colors of the boats.
5. Find all the boats with red color.
6. Alter the sailor’s table with column income and insert the values for all the SIDs.
7. Update boat color from blue to Indigo
8. Delete the income column from the sailor’s table.
9. Find the name of the sailors (distinct).
10. Display the schema of sailors and reservations.
11. Initiate a new database to maintain the details of 10 newly recruited sailors for their
job roles:
1. Modify the sailor’s tables SID column data type from varchar to int.
2. Rename the sailor’s table with new_ sailors.
3. Apply the truncate operation on the "new_sailors" table and record your
observations.
4. Perform the drop operation on the new sailors' database and document your
observations.
5. Analyze and outline the distinctions between the drop and truncate operations
based on your observations.
EXERCISE: 4:
LEVEL -2: (Two Tables) WEEK -4
EXERCISE: 6 Week - 8
Construct a company database to perform the given queries.
1. List all employees in the order they were hired to the company.
2. Calculate the sum of all the salaries of managers.
3. List the employee numbers, names and hiredates of all employees who were hired in 1982.
4. Count the number of different jobs in the EMP table without listing them.
5. Find the average commission, counting only those employees who receive a commission.
6. Find the average commission, counting employees who do not receive a commission as if
they received a commission of 0.
7. Find in which city the Operations department is located.
8. What is the salary paid to the lowest-paid employee?
9. Find the total annual pay for Ward.
10. List all employees with no manager.
11. List all employees who are not managers.
12. How many characters are in the longest department name?
Find the requirements below for the construction of the Company Database.
Reference : https://www.cs.uct.ac.za/mit_notes/database/pdfs/chp03.pdf