Home > Database > Mysql Tutorial > body text

Detailed explanation of view instances in Mysql

怪我咯
Release: 2017-04-30 10:13:14
Original
1220 people have browsed it

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语句
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, 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 视图名
Copy after login

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!

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!