0% found this document useful (0 votes)
10 views3 pages

Database Lab

The document outlines a database lab exercise focused on creating a StudentManagement database and a Students table with specified columns. It includes SQL commands for inserting data, querying students in a specific class, updating a student's age, and deleting a record. The solutions provided demonstrate basic SQL operations for managing student records.

Uploaded by

hinar0337
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)
10 views3 pages

Database Lab

The document outlines a database lab exercise focused on creating a StudentManagement database and a Students table with specified columns. It includes SQL commands for inserting data, querying students in a specific class, updating a student's age, and deleting a record. The solutions provided demonstrate basic SQL operations for managing student records.

Uploaded by

hinar0337
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/ 3

Database Lab

Question 1: Create a Database and Table


Create a database named StudentManagement. Inside this
database, create a table Students with the following structure:
Column Name Data Type Constraint

StudentID INT PRIMARY KEY

Name VARCHAR(50) NOT NULL

Age INT

Class VARCHAR(20)

AdmissionDate DATE

Solution:
CREATE DATABASE StudentManagement;

USE StudentManagement;

CREATE TABLE Students (


StudentID INT PRIMARY KEY,
Name VARCHAR(50) NOT NULL,
Age INT,
Class VARCHAR(20),
AdmissionDate DATE
);
Question 2: Insert Data

Insert the following data into the Students table:


StudentID Name Age Class AdmissionDate

1 Ali Ahmed 15 10th 2023-03-10

2 Zara Khan 14 9th 2023-04-15

3 Bilal Zain 16 11th 2023-02-20


Solution:
INSERT INTO Students (StudentID, Name, Age, Class, AdmissionDate)
VALUES
(1, 'Ali Ahmed', 15, '10th', '2023-03-10'),
(2, 'Zara Khan', 14, '9th', '2023-04-15'),
(3, 'Bilal Zain', 16, '11th', '2023-02-20');

Question 3: Query Data


Write a query to display all students who are in class
10th.
Solution:
SELECT * FROM Students
WHERE Class = '10th';
Question 4: Update Data
Update the age of Ali Ahmed to 16.
Solution:
UPDATE Students
SET Age = 16
WHERE Name = 'Ali Ahmed';

Question 5: Delete a Record


Delete the record of the student with StudentID = 3.
Solution:
DELETE FROM Students
WHERE StudentID = 3;

You might also like