What does a view do in a database? When do I need to use a view?

Source: Internet
Author: User
The benefits of the view can be divided into four main points:
I would like to say something simple, I hope you can understand.

1th:
With views, you can tailor user data to focus on specific data.

Explain:
In the actual process, the company has different roles of staff, we take the sales company as an example,
The purchaser, who may need some data relating to him, and that has nothing to do with him, is not
Has any significance, we can according to this actual situation, specially for the procurement personnel creates a visual
Figure, when he queries the data, just select * from View_caigou.

2nd: Using views, you can simplify data manipulation.

Explanation: When we use queries, we use aggregate functions in many cases and
Displays information about other fields and may also need to be associated with other tables, where the written statement may
It's going to be very long, and if this action happens frequently, we can create the view, and after that, I
We only need select * from View1 to be able ~, is not very convenient AH ~

3rd: Use the view, the data in the base table has a certain security

Because the view is virtual, it doesn't exist physically, it just stores the collection of data, and we can
The key field information in the base table can be given to the user without a view, which is a set of dynamic data
Together, the data is updated as the base table is updated. At the same time, the user can not change the view
and delete, you can guarantee the security of the data.

4th: You can merge the separated data and create the partitioned view

With the development of society, the company's business volume continues to expand, a large company, subordinates are equipped with very
Many branches, in order to manage conveniently, we need the structure of the unified table, regular view of the company's business
Situation, while looking at each company's data is inconvenient, not very good comparability, if these
It's much more convenient to combine data into a single table, where we can use the Union keyword,
Merge the data from each branch into one view.

Above, that's what I think the view does, and many companies actually use views to query the data.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.