VIEWS are virtual tables that do not store any data of its own. but display data stored in other tables. In other words, VIEWS are nothing but some SQL Queries. A view can contain all or a few rows from a table. A MySQL view can show data from one table or many tables.
In MySQL, the View is a virtual table created by a query by joining one or more tables.
the main difference between views and Tabel that the views are definitions built on top of other tables. If any changes occur in the main table, the same changes reflected in the View table also.
view_name: It specifies the name of the VIEW that you want to create in MySQL database.
OR REPLACE: It is optional. It is used when a VIEW already exists. If you do not specify this clause and the VIEW already exists, the CREATE VIEW statement will return an error.
How to create views in mysql?
How to show created view
Note :It is essential to know that a view does not store the data physically. When we execute the SELECT statement for the view, MySQL uses the query specified in the view's definition and produces the output.
View Example :-
Example
products table:
products view table:
MySQL Update VIEW :
ALTER VIEW statement is used to modify or update the already created VIEW
example
Drop VIEW
Create View with JOIN Clause
Create View with inner JOIN Clause
Trending Tutorials