MySQL (ii)

Source: Internet
Author: User

View

A view is a virtual table (not a real one), which is essentially "getting a dynamic dataset from an SQL statement and naming it", which allows the user to get a result set using only "name" and use it as a table.

Temporary table Search

Select    *from    (        Select            nid,            NAME        from            tb1        WHERE            nid > 2    ) as Awhere    A. NAME > ' Alex ';

1. Create a View

--Format: CREATE VIEW name  as SQL statement CREATE VIEW v1 as Selet nid,     namefrom    awhere    nid > 4

2. Delete View

--Format: Drop View Name Drop View V1

3. Modify the View

--format: ALTER VIEW name as SQL statement alter VIEW v1 asselet A.nid,    B. namefrom    Aleft Join B on a.id = B.nidleft Join C on a.ID = C.nidwhere    a.id > 2AND C.nid < 5

4. Using views

When you use a view, you manipulate it as a table, and because the view is a virtual table, you cannot use it to create, update, and delete real tables, only for queries.

SELECT * FROM v1
Trigger

Before and after an "Add/delete/change" operation on a table if you want to trigger the behavior of a feature, you can use a trigger that customizes the behavior of the user before and after the "Add/delete/change" row of the table.

MySQL (ii)

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.