You use a Microsoft Azure SQL DataBase instance. The instance contains a table named Customers that has columns named Id, Name, and IsPriority.
You need to create a view named VwPriorityCustomers that:
– returns rows from Customer that have a value of True in the IsPriority column, and
– does not allow columns to be altered or dropped in the underlying table.
Which Transact-SQL statement shoul you run?
A . CREATE VIEW VwPriorityCustomers
AS
SELECT Id, Name FROM dbo.Customers WHERE IsPriority=1
WITH CHECK OPTION
B . CREATE VIEW VwPriorityCustomers
WITH VIEW_METADATA
AS
SELECT Id, Name FROM dbo.Customers WHERE IsPriority=1
C . CREATE VIEW VwPriorityCustomers
WITH ENCRYPTION
AS
SELECT Id, Name FROM dbo.Customers WHERE IsPriority=1
D . CREATE VIEW VwPriorityCustomers
WITH SCHEMABINDING
AS
SELECT Id, Name FROM dbo.Customers WHERE IsPriority=1
Answer: D
Explanation:
SCHEMABINDING binds the view to the schema of the underlying table or tables. When SCHEMABINDING is specified, the base table or tables cannot be modified in a way that would affect the view definition.
References: https://docs.microsoft.com/en-us/sql/t-sql/statements/create-view-transactsql?view=sql-server-2017
Leave a Reply