Views in mysql have many similarities with tables. Views are also composed of several fields and several records. Views can also be used as the data source of select statements
View:
The view in mysql has many similarities with the table. The view is also composed of several fields and several records. The view can also be used as the data source of the select statement.
What is saved in the view is only a select statement, which saves the definition of the view and does not save the real data. The source data in the view comes from database tables. The database table is called a basic table or base table, and the view is called a virtual table.
1. Create a view
The syntax format for creating a view is as follows.
create view 视图名 [ (视图字段列表) ] as select语句
Example:
create view t (id,name,age,sex) as select id,name,age,sex from teacher;
·View view structure (view view information, similar to viewing table information )
desc t;
#2. Delete a view
If a view is no longer used, you can use drop The view statement deletes the view. The syntax format is as follows.
drop view 视图名
3. The role of views
·Making operations simple
·Avoid Data redundancy
·Enhance data security
·Improve the logical independence of data
The above is the detailed content of What are views in Mysql? Detailed explanation of views in Mysql. For more information, please follow other related articles on the PHP Chinese website!