Mysql -- view,

Source: Internet
Author: User

Mysql -- view,
1. view features

When a view comes from multiple basic tables, data cannot be added or deleted.

2. Create a view

Although a view can be viewed as a virtual table, it does not physically exist, that is, the database management system does not have a dedicated location to store data for the view. According to the view concept, we can find that its data comes from the query statement. Therefore, the view creation syntax is:

  • Syntax:

  • Example:

Create various views

(1) encapsulate the view of query statements Using Aggregate functions (SUM, MIN, MAX, COUNT, etc.

The student table is as follows:

(2) encapsulates the view for implementing the order by query statement.

3. view 1. view with show tables statements

2. DESCRIBE | DESC view View Design Information

4. delete a view
  • Syntax:

  • Example:

5. Modify VIEW 1. create or replace view statement modify VIEW
  • Syntax:

  • Example:

2. ALTER statement modification View
  • Syntax:

  • Example:

6. Use the view to modify basic table 1. Search (query) data

Querying data through a view is exactly the same as querying through a table, but querying through a view is safer, simpler, and easier to use than querying a table. In specific implementation, you only need to replace the table name with the view name.

  • Syntax:

  • Example:

2. operate basic table data using views

You can not only query data in a view, but also update (add, delete, and update) the view. Because the view is a "virtual table", the index updates the View data. In fact, the basic table data is updated.

When updating View data, pay attention to the following two points:

(1) adding, deleting, and updating View data directly affects basic tables.

(2) When a view comes from multiple basic tables, data cannot be added or deleted.

  • Add data operation

After execution:

  • Delete data

 

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.