Home  >  Article  >  Daily Programming  >  How to modify the view in Mysql data table

How to modify the view in Mysql data table

藏色散人
藏色散人Original
2018-10-26 14:25:186561browse

This article mainly introduces how to modify the view in mysql data table.

The basic knowledge of mysql views has been introduced in detail in the previous article. Here we will give you a brief introduction to the mysql view.

In layman's terms, a view is a virtual table defined by a query composed of SELECT statements, which is composed of data in one or more tables.

Views are just like mysql basic tables. General operations that can be performed on tables can be applied to views, such as create, query, insert, modify, delete operations, etc.

The creation and query of views have been introduced to you in these two articles. Friends in need can refer to them.

[How to create a view in mysql?

How to query the mysql data table view

Let’s continue to introduce the modification operation of mysql view with a simple example ##.

In fact, the modification of the view is equivalent to the modification of the SQL statement.

First we can connect to the mysql database through the cmd command line tool.

Then you can first use the graphic version of Navicat database management tool to view the information of the specified data table my_v1 view more intuitively and conveniently.

How to modify the view in Mysql data table

As shown in the figure above, the my_v1 view contains three fields id, name, and c_id.

Modify the syntax of the view:

alter view +视图名  as + 新的select 语句

The example of modifying the syntax of the view is as follows:

alter view my_v1 as select id,name from stu;

How to modify the view in Mysql data table

Here we use the command line tool to modify the my_v1 view, and re-query the two fields id and name from the stu table.

Finally, we use Navicat to check whether the data of the my_v1 view has been modified.

How to modify the view in Mysql data table

As shown in the picture, only the two fields id and name can be viewed in the my_v1 view, which means that we have successfully modified the view.

Note: Normally, try not to modify the view that has been created to avoid data loss.

This article is an introduction to the modification operations of views in mysql data tables. It is also very simple and easy to understand. I hope it will be helpful to friends in need!

If you want to know more about mysql, you can follow the PHP Chinese website

mysql video tutorial, everyone is welcome to refer to and learn!

The above is the detailed content of How to modify the view in Mysql data table. 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