0% found this document useful (0 votes)
209 views6 pages

11/20/2018 MIST.3030 Database Management Systems by Xiaobai Li 1

This document contains instructions and examples for several database management tasks using SQL, including: 1. Creating a view called LargeOrders that displays order details for orders of more than 3 units. 2. Creating an updatable view called ProductDescriptionV to display and add a new product description. 3. Granting permissions to a partner to view tables and writing a query using the partner's tables. 4. Using transactions to delete a customer and update another customer's name in the customer table.

Uploaded by

Nina Le
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
209 views6 pages

11/20/2018 MIST.3030 Database Management Systems by Xiaobai Li 1

This document contains instructions and examples for several database management tasks using SQL, including: 1. Creating a view called LargeOrders that displays order details for orders of more than 3 units. 2. Creating an updatable view called ProductDescriptionV to display and add a new product description. 3. Granting permissions to a partner to view tables and writing a query using the partner's tables. 4. Using transactions to delete a customer and update another customer's name in the customer table.

Uploaded by

Nina Le
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

11/20/2018 MIST.

3030 Database Management Systems by Xiaobai Li 1

3. (8 points) Create a view using the dbo’s tables (and name it LargeOrders), which includes
OrderID, CustomerID, ProductID and Quantity for orders of more than three units. Turn in both the
SQL statement and the output results
SQL Statement:

Output:

4. (12 points) Create an updateable view, named ProductDescriptionV, which includes ProductID
and ProductDescription values for all products. Add a new product with ProductID = 101 and
ProductDescription = ‘Bookshelf’ to the view. Print out the results before and after the update.
Turn in the SQL commands for creating and updating the view.
SQL Commands:
11/20/2018 MIST.3030 Database Management Systems by Xiaobai Li 2

Before update:

SQL to update:

After update:
11/20/2018 MIST.3030 Database Management Systems by Xiaobai Li 3

5. (12 points) You need a partner to complete this problem. Please type or write your partner’s name
on the page for this problem.
a. Grant the SELECT permission on your four PVF tables to your partner. Print out your SQL
statements.

b. Ask your partner to grant the SELECT permission on his/her PVF tables to you. Then write a
query based on your partner’s tables to find out CustomerID, Name, OrderID and OrderDate
for those customers who placed orders in November, 2018. Print out your SQL statement and
the results. [Note: In SQL Server, use a pair of single quotes for the values of a Date type; the
MS-Access syntax (#) won’t work in SQL Server.]
SQL:
11/20/2018 MIST.3030 Database Management Systems by Xiaobai Li 4

Output:

6. (8 points) Do this problem with your own tables.


You were told that customer #15 had gone out of business and thus should be deleted from the
customer table. You were also notified by customer #9 that its name had been changed from “M &
H Casual Furniture” to “Casual Furniture”. Use the following SQL commands to process the two
transactions in a batch:
begin tran
<transaction processing statements>
11/20/2018 MIST.3030 Database Management Systems by Xiaobai Li 5

if @@error > 0 …
else …

Show the whole process in your solution. Display the table’s contents before and after the
transaction using “select CustomerID, Name from MyCustomer;” (instead of opening
the entire Customer table).
Before the transaction:

SQL:
11/20/2018 MIST.3030 Database Management Systems by Xiaobai Li 6

Output:

You might also like