diff options
Diffstat (limited to 'task5_views.sql')
| -rw-r--r-- | task5_views.sql | 38 |
1 files changed, 35 insertions, 3 deletions
diff --git a/task5_views.sql b/task5_views.sql index 15032de..145380e 100644 --- a/task5_views.sql +++ b/task5_views.sql @@ -3,7 +3,7 @@ --------------- CREATE VIEW PaymentNotifications AS -SELECT Customers.email, Payments.amount, Orders.date +SELECT Payments.id, Customers.email, Payments.amount, Orders.date FROM Payments INNER JOIN Orders ON Payments.order_id = Orders.id INNER JOIN Customers ON Orders.customer_id = Customers.id @@ -37,7 +37,7 @@ GO CREATE VIEW BoxDates AS -SELECT Orders.id, Boxes.id, Deliveries.date +SELECT Boxes.id, Orders.id, Deliveries.date FROM Shipments INNER JOIN Orders ON Shipments.order_id = Orders.id INNER JOIN Boxes ON Orders.id = Boxes.order_id @@ -79,4 +79,36 @@ GO --------------- -- Задание 3 -- ----------------
\ No newline at end of file +--------------- + +SET NUMERIC_ROUNDABORT OFF; +SET ANSI_PADDING, ANSI_WARNINGS, + CONCAT_NULL_YIELDS_NULL, ARITHABORT, + QUOTED_IDENTIFIER, ANSI_NULLS ON; +GO + +CREATE VIEW [dbo].[PaymentNotificationsInd] WITH SCHEMABINDING AS +SELECT Payments.id, Customers.email, Payments.amount, Orders.date +FROM [dbo].[Payments] +INNER JOIN [dbo].[Orders] ON Payments.order_id = Orders.id +INNER JOIN [dbo].[Customers] ON Orders.customer_id = Customers.id +GO + +DROP VIEW PaymentNotificationsInd +GO + +CREATE UNIQUE CLUSTERED INDEX NotifyEmail +ON PaymentNotificationsInd (id, email) +GO + +DROP INDEX NotifyEmail ON PaymentNotificationsInd +GO + +SELECT * FROM PaymentNotificationsInd +GO + +SELECT Payments.id, Customers.email, Payments.amount, Orders.date +FROM [dbo].[Payments] +INNER JOIN [dbo].[Orders] ON Payments.order_id = Orders.id +INNER JOIN [dbo].[Customers] ON Orders.customer_id = Customers.id +GO
\ No newline at end of file |