0% found this document useful (0 votes)
22 views2 pages

Mysql Practice Lab

The document provides a practical lab for learning basic MySQL commands using a sample 'School' database. It includes steps for creating a database, creating a 'Students' table, inserting records, selecting data, and updating records. Additionally, it presents challenges and practice questions for further skill development in MySQL operations.

Uploaded by

karlsoncollin1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views2 pages

Mysql Practice Lab

The document provides a practical lab for learning basic MySQL commands using a sample 'School' database. It includes steps for creating a database, creating a 'Students' table, inserting records, selecting data, and updating records. Additionally, it presents challenges and practice questions for further skill development in MySQL operations.

Uploaded by

karlsoncollin1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Computer Science – MYSQL

MySQL Practice Lab: CREATE DATABASE, SELECT, INSERT,


UPDATE
This lab will help you practice basic MySQL commands including CREATE DATABASE,
SELECT, INSERT, and UPDATE. The exercises are based on a sample 'School' database.

Step 1: Create Database


Command:

CREATE DATABASE School;

Step 2: Create Table


Inside the 'School' database, create a table named 'Students' with the following structure:

student_id INT PRIMARY KEY,


first_name VARCHAR(50),
last_name VARCHAR(50),
grade INT

Step 3: Insert Data


Insert at least 3 student records:

INSERT INTO Students VALUES (1, 'John', 'Doe', 10);


INSERT INTO Students VALUES (2, 'Jane', 'Smith', 11);
INSERT INTO Students VALUES (3, 'Ali', 'Khan', 9);

Step 4: Select Data


Retrieve all student records:

SELECT * FROM Students;

Retrieve students in grade 10:

SELECT * FROM Students WHERE grade = 10;

Step 5: Update Data


Increase the grade of student with ID 1 by 1:
UPDATE Students SET grade = grade + 1 WHERE student_id = 1;

Step 6: Practice Challenge


Add another table called 'Teachers' with fields: teacher_id (INT, PRIMARY KEY), first_name
(VARCHAR(50)), last_name (VARCHAR(50)), and subject (VARCHAR(50)). Insert 2 records
and display all teachers who teach 'Mathematics'.

Additional Practice Questions


6. Retrieve all students whose age is above 20.

7. Update the age of a student with a specific StudentID.

8. Delete a student from the database whose name matches a given value.

9. Add a new column 'Email' to the Students table and insert email addresses for existing
students.

10. Display all students ordered by their name in ascending order.

You might also like