Professional Documents
Culture Documents
EXPERIMENT NO 3
Data presentation
Experimental results
Conclusion
Date: Signature:
AIR University Islamabad DBS LAB
LAB TASKS
Task1:
Using the DELETE statement, delete the record for the student having name
Akram and Ahsan in the table you have created in lab 2. Also, delete the
record for the course having course code=1001.
code=1001.
CREATE TABLE Students (
Name varchar(25),
Reg_No int,
Courses varchar(255),
Course_Code int,
Offered_By varchar(255)
);
INSERT INTO Students (Name, Reg_No, Courses, Course_Code, Offered_By)
VALUES
('Ali', '01', 'DIP', '1001', 'Mr.A'),
('Umar', '02', 'DLD', '1002', 'Mr.A'),
('Junaid', '03', 'DBS', '1003', 'Mr.B'),
('Hamza', '04', 'DIP', '1002', 'Mr.C'),
('Ahmed', '05', 'MLI', '1001', 'Mr.C'),
('Akram', '06', 'ENG', '1003', 'Mr.B'),
('Ahsen', '07', 'MLI', '1004', 'Mr.A'),
('Imtiaz', '08', 'ENG', '1003', 'Mr.C'),
('Hassan', '09', 'DIP', '1001', 'Mr.A'),
('Mutahir', '10', 'DSP', '1005', 'Mr.Z');
Output:
2
AIR University Islamabad DBS LAB
Task2:
Sort the tables you have created in lab 2 in ascending and descending order
by their name.
CREATE TABLE Students (
Name varchar(25),
Reg_No int,
Courses varchar(255),
Course_Code int,
Offered_By varchar(255)
);
INSERT INTO Students (Name, Reg_No, Courses, Course_Code, Offered_By)
VALUES
('Ali', '01', 'DIP', '1001', 'Mr.A'),
('Umar', '02', 'DLD', '1002', 'Mr.A'),
('Junaid', '03', 'DBS', '1003', 'Mr.B'),
('Hamza', '04', 'DIP', '1002', 'Mr.C'),
('Ahmed', '05', 'MLI', '1001', 'Mr.C'),
('Akram', '06', 'ENG', '1003', 'Mr.B'),
('Ahsen', '07', 'MLI', '1004', 'Mr.A'),
('Imtiaz', '08', 'ENG', '1003', 'Mr.C'),
('Hassan', '09', 'DIP', '1001', 'Mr.A'),
('Mutahir', '10', 'DSP', '1005', 'Mr.Z');
Output:
3
AIR University Islamabad DBS LAB
Task3:
For the table in lab 2, generate a query for updating the table with fully
qualified names and update the following values:
CREATE TABLE Students (
Name varchar(25),
Reg_No int,
Courses varchar(255),
Course_Code int,
Offered_By varchar(255)
);
INSERT INTO Students (Name, Reg_No, Courses, Course_Code, Offered_By)
VALUES
('Ali', '01', 'DIP', '1001', 'Mr.A'),
('Basit', '02', 'DLD', '1002', 'Mr.A'),
('Junaid', '03', 'DBS', '1003', 'Mr.B'),
('Hamza', '04', 'DIP', '1002', 'Mr.C'),
('Ahmed', '05', 'MLI', '1001', 'Mr.C'),
('Akram', '06', 'ENG', '1003', 'Mr.B'),
('Ahsen', '07', 'MLI', '1004', 'Mr.A'),
('Imtiaz', '08', 'ENG', '1003', 'Mr.C'),
('Hassan', '09', 'DIP', '1001', 'Mr.A'),
('Mutahir', '10', 'DSP', '1005', 'Mr.Z');
UPDATE Students
SET Courses='SE', Offered_By='Mr.Z'
WHERE Name='Ali';
UPDATE Students
SET Courses='CG', Offered_By='Mr.X'
WHERE Name='Basit';
Output:
4
AIR University Islamabad DBS LAB
Learning Outcomes:
DML is used to manipulate the data within the database. DDL is used to create and
modify database objects like tables, indexes, views, and constraints. DML is used
to perform operations on the data within those database objects.
DDL statements are typically executed less frequently than DML statements.
The primary purpose of DML commands is to select, insert, delete, update, and
merge data records in RDBMS.