Mysql view operations and stored procedures

Source: Internet
Author: User
Tags mysql view

1. the MySQL view operation is only supported by the new version of the database. The advantage of the view operation is that it can simplify the query of the database. In particular, we can create a view for some frequently queried data tables first, you can directly query this view when querying this type of data table. This can also improve the query efficiency.
Another benefit of a view is that if you change the field or value of the base data table, the view chart will change accordingly, so we don't have to worry about it, when changing the field value of the base data, the view data is not synchronized.
For example, create a view and query it through the view.
Create view v3 as SELECT B. sid, B. grade, c. cname
FROM grade B, course c
WHERE B. cid = c. cid

Then query a piece of data from the View
Select sid, grade, cname from v3 where sid = 200410001

In this way, do not query a piece of data again using a joint query.

2. Stored Procedures: this operation can make database operations more concise, and the reusability of data operations is also better reflected. stored procedures can implement multi-Table operations, he also allows passing in parameters. For specific operations, refer to the manual.

These two SQL features can be flexibly used in our actual development, and may change some unreasonable database operations in the past, making the program we write more reasonable, easy to maintain.

Related Article

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.