课程: Program Databases with Transact-SQL

今天就学习课程吧!

今天就开通帐号,24,100 门业界名师课程任您挑!

SchemaBind a view

SchemaBind a view

- Views are defined with select statements that reference database tables. This can cause issues if the structure of the underlying table changes after the view is created. For instance if a table is dropped or a column is renamed. Database designers can prevent this disconnect from happening with an the additional option called schema binding. I'm going to create a view that shows some information from the Sales.CustomerTransactions table. We're going to call this view Sales.OutstandingBalance. I'm using a WHERE clause here to only return transactions that have a balance due. This occurs when the customer hasn't fully yet paid their bill. Then we can test out the view by selecting everything from the Sales.OutstandingBalance view. So I'm going to run line six through 22. So this is our starting point, we have 84 rows returned for all of the transactions with a balance due. Now let's suppose that a structural change is made to the database. I'm going to scroll down on my script here…

内容