In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
The following brings you mysql view knowledge related content, I believe you must have read similar articles. What's the difference between what we bring to everyone? Let's take a look at the body. I believe you will gain something after reading the knowledge of mysql view.
View concept:
A view refers to a virtual table in a computer database, whose contents are defined by a query. Like a real table, a view contains a series of named columns and rows of data. However, the view does not exist in the database as a set of stored data values. Row and column data to freely define the table referenced by the view's query, and dynamically generated when the view is referenced. For details, see the Baidu encyclopedia of the view, which has a detailed explanation of the classification and advantages of the view.
View creation:
Create view view_name as select column 1, column 2,. From table name
We can think of the view as a predefined subquery, as in the above statement, it would be quite easy to understand if we replaced create with select.
Select * from select col_1,col_2 from tbl_1 as temp
In fact, the working principle of the view is the same as the temporary table generated by this seed query, and the virtual table will be generated dynamically according to the original table only when the view is used. So the data of the view will change according to the data change of the original table.
Give an example
`create table employee (
Id int primary key auto_increment
Name varchar (20) not null
Salary decimal (10Pol 2) not null default 1000
);
Create view v_emp as select id,name from employee; `
Mysql > desc v_emp
+-+ +
| | Field | Type | Null | Key | Default | Extra | |
+-+ +
| | id | int (11) | NO | | 0 | |
| | name | varchar (20) | NO | | NULL |
+-+ +
You can see that the view v_emp we created successfully hides the employee's salary field salary
View Management Delete View
Drop view [if exists] view_name
Modify the view
Alter view v_view_name as select * from tbl_1
Modify the view structure
Alter view v_view_name (col_1,col_2...) As select a,b from tbl_1
This allows you to hide not only the table name but also the field name.
Be careful
Views support query operations best, and have certain restrictions on additions, deletions and modifications, such as views composed of multiple tables, while views created by a single table have default values or allow empty fields in the original table that are not included in the view when inserting data. Only in this way can we ensure the success of the operation.
Do you think you want the above knowledge about mysql views? If you want to know more about it, you can continue to follow our industry information section.
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.