What is the MySQL view?

Source: Internet
Author: User
Tags mysql view

What is MySQL view is a virtual table whose content is defined by the query. Like a real table, a view contains a series of columns and row data with names. However, a view does not exist in the database as a stored data value set. Rows and columns are used to define tables referenced by View queries and dynamically generate tables when views are referenced. For the referenced basic table, the view function is similar to filtering. The filtering of the definition view can be from one or more tables of the current or other databases, or other views. There are no restrictions on query through views, and there are few restrictions on data modification through them. A view is an SQL statement stored in a database. It is mainly for two reasons: security reasons. A view can hide some data, such as the Social Insurance Fund table, you can use the view to display only the name and address, but not the social insurance number and wage number. Another reason is that complex queries are easy to understand and use. Therefore, a view is not a basic table that actually exists, but a virtual table. The data of the view is not actually stored in the database in the view structure, but in the table referenced by the view. Once defined, the view is stored in the database. The corresponding data is not stored in the database as the table. The data displayed in the view is only stored in the basic table. Operations on a view are the same as those on a table. You can query, modify (with certain restrictions), and delete a view. When you modify the data seen through the view, the data of the corresponding basic table also needs to change. At the same time, if the data of the basic table changes, this change can also be automatically reflected in the view. View has many advantages, mainly manifested in: • viewpoint set • Simplified operation • customized data • merged and split data • Secure how to create a view create view name as select * from indicates the where condition; for example, create view v_t1 as select * from t1 where id> 4 and id <11; view: show tables; at this time, you will find a table in the database, which is the view chart, it is not a real table but a virtual table. You can also add, delete, query, and modify charts. Delete view: drop view name. Depending on the chart and data table, once the master table is deleted, an error is returned when you query the view chart.

Related Article

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.