Home > Database > Mysql Tutorial > body text

What do database views mean and how do MySQL views work?

PHPz
Release: 2023-09-13 11:49:02
forward
1744 people have browsed it

数据库视图是什么意思以及 MySQL 视图如何工作?

#A database view is nothing but a SQL statement stored in a database with an associated name. Views are actually combinations of tables in the form of predefined SQL queries.

A view can contain all rows of the table or select rows from the table. MySQL views can be created from one or more tables, which rely on MySQL queries written to create the view.

A view is a virtual table that allows the user to do the following -

  • Structure data in a way that the user or class of users finds natural or intuitive.
  • Restrict access to data so users can see and (sometimes) modify exactly what they need without having to do more.
  • Summarizes data from various tables that can be used to generate reports.

Basically, views are definitions built on top of other view tables. If the data in the underlying table changes, the same will be reflected in the view. Views can be built on single or multiple tables. MySQL supports database views starting from version 5, and handles queries against views in the following two ways -

  • By creating temporary tables - In this case, MySQL will handle queries based on the view The define statement creates a temporary table and executes the incoming query on this temporary table.
  • By combining queries - In this way, MySQL will combine the incoming query queries to define the view as one query and execute the combined query.

The above is the detailed content of What do database views mean and how do MySQL views work?. For more information, please follow other related articles on the PHP Chinese website!

source:tutorialspoint.com
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