Summary of the SQL Server View
A view is stored on a physical table. It is changed due to changes to the physical table and generally does not need to be updated.
View as a filter: It can be seen from the Filter Name that the main purpose of such a view is to hide and can be considered as a hidden select statement.
One of the most important details in a view is that in many Update operations, you need to add the "checkwith option" Statement (where conditions must be met for Update, insert, and delete ), this ensures data integrity.
In addition, in most databases, the View tool is usually used too much or too little. Some people like to use views to abstract almost everything (this also means adding a layer of processing ). Others seem to have forgotten the view. View should be used at the right time to get better results.
When using a view, you should pay attention to the following aspects:
1. Avoid building a view based on the view-instead, apply the appropriate query information from the first view to the new view.
2. Remember to use the view with check option to provide some flexibility that is not available for different check constraints.
3. View encryption-the encrypted view can no longer restore unencrypted code.
4. In addition to permissions, using Alter View means that the existing View is completely replaced. This means that if the encryption and restrictions in the modified view are still valid, the alter statement must contain the withencryption and withcheck option clauses.
5. Use sp_helptext to display the supported code of the view-avoid using the system table.
6. Minimize users who use the view for production queries-because they increase additional system overhead and compromise performance.
General View usage:
1. Filter rows
2. protect sensitive data
3. Reduce database complexity
4. Abstract multiple physical databases into one logical database