Views- It is a stored SQL statement that defines a virtual table. It takes the output of a query and makes it appear as a virtual table.
Advantages:-Here are the advantages of use view.
1.To hide the complexity of a query
(i) Provide different representations of same data.
(ii) To ensure that exactly the same SQL is used throughout your application.
2.To improve security by restricting access to data
(i) Restrict the columns/rows which can be queried.
(ii) Restrict the rows and columns that may be modified.
3.To isolate and application from any future change to the base table definition
(i) Users formulate their queries on the views (virtual tables).
When and how to use:-
Suppose that we have a table which contain first name, middle name, last name and address of user
and somewhere is requirement of list of full name of users.
It will give following result
To get list of full name of user here is the view
LTRIM and RTRIM are SQL string functions.These funtions I have used to remove if any whitespace present left side or right side of FirstName,MiddleName,LastName.
Now whenever you need list of full name of users you can get it by executing this newly created view
Advantages:-Here are the advantages of use view.
1.To hide the complexity of a query
(i) Provide different representations of same data.
(ii) To ensure that exactly the same SQL is used throughout your application.
2.To improve security by restricting access to data
(i) Restrict the columns/rows which can be queried.
(ii) Restrict the rows and columns that may be modified.
3.To isolate and application from any future change to the base table definition
(i) Users formulate their queries on the views (virtual tables).
When and how to use:-
Suppose that we have a table which contain first name, middle name, last name and address of user
and somewhere is requirement of list of full name of users.
It will give following result
To get list of full name of user here is the view
LTRIM and RTRIM are SQL string functions.These funtions I have used to remove if any whitespace present left side or right side of FirstName,MiddleName,LastName.
Now whenever you need list of full name of users you can get it by executing this newly created view
No comments:
Post a Comment