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

How to create a mysql View

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

Share

Shulou(Shulou.com)06/01 Report--

Let's learn how to create a mysql view, I believe you will benefit a lot after reading, the text is not much in the essence, you want to create a mysql view of this short content is what you want.

Creating a view does not save user data in the database, the view is like a window of a table, it provides a query way to specify the way to see the table, and you can only see what you want people to see. In general, the view cannot modify the data, but it can be modified under certain circumstances.

Create a view statement:

Create [or replace] [ALGORITHM= {UNDEFINED | MERGE | TEMPTABLE}] view [(column1,column)] viewName [(column_list)]

As select statement.

Replace means that if the view exists, then replace the view, and if it does not exist, create the view

ALGORITHM indicates the algorithm used:

UNDEFINED default algorithm (undefined), Mysql automatically selects the algorithm to use

MERGE merging algorithm

TEMPTABLE temporary table.

View modification statement:

Alter [ALGORITHM= {UNDEFINED | MERGE | TEMPTABLE}] view viewName [(column_list)]

As select statement.

I personally think that the view is best used to query data, not to modify the data in the view.

Create a view for a single table:

Create or REPLACE VIEW v_test

As SELECT * from yi_sys_function

Create a view for a multi-table association query:

Create or REPLACE view v_test1

As SELECT DISTINCT yma.account,yma.tag,yma.addserival FROM yy_message_account yma,yy_message_log yml

Where yma.tag=yml.tag

After reading this article on how to create a mysql view, many readers will want to know more about it. For more industry information, you can follow our industry information section.

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