Beruflich Dokumente
Kultur Dokumente
Implementing Views
Introduction to Views
Advantages of Views
Defining Views
Modifying Data Through Views
Introduction to Views
i.e. View is an object that derives its data from one or more tables
( Base tables or Underlying Tables).
EmployeeView
EmployeeView
Lastname
Lastname Firstname
Firstname
Davolio
Davolio Nancy
Nancy User’s View
Fuller
Fuller Andrew
Andrew
Leverling
Leverling Janet
Janet
Advantages of Views
USE
USE Northwind
Northwind ShipStatusView
GO
GO
CREATE
CREATE VIEW
VIEW ShipStatusView
ShipStatusView
AS OrderID
AS OrderID ShippedDate
ShippedDate ContactName
ContactName
SELECT
SELECT OrderID,
OrderID, RequiredDate,
RequiredDate, ShippedDate,
ShippedDate, 10264 1996-08-23
1996-08-21
10264 1996-08-21Laurence
1996-08-23 LaurenceLebihan
Lebihan
ContactName
ContactName 10271 1996-08-30
1996-08-29 Georg Pipps
10271 1996-08-30
1996-08-29 Georg Pipps
FROM
FROM Customers cc INNER
Customers INNER JOIN
JOIN Orders
Orders oo 10280
10280 1996-09-12
1996-09-11
1996-09-11Horst
1996-09-12 HorstKloss
Kloss
ON
ON c.CustomerID
c.CustomerID == O.CustomerID
O.CustomerID
WHERE RequiredDate < ShippedDate
WHERE RequiredDate < ShippedDate
Altering and Dropping Views
Altering Views
USE
USE Northwind
Northwind
GO
GO
ALTER
ALTER VIEW
VIEW EmployeeView
EmployeeView
AS
AS
SELECT
SELECT LastName,
LastName, FirstName,
FirstName, Extension
Extension
FROM Employees
FROM Employees
USE
USE Northwind
Northwind
GO
GO
CREATE
CREATE VIEW
VIEW customers_view
customers_view
WITH ENCRYPTION
WITH ENCRYPTION
AS
AS
SELECT
SELECT customerid,companyname
customerid,companyname
FROM
FROM customers
customers
GO
GO
Sp_helptext ‘customers_view’
The object comments have been encrypted.
Modifying Data Through Views
1. True
2. False
Q.5. What is the Syntax to create a View.
Q.6. What is With Encryption.?
Q.7. What is With Check Option.
Q.8. The View created by using With Encryption can be
Decrypted .?
1. Yes
2. No
Q.9. Views can be used for ________
1. Providing row and column level security.
2. Ensuring efficient access to data.
3. Masking data complexity from user.
4. Helps to work as Physical Table for User.
5. All of the Above.
Q.10. If columns names are not specified explicitly in the
View Definition statement then the view inherits the
column names of the______________
1. System catalog
2. Sp_depends
3. Source of the View
4. None of the above.
Q.11. The Clause ‘ WITH CHECK OPTION ’ indicates that
Update and Insert operations against the view are to
be checked to ensure that the Updated or Inserted
rows dissatisfy the view definition condition.
1. True
2. False
Q.12. You are executing performance optimization on
your company's market research database. On the
tblConsumers table, you have a view named
vConsumerData. You would like to see the original
statement used to create the view. What statement
should you execute?
1. sp_helptext vConsumerData
2. sp_helptext tbl_Consumers
3. sp_depends v_ConsumerData
4. sp_depends tbl_Consumers
Q.13. Which of the following statements is true about
modifying data using a view?
Introduction to Views
Advantages of Views
Defining Views
Modifying Data Through Views
It is
Courage and Character
that is the deadly combination
for Success
Thank You.