DS Lab # 05
DS Lab # 05
Date of Conduct: ___________ Submission Date: _________ Signature of the Lab Tutor: ____________
ABILITY TO CONDUCT
LAB PERFORMANCE INDICATOR SUBJECT KNOWLEDGE DATA ANALYSIS AND INTERPRETATION
EXPERIMENT
SCORE
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