What are the different types of the Views in the Transact- SQL? What is their importance in the database? When we can use the read only and updatable views?
As I mentioned in the last article “What is the importance of the View in the SQL Server? What are the advantages and disadvantages of the Views in SQL Server?” view is defined as the “Virtual table”. These tables are not the real tables in the database, but these are like the virtual tables which contain the columns and data like the other real tables. These views are created from one or more than one tables to store the columns and data in it. Here is some of the usability of the views in the Transact-SQL
1) View is used to restrict the user from accessing the specific rows in the table (s). Let have a simple example of an employee to see only the records of him/her related to work hours in the time tracking table.
2) These are also used for restricting the access to specific column (s) to anyone in the team. For example allow employees who are working in the company, they can see the name, work phone, department and designation in the employee table. But we don’t allow them to see the personal information like SSN, Salary and Date of Birth D.O.B. in the same employee table.
3) Views are also helpful for us to get the aggregate information like Total of the Columns, Difference of the Columns, Average and Percentage (%) etc.
Here is the some of the useful types of the views we can use for the sake of the security of direct access to data by user:-
We have the two types of the view which are known as read only and other one is updatable views. People dealing with the database can easily tell us which one is read only view and which one is updatable view. If we are able to map the view schema to the underlying base tables in the reverse mapping then we can call those views as the updatable views with the help of the INSERT, UPDATE and DELETE operations can be done to perform on the base table(s).
Read only views cannot perform these INSERT, UPDATE and DELETE operations on the reverse mapping between view schema and base table’s schema. Sometime some of the system allows the definition of INSTEAD OF triggers on views. We can use the other logic for the execution in place of the INSERT, UPDATE and DELETE operations on the views. We can also use read only views to modify the implemented data in the database system. Interesting point regarding the views is the INSTEAD OF the trigger on the views never change the properties of the READ only and Updatable views at any time.
I will discuss the some more information on the views in the next article “What are the advantages and disadvantages of the views in the Transact-SQL?” we will talk about the views in details in the discussion on the advantages and disadvantages of the views. But for sure we can save our data from the direct access to the tables and columns in our database.
Thanks to everyone for visiting this article you can leave some comments on this article for more knowledge sharing base and sharing personal experience with everyone in the database.
To be continued…….
Thanks,
Sandeep Rajmail


Leave a Reply