SQL Problem Set: Basic SQL Operations
Problem 1: Create a Database
You are tasked with managing a small school's student records. First, create a new database to
store the student information.
Task: Create a database named SchoolDB.
Problem 2: Create a Table
Now that you have the database, you need to create a table for storing student data. Each
student has an id, name, and age.
Task: Create a table called Students with the following columns:
o id (integer)
o name (text)
o age (integer)
Problem 3: Add a Column
After creating the Students table, you realize that you need to store each student's grade. You
need to add a new column to the table to store this information.
Task: Add a column grade (text) to the Students table.
Problem 4: Insert a Single Record
Now it's time to add some student data. Start by inserting a record for a student named John,
who is 16 years old and has a grade of A.
Task: Insert a record with the following details:
o id = 1
o name = 'John'
o age = 16
o grade = 'A'
Problem 5: Insert Multiple Records
More students need to be added to the database. Insert records for the following students:
id = 2, name = 'Emma', age = 15, grade = 'B'
id = 3, name = 'Sophia', age = 17, grade = 'A'
id = 4, name = 'Liam', age = 16, grade = 'C'
Task: Insert these three records into the Students table.
Problem 6: Update a Record
You have been informed that Liam's grade was entered incorrectly. His correct grade is B.
Update the record to reflect this change.
Task: Update the grade for the student with id = 4 to B.
Problem 7: Add a New Column
The school now wants to store the email addresses of the students. Add a new column to the
Students table to accommodate this.
Task: Add a column email (text) to the Students table.
Problem 8: Insert a Record with the New Column
Now that you have added the email column, you need to add a new student with their email
address included. Insert a record for a student named Noah, who is 18 years old, has a grade
of A, and an email address of noah@[Link].
Task: Insert the following details into the Students table:
o id = 5
o name = 'Noah'
o age = 18
o grade = 'A'
o email = 'noah@[Link]'