Home  >  Article  >  Database  >  MySQL view application modification view

MySQL view application modification view

黄舟
黄舟Original
2017-05-07 16:39:543328browse

MySQL View Application Modification View

In order to improve work efficiency, views that do not meet the conditions can be changed through modification. To implement the examples in this chapter, we first need to create the data table, and then create the view. Don’t worry, we will introduce it in detail below! ~

So before we start this chapter, let’s review the content in the previous article "MySQL View Application - Creating Views". We introduced in detail how to create MySQL views, how to verify user identity through views, friends who are unclear can review it. Today our article mainly introduces to you the modification of MySQL views. Let’s take a look at it together!

Technical points

Modifying the view in MySQL can be achieved through the alter view statement. The specific instructions for using the alter view statement are as follows:

alter view [algorithm={merge | temptable | undefined} ]view view_name[(column_list)] as select_statement[with [cascaded | local] check option]

algorithm: This parameter has been introduced in creating the view and will not be described again here.

view_name: The name of the view.

select_statement: SQL statement is used to limit the view.

mysql modification view implementation process

(1) First, the data table user should be created in the database. This table can also be created in phpMyAdmin , our database has been created here, so we won’t repeat it here~

(2) Create the view userinfo. The code is as follows:

create view userinfo as select * from user

(3) Query view userinfo. The code is as follows:

select * from userinfo

Looking at the execution results, you can find that all fields in the user table are listed one by one.

(4) Let’s start modifying the view, requiring that only the username field be listed after modification. The code is as follows:

alter view userinfo as select * from user

(5) Query the view userinfo again. From the results, you can find that only one field, username, is listed, indicating that the view modification is successful.

The results of the above implementation process displayed in the "Command Prompt" are as follows:

MySQL view application modification view

Then here is the content about modifying the MySQL view It’s over, isn’t it very simple? I believe that everyone can master it in detail. In the next article, we will continue to introduce the application of MySQL views. For details, please read "Application Views of MySQL Views" 》!

【Recommended related tutorials】

1.【MYSQL online free video tutorial

2. Recommended related video courses : "Backend.com MySQL Database Video Tutorial"

The above is the detailed content of MySQL view application modification view. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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