Introduction to database SQL Creation views and views

Source: Internet
Author: User
Tags mysql tutorial mysql view

What is a MySQL tutorial view

The English name of the view is the view is a virtual existence of the table, for the use of views of users, is basically transparent, and is a MySQL view in the database tutorial is not exist, the relevant data from the table used in the query, and is dynamically generated.

Okay, let's take a look at the database SQL view Creation

Create a view we use the permission for Creation view, and for queries and select permissions, if you use Create or replace or alert to modify the viewing chart, we also need drop permissions.

Here's a look at the syntax for view creation

create [or replace] [algorithm ={undefined |merge |temptable}]

View view_name[(column_list})

As SelectList

[With [caseaded | loca] Check OPTION]

OK, let's look at a view creation instance

->mysql>create or Replace view st_list_v as select S.st.finame from STT as s,add as a where s.addressid= As.addressi D

Query OK, 0 rows Affected (0.00 sec);

Note: The MySQL view definition has some limitations, such as, from the keyword can not be followed by a subquery, which is different from the MSSQL database, if the view migration, you may have to make some changes,

The following types of views are not updatable when the database view is updatable and the definition of the query in the view is related.

There are keyword SQL statements: Sum,min,max,count,distinct,group by Having,union,unionall mainly refers to aggregate functions

The following view is not updatable.

Mysql->create or Replace view palsum as select Tt,sum (ID) from pay group by STT;

Query OK, 0 rows Affected (0.00 sec);

Well, this database view tutorial is mainly about the creation of the MySQL view and considerations for the view.

The original site reproduced the source: http://www.111cn.nethttp://www.111cn.net/database/database.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.