Home > Database > Mysql Tutorial > body text

What are views in Mysql? Detailed explanation of views in Mysql

零下一度
Release: 2017-04-26 14:14:52
Original
1489 people have browsed it

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语句
Copy after login

Example:


create view t (id,name,age,sex) as
select id,name,age,sex from teacher;
Copy after login

·View view structure (view view information, similar to viewing table information )


desc t;
Copy after login

#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 视图名
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!