In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
This article is to share with you about whether there is room for mysql views. The editor thought it was very practical, so I shared it with you as a reference. Let's follow the editor and have a look.
The mysql view has no space. The MySQL view is a virtual table that does not actually exist in the database and does not allocate space. The MySQL database only stores the definition of the view, but does not store the data in the view, which is stored in the real table referenced by the query of the defined view.
A MySQL view (View) is a virtual table. Like a real table, a view is made up of columns and rows, but the view does not actually exist in the database. The data for rows and columns comes from the table used in the query that defines the view and is dynamically generated when the view is used.
Only the definition of the view is stored in the database, but there is no data in the view, which is stored in the real table referenced by the query of the defined view. When you query data using a view, the database fetches the corresponding data from the real table. Therefore, the data in the view depends on the data in the real table. Once the data in the real table changes, so does the data displayed in the view.
The view can select the information that is useful to the user from the original table, and the information that is useless to the user, or the user does not have the permission to know, can be shielded directly, which is similar to filtering. This not only simplifies the application, but also ensures the security of the system.
For example, there is a company department table department in the following database. The table includes department number (d_id), department name (d_name), function (function), and office address (address). The department table is structured as follows:
Mysql > DESC department +-+ | Field | Type | Null | Key | Default | Extra | +- +-+ | d_id | int (4) | NO | PRI | NULL | d_name | varchar (20) | NO | UNI | NULL | | function | varchar (50) | YES | | NULL | | address | varchar (50) | YES | | NULL | | +-+- +-+ 4 rows in set (0.02 sec)
There is also an employee form worker. The table contains the employee's work number (num), department number (d_id), name (name), gender (sex), date of birth (birthday), and home address (homeaddress). The worker table is structured as follows:
Mysql > DESC worker +-+ | Field | Type | Null | Key | Default | Extra | +- -+-+ | num | int (10) | NO | PRI | NULL | d_id | int (4) | YES | MUL | NULL | | name | varchar (20) | NO | | NULL | | sex | varchar (4) | NO | NULL | | birthday | Datetime | YES | | NULL | | homeaddress | varchar (50) | YES | | NULL | | +-+-+ 6 rows in set (0.01sec)
Due to the different scope of authority of the leaders of each department, the leaders of each department can only see the employee information of that department; moreover, the leader may not care about the birthday and home address of the employee. In order to achieve this goal, a view can be established for the leaders of each department, through which the leader can only see the designated information of the employees of the department.
For example, create a view named product _ view for the production department. Through the view product_ view, the leaders of the production department can only see the work number, name and gender of the employees in the production department. The information of these department tables and worker tables still exist in their respective tables, while no data information is stored in the view product_view. When the information of the department table and the worker table changes, the information displayed by the view product_view will change accordingly.
Tip: if you often need to query data for specified fields from multiple tables, you can create a view on those tables that displays the data for those fields.
The view of MySQL does not support the ability to enter parameters, so there is a lack of interactivity. However, for operations that do not change much, using views can greatly simplify the operation of users.
Views are different from datasheets, and they differ in the following ways:
A view is not a real table in the database, but a virtual table, and its structure and data are based on the query of the real table in the data.
The query operation SQL statement stored in the database defines the contents of the view, and the column data and row data come from the actual table referenced by the view query, which is generated dynamically when the view is referenced.
The view has no actual physical record and is not stored in the database in the form of a dataset, but the corresponding data is actually stored in the real table referenced by the view.
The view is the window of the data, and the table is the content. The table is the storage unit of the actual data, while the view only displays the data in different ways, and its data source is still the actual table.
A view is a way to view a data table, which can query the data made up of certain fields in the data table, just a collection of SQL statements. From a security point of view, the data security of the view is higher, and the users who use the view do not touch the data table and do not know the table structure.
The creation and deletion of the view only affects the view itself, not the corresponding basic table.
Thank you for reading! About whether the mysql view has space to share here, I hope the above content can be of some help to you, so that you can learn more knowledge. If you think the article is good, you can share it and let more people see it.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.