Home >Database >Mysql Tutorial >Detailed explanation of view instances in Mysql
View in mysql, the view 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.
View:
The view in mysql has many similarities with the table. The view also consists of several fields and several records. Composed, 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, DeleteView
If a view is no longer used, you can use the drop view statement to delete the view. The syntax format is as follows.drop view 视图名
3. The role of views
·Making operations simple·Avoiding data redundancy
·Enhancing data Security
·Improve the logical independence of data
The above is the detailed content of Detailed explanation of view instances in Mysql. For more information, please follow other related articles on the PHP Chinese website!