PRACTICE WORKSHEET - 1
Table 1: STUDENT
RollNo Name Class Marks City
101 Riya 12 88 Chennai
102 Arjun 11 76 Mumbai
103 Neha 12 92 Delhi
104 Rahul 11 NULL Pune
Queries:
1. Write a query to create a database named SchoolDB and switch to it.
2. Write a query to create the table with RollNo as Primary Key.
3. Write a query to insert all the given records.
4. Write a query to display details of students in Class 12.
5. Write a query to show names of students with marks between 80 and 90.
6. Write a query to display students whose City is NULL.
7. Write a query to remove the entire table Student.
8. Write a query to increase the Quantity of all products by 50 where Price > 10
9. Write a query to select Name and Marks of students in Class 12 and display them ordered by
Marks descending.
Table 2: EMPLOYEE
EmpID EmpName Department Salary Gender
E01 Ramesh HR 35000 M
E02 Priya IT 55000 F
E03 Karan Sales 40000 M
E04 Asha IT 60000 F
Queries:
1. Write a query to create the Employee table with appropriate data types.
2. Write a query to add a new column Age INT.
3. Write a query to change the data type of Salary to DECIMAL(10,2).
4. Write a query to increase the salary of IT department employees by 5000.
5. Write a query to delete the record of employee E03.
6. Write a query to display all employee names using alias StaffName.
7. Write a query to delete all records from the Employee table.
8. Write a query to increase PurchaseAmt by 500 for all customers from Delhi
Table 3: BOOKS
BookID Title Author Price Category
B101 Python Basics Sumita Arora 450 Education
B102 Life Lessons Robin Sharma 300 Self-Help
B103 Learn SQL Reema Thareja 400 Education
Queries:
1. Write a query to create Books table with BookID as Primary Key.
2. Write a query to insert all the above records.
3. Write a query to increase price of Self-Help books by 50.
4. Write a query to display distinct categories.
5. Write a query to show books with Title starting with 'L'.
6. Write a query to remove the column Category.
7. Write a query to remove the entire table Books.
Table 4: PRODUCT
PCode PName Price Quantity
P01 Pen 10 200
P02 Pencil 5 300
P03 Notebook 50 150
Queries:
1. Write a query to create Product table.
2. Write a query to insert the given records.
3. Write a query to change price of Notebook to 55.
4. Write a query to delete products with quantity less than 200.
5. Write a query to display all products in descending order of Price.
6. Write a query to add a new column Brand VARCHAR(20).
7. Write a query to delete all records from Product table.
Table 5: CUSTOMER
CustID CustName City PurchaseAmt
C001 Arvind Delhi 2000
C002 Meena Chennai 5000
C003 Ravi Mumbai NULL
C004 Preethi Delhi 7000
Queries:
1. Write a query to create Customer table.
2. Write a query to display customers with PurchaseAmt > 4000.
3. Write a query to display customers from Delhi or Chennai.
4. Write a query to show customers whose PurchaseAmt is NULL.
5. Write a query to add a Primary Key on CustID.
6. Write a query to remove the column City.
7. Write a query to remove the entire table Customer.
Table 6: TEACHER
TID TName Subject Experience Salary
T01 Kavitha CS 5 55000
T02 Naveen Math 7 60000
T03 Rekha English 4 48000
Queries:
1. Write a query to create Teacher table.
2. Write a query to insert the given records.
3. Write a query to increase salary of teachers with Experience >5 by 10%.
4. Write a query to display teachers teaching CS or Math.
5. Write a query to add column PhoneNo CHAR(10).
6. Write a query to remove the column Experience.
7. Write a query to delete all records from Teacher table.
Table 7: MOVIES
MovieID Title Genre Rating Year
M01 Leo Action 8.2 2023
M02 Jawan Action 8.5 2023
M03 OMG2 Drama 7.8 2023
Queries:
1. Write a query to create Movies table.
2. Write a query to display movies with Genre Action.
3. Write a query to change rating of OMG2 to 8.0.
4. Write a query to delete movie with lowest rating.
5. Write a query to add column ActorName VARCHAR(30).
6. Write a query to display unique genres.
7. Write a query to remove the entire table Movies.
Table 8: SUPPLIER
SID SName City Product Phone
S1 Raman Chennai Pen 9876543210
S2 Priya Delhi Paper 9988776655
S3 Raj Mumbai Ink 8899776655
Queries:
1. Write a query to create Supplier table.
2. Write a query to insert the above records.
3. Write a query to display suppliers from Chennai.
4. Write a query to modify Phone of S2 to 9999999999.
5. Write a query to remove column Product.
6. Write a query to describe the table structure.
7. Write a query to delete all records from Supplier table.
Table 9: ORDERS
OrderID CustID Amount Date
O1 C001 2000 2024-05-12
O2 C002 3500 2024-05-15
O3 C004 1500 2024-05-18
Queries:
1. Write a query to create Orders table.
2. Write a query to insert the given records.
3. Write a query to display orders with Amount between 1500 and 3000.
4. Write a query to change Amount of O2 to 4000.
5. Write a query to display all orders sorted by Amount descending.
6. Write a query to add column OrderStatus VARCHAR(15).
7. Write a query to remove the entire table Orders.
Table 10: DEPARTMENT
DeptID DeptName Location
D1 HR Chennai
D2 IT Bangalore
D3 Sales Mumbai
Queries:
1. Write a query to create Department table.
2. Write a query to insert the given data.
3. Write a query to add column Manager VARCHAR(30).
4. Write a query to remove column Location.
5. Write a query to display DeptName with alias Department_Name.
6. Write a query to show all tables in the database.
7. Write a query to delete all records from Department table.