Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

DATABASE MANAGEMENT LAB (CS 29006)

School of Electronics Engineering

Experiment Number 01
Experiment Title Sturtured Querry Language
Date of Experiment 24/01/2024
Date of Submission 13/02/2024

1. Problem Statement:

1. Create a table name student with the following attributes (data types are shown in the
parenthesis): Roll No (Integer), Name (varchar(50)), Gender (Char), CGPA (Float)

2. Insert at least ten records into the table.

3. Add a new column to the table, for the Date of Birth (Date). Use the date data type to
store this. Also, update the date of birth of all the records

4. Delete from the table the record of the student whose CGPA is the lowest

5. Display only those students whose CGPA lies in the range of [6, 8]

6. Order the data in the tables based on CGPA from ascending to descending.

7. Display the records for students with the smallest and the largest CGPA

8. Display only those students whose CGPA lies in the range of [6, 8] and whose DOB
is after 1-6-2006.

2. Theory:

SQL (Structured Query Language) is a standard language for managing relational


databases in RDBMS (Relational Database Management Systems). It consists of:

 DDL (Data Definition Language): Defines and manages the database structure.
 DML (Data Manipulation Language): Manipulates and retrieves data in the
database.
 DCL (Data Control Language): Manages access and security permissions.
 TCL (Transaction Control Language): Ensures transaction consistency and
integrity.

Submitted by:
Name: Nikhil Kumar
Roll No.: 2230030
DATABASE MANAGEMENT LAB (CS 29006)
School of Electronics Engineering

3. Code and Result :

create database lab1;

use lab1;

create table student (roll_no integer,name varchar(50),gender char,cgpa float );

select * from student;

insert into student (roll_no,name,gender,cgpa)


values
(1,'jay','m',8.2),
(2,'vijay','m',7.2),
(3,'annaya','f',7.5),
(4,'aditya','m',9.2),
(5,'jaya','f',6.2),
(6,'riya','f',7.2),
(7,'ram','m',10),
(8,'rahul','m',8.2),
(9,'payal','f',7.2),
(10,'reena','f',8.5);

select * from student;

Submitted by:
Name: Nikhil Kumar
Roll No.: 2230030
DATABASE MANAGEMENT LAB (CS 29006)
School of Electronics Engineering

alter table student add column dob date;

update student set dob='2003-06-11' where roll_no=1;


update student set dob='2003-12-01' where roll_no=2;
update student set dob='2003-06-09' where roll_no=3;
update student set dob='2003-05-06' where roll_no=4;
update student set dob='2003-01-13' where roll_no=5;
update student set dob='2003-03-18' where roll_no=6;
update student set dob='2003-07-21' where roll_no=7;
update student set dob='2003-11-15' where roll_no=8;
update student set dob='2003-04-10' where roll_no=9;
update student set dob='2003-12-12' where roll_no=10;

select * from student;

Submitted by:
Name: Nikhil Kumar
Roll No.: 2230030
DATABASE MANAGEMENT LAB (CS 29006)
School of Electronics Engineering

delete from student where cgpa=min(cgpa) ;


select * from student;

select * from student where cgpa between 6 and 8;

Submitted by:
Name: Nikhil Kumar
Roll No.: 2230030
DATABASE MANAGEMENT LAB (CS 29006)
School of Electronics Engineering

select * from student order by cgpa ;

select * from student order by cgpa desc;

Submitted by:
Name: Nikhil Kumar
Roll No.: 2230030
DATABASE MANAGEMENT LAB (CS 29006)
School of Electronics Engineering

select * from student where cgpa=(select max(cgpa) from student );

select * from student where cgpa=(select min(cgpa) from student );

select * from student where cgpa between 6 and 8 and dob > '2003-11-01';

Submitted by:
Name: Nikhil Kumar
Roll No.: 2230030
DATABASE MANAGEMENT LAB (CS 29006)
School of Electronics Engineering

4. Concluding Remarks:
SQL is a fundamental language for managing relational databases in the context of
RDBMS. It provides a comprehensive set of tools through DDL, DML, DCL, and
TCL to define and manipulate data structures, control access and security, ensure
transactional integrity, and query and retrieve information.

Submitted by:
Name: Nikhil Kumar
Roll No.: 2230030

You might also like