0% found this document useful (0 votes)
24 views4 pages

DS Lab # 05

This document provides instructions for a database systems lab experiment involving data manipulation language (DML) commands. It introduces the basic DML commands of INSERT, UPDATE, and DELETE and provides syntax examples. It also lists exercises for students to write SQL queries manipulating data in salesman and customer tables, including inserting, updating, deleting, and displaying records.

Uploaded by

ashbalfaheem
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)
24 views4 pages

DS Lab # 05

This document provides instructions for a database systems lab experiment involving data manipulation language (DML) commands. It introduces the basic DML commands of INSERT, UPDATE, and DELETE and provides syntax examples. It also lists exercises for students to write SQL queries manipulating data in salesman and customer tables, including inserting, updating, deleting, and displaying records.

Uploaded by

ashbalfaheem
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/ 4

DEPARTMENT OF TELECOMMUNICATION ENGINEERING

BACHELOR OF SCIENCE IN CYBER SECURITY


MEHRAN UNIVERSITY OF ENGINEERING & TECHNOLOGY, JAMSHORO
DATABASE SYSTEMS
(2nd SEMESTER, 1st Year) LAB EXPERIMENT # 5

Name: _________________________________________________________ Roll No: ______________

Date of Conduct: ___________ Submission Date: _________ Signature of the Lab Tutor: ____________
ABILITY TO CONDUCT
LAB PERFORMANCE INDICATOR SUBJECT KNOWLEDGE DATA ANALYSIS AND INTERPRETATION
EXPERIMENT

SCORE

Objective: To implement Data Manipulation Language (DML) Commands on SQL.


Tools: ORACLE/MySQL/Workbench Duration: 3 Hours

DATA MANIPULATION LANGUAGE (DML): The Data Manipulation Language (DML) is


used to retrieve, insert and modify database information. These commands will be used by all
database users during the routine operation of the database. Let's take a brief look at the basic DML
commands:
I. INSERT
II. UPDATE
III. DELETE
I. INSERT INTO: This is used to add records into a relation. There are two types of INSERT
INTO queries which are defined below:
a) Inserting a single record
Syntax:
INSERT INTO < relation/table name> (field_1,field_2 field n)VALUES (data I,data_2, data_n);
Example:
SQL>INSERT INTO student(id,student_name,class,address)
VALUES (1,'Usama','CyberSecurity','Pak');
b) Inserting multiple records
Syntax:
INSERT INTO < relation/table name> (field_1,field_2 field n)
VALUES (data1),(data2),(data3);

1|Page
DEPARTMENT OF TELECOMMUNICATION ENGINEERING
BACHELOR OF SCIENCE IN CYBER SECURITY
MEHRAN UNIVERSITY OF ENGINEERING & TECHNOLOGY, JAMSHORO
DATABASE SYSTEMS
(2nd SEMESTER, 1st Year) LAB EXPERIMENT # 5
Example:
INSERT INTO student(name, age, email, city)
VALUES ('Usama', 35, '[email protected]', 'Sahiwal'),
('Nasir', 28, '[email protected]', 'Hyd'),
('Arbab',25, '[email protected]', 'Hyd');
II. UPDATE
The UPDATE statement is used to modify the existing records in a table.
Syntax:
UPDATE table_name
SET column1 = value1, column2 = value2, ...
WHERE condition;
For example we have a Customers table.

Example:
UPDATE Customers
SET ContactName = 'Alfred Schmidt', City= 'Frankfurt'
WHERE CustomerID = 1;
Update multiple Records:
It is the WHERE clause that determines how many records will be updated.

2|Page
DEPARTMENT OF TELECOMMUNICATION ENGINEERING
BACHELOR OF SCIENCE IN CYBER SECURITY
MEHRAN UNIVERSITY OF ENGINEERING & TECHNOLOGY, JAMSHORO
DATABASE SYSTEMS
(2nd SEMESTER, 1st Year) LAB EXPERIMENT # 5
The following SQL statement will update the ContactName to "Juan" for all records where country
is "Mexico".
Example:
UPDATE Customers
SET ContactName='Juan', City = ‘UK’
WHERE Country='Mexico';
III. DELETE
The DELETE statement is used to delete existing records in a table.
Syntax:
DELETE FROM table_name WHERE condition;
Example:
DELETE FROM Customers WHERE CustomerName='Alfreds Futterkiste';
Delete all records
It is possible to delete all rows in a table without deleting the table. This means that the table
structure, attributes, and indexes will be intact:
Syntax:
DELETE FROM table_name;
Example:
DELETE FROM Customers;

Exercise
Consider the following tables to write SQL queries.

1. Salesman
2. Customer

Create salesman_id and customer_id as primary keys from both tables respectively.

3|Page
DEPARTMENT OF TELECOMMUNICATION ENGINEERING
BACHELOR OF SCIENCE IN CYBER SECURITY
MEHRAN UNIVERSITY OF ENGINEERING & TECHNOLOGY, JAMSHORO
DATABASE SYSTEMS
(2nd SEMESTER, 1st Year) LAB EXPERIMENT # 5

1. Write an SQL query to display the salesman name whose city is London from Salesman
Table.
2. Write an SQL query to display the salesman name whose grade is 100 from Customer
Table.
3. Write an SQL query to update the Julia Green to your own [First Name] [Last Name]
from Customer Table. E.g Ahmed Hussain.
4. Write an SQL query to update the City as Hyderabad and Grade as 1000 from Customer
Table.
5. Write an SQL query to delete the Mc Lyon from Salesman Table.
6. Write an SQL query that show the details of Salesman who have received commission of
greater than 0.12 and city is Paris from Salesman Table.
7. Write an SQL query to add one more column as “Salary”.
8. Write an SQL query to insert data in the newly created Salary Column in the Salesman
Table.
9. Write an SQL query to delete the grade column from Customer Table.
10. Summarize the whole lab in your own sentence whatever you have learnt in this lab.

4|Page

You might also like