14. View

1. Introduction The
view is a virtual table whose content is defined by the select query statement. Like a real table, a view also contains rows and columns, and the operations on the view are basically the same as those on the table. The data in the view is dynamically generated when the view is used, and the data in the view is stored in the base table.

2. Features
Readability: Simplifies complex queries, making complex queries easier to understand and use.
Security: The view can hide some sensitive information, and can restrict permissions to the row or column level.
Reusability: The view is the encapsulation of complex query statements and the reconstruction of the database, which will not affect the operation of the program.

3. Use

#创建视图
create view viewName as select...;

#使用视图
select *  from viewName;

#修改视图
alter view viewName as select...;

#查看视图创建语句
show create view viewName;

#查看有哪些视图
show table status where comment='view';

#删除视图
drop view viewName;

As shown in the figure below, create a view to query all user information in the user table, and then query the content of the view.
Insert picture description here

Guess you like

Origin blog.csdn.net/Jgx1214/article/details/107496181