0% found this document useful (0 votes)
29 views2 pages

Book Rental Database DML Exercise ANSWER

This document provides examples of SQL statements to manipulate data in database tables: 1. INSERT statements are used to insert new rows into the Book table, specifying values for all or some columns. 2. An UPDATE statement is used to increase the rental rate of all book copies by 10%. Another UPDATE statement changes the address field where the string "Rose Central" is found. 3. A DELETE statement removes rows associated with loans and member details for the member "Tan Mei Ling". Another DELETE statement removes all rows from the Loan table.

Uploaded by

cupcake sweet
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
0% found this document useful (0 votes)
29 views2 pages

Book Rental Database DML Exercise ANSWER

This document provides examples of SQL statements to manipulate data in database tables: 1. INSERT statements are used to insert new rows into the Book table, specifying values for all or some columns. 2. An UPDATE statement is used to increase the rental rate of all book copies by 10%. Another UPDATE statement changes the address field where the string "Rose Central" is found. 3. A DELETE statement removes rows associated with loans and member details for the member "Tan Mei Ling". Another DELETE statement removes all rows from the Loan table.

Uploaded by

cupcake sweet
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
You are on page 1/ 2

LAB EXERCISE - ANSWER

SQL DATA MANIPULATION LANGUAGE (DML)


INSERT, UPDATE AND DELETE STATEMENTS

CASE STUDY: NP40 BOOK RENTAL

1) Insert a new row into the Book table for all columns.

INSERT INTO Book (ISBN, Title, YearPublish, PublisherID, BookCat)


VALUES (‘0330246631’, ‘Vet in harness’, 1975, 6, ‘NF’);

OR

INSERT INTO Book


VALUES (‘0330246631’, ‘Vet in harness’, 1975, 6, ‘NF’);

2) Insert a new row into the Book table supplying data for all the mandatory columns: ISBN and
Title.

INSERT INTO Book (Title, ISBN)


VALUES (‘Inside SQL Server 2000’, ‘0735609985’);

OR

INSERT INTO Book (Title, ISBN)


VALUES (‘Inside SQL Server 2000’, ‘0735609985’, NULL, NULL, NULL);

OR

INSERT INTO Book (Title, ISBN)


VALUES (‘Inside SQL Server 2000’, ‘0735609985’, ‘ ’, ‘ ‘, ‘ ‘);

3) Increase the rental rates of all copies of the books by 10 percent.

UPDATE BookCopy
SET RentalRate = RentalRate * 1.1;

4) Change the address of the Rose Central branch to 33, Rose Central.

UPDATE Branch
SET Address = ’33, Rose Central’
WHERE Address LIKE ‘%Rose Central%’;

1
5) Change the address of the Tulip branch to ‘535 NP Orchard Road’ and its telephone number to
64601111.

UPDATE Branch
SET Address = ‘535 NP Orchard Road’,
TelNo = ‘64601111’
WHERE Address LIKE ‘%Tulip%’;

6) Delete the rows associated with loans made by the member named ‘Tan Mei Ling’ and delete
the details of this member as well.

DELETE Loan
WHERE Loan.MemberID = Member.MemberID
AND Name = ‘Tan Mei Ling’;

DELETE Member
WHERE Name = ‘Tan Mei Ling’;

7) Delete all rows in the Loan table.

DELETE Loan;

You might also like