Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the method of creating views in the MySQL database

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article will explain in detail what is the method of creating views in the MySQL database. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.

Syntax:

CREATE VIEW AS

Specifies the name of the view The name must be unique in the database and cannot have the same name as other tables or views.

Specifies the SELECT statement that creates the view, which can be used to query multiple underlying tables or source views

There are the following restrictions on the assignment of SELECT statements in the creation view:

In addition to CREATE VIEW permissions, users also have permissions related to the underlying tables and other views involved in the operation.

SELECT statements cannot refer to system or user variables.

The SELECT statement cannot contain subqueries in the FROM clause.

SELECT statements cannot reference preprocessing statement parameters.

The table or view referenced in the view definition must exist. However, after you create the view, you can delete the table or view that defines the reference. You can use the CHECK TABLE statement to check the view definition for such problems.

ORDER BY statements are allowed in the view definition, but if you select from a specific view that uses its own ORDER BY statement, the ORDER BY in the view definition is ignored.

The TEMPORARY table (temporary table) cannot be referenced in the view definition, and the TEMPORARY view cannot be created.

WITH CHECK OPTION means that when you modify the view, check whether the inserted data meets the conditions set by WHERE.

Create a view named view_menu on the b_menu table, and enter the SQL statement and the execution result as shown below.

Create a view SQL statement:

Create view view_menuas select * from b_menu

View the view SQL statement:

Select * from view_menu

By default, the view created is the same as the fields of the base table, or you can create the view by specifying the name of the view field. (mainly because all the data is used to create the view).

On "what is the method of creating views in the MySQL database" this article is shared here, I hope the above content can be of some help to you, so that you can learn more knowledge, if you think the article is good, please share it out for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report