0% found this document useful (0 votes)
90 views

SQL Labsheet 2 - DML Part 1

1. Insert data into tables created in a previous lab using SQL DML statements. 2. Write SQL statements to: a) Update the salary of an employee and date of birth of another employee b) Change null values in a field to 0 c) Update an employee's last name after marriage d) Remove a dependent from a table after they start working

Uploaded by

Hirdesh Ramjutun
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
90 views

SQL Labsheet 2 - DML Part 1

1. Insert data into tables created in a previous lab using SQL DML statements. 2. Write SQL statements to: a) Update the salary of an employee and date of birth of another employee b) Change null values in a field to 0 c) Update an employee's last name after marriage d) Remove a dependent from a table after they start working

Uploaded by

Hirdesh Ramjutun
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

CSE2021Y Database Design and Implementation

Labsheet 2 – SQL – DML Part 1

1. Use SQL DML statements in SQL Server to insert the following data in tables created in
Labsheet 1.
employee
fname minit lname ssn bdate address sex salary superssn dno
John B Smith 1234 1965-01-09 Houston M 30000 3334 5
Franklin T Wong 3334 1955-12-08 Houston M 40000 8886 5
Alicia J Zelaya 9998 1968-01-19 Spring F 25000 9876 4
Jennifer S Wallace 9876 1941-06-20 Bellaire F 43000 8886 4
Ramesh K Narayen 6668 1962-09-15 Humble M 38000 3334 5
Joyce A English 4534 1972-07-31 Houston F 25000 3334 5
Ahmad V Jabbar 9879 1969-03-29 Houston M 25000 9876 4
James E Borg 8886 1937-11-10 Houston M 55000 null 1
dept_locations
department
dnumber dlocation
dname dnumber mgrssn mgrstartdate
1 Houston
Research 5 3334 1988-05-22
4 Stafford
Administration 4 9876 1995-01-01
5 Bellaire
Headquarters 1 8886 1981-06-19
5 Sugarland
project 5 Houston
pname pnumber plocation dnum works_on
ProductX 1 Bellaire 5 essn pno hours
ProductY 2 Sugarland 5 1234 1 32.5
ProductZ 3 Houston 5 1234 2 7.5
Computerization 10 Stafford 4 6668 3 40
Reorganization 20 Houston 1 4534 1 20
Newbenefits 30 Stafford 4 4534 2 20
3334 2 10
dependent 3334 3 10
essn dependent_name sex bdate relationship 3334 10 10
3334 Alice F 1986-04-05 Daughter 3334 20 10
3334 Theodore M 1983-10-25 Son 9998 30 30
3334 Joy F 1958-05-03 Spouse 9998 10 10
9876 Abner M 1942-02-28 Spouse 9879 10 35
1234 Michael M 1988-01-04 Son 9879 30 5
1234 Alice F 1988-12-30 Daughter 9876 30 20
1234 Elizabeth F 1967-05-05 Spouse 9876 20 15
8886 20 null
2. Write SQL Statements for the following:
(a) Change the salary of employee James Borg from 55000 to 56000 and the date of birth of
employee Ahmad Jabbar to 1969-03-30.
(b) For all records which have a null value for the 'hours' field in the works_on table change the
null value to 0.
(c) Employee with SSN 4534 just got married and her last name has changed to her current last
name followed by a '-' followed by the last name of her husband, Herald. Make the
appropriate change in the database.
(d) The son of employee with SSN 3334 has started working and is therefore no longer a
dependent. Show this change in the database.

You might also like