PHP View Operations

Source: Internet
Author: User

First, the basic description of the view          View is a virtual table. Unlike a table that contains data, a view contains only queries that retrieve data dynamically when used.         Use of views requires MySQL5 and later version support.         Here are some common applications for views:        Reusing SQL statements;        simplifying complex SQL operations;        Use the components of a table instead of the entire table;        Protecting data;        Changing data formats and representations;        After the view is created, you can use them in the same way as the tables.         But for a large number of complex or nested views, performance can be degraded very badly. Therefore, adequate testing should be done before the appropriate application is deployed. Ii. rules and restrictions for using views         The view must be uniquely named (cannot give the view the same name as another view or table), as with the table;        There is no limit to the number of views that can be created;         in order to create a view, you must have sufficient access rights;        View can be nested;        ORDER BY ;        views cannot be indexed, or have associated triggers or default values;        views can be used with tables; Use view to create view name  [ (column name 1, column Name 2,...)] As SQL statement 1, create view         Create  view view_name        as      &N Bsp SELECT statement &NBsp       Example:        mysql> Create or replace view v_pic_url      &N Bsp     as            select           -&GT ;     id,url            → from v9_picture          &NBS P Where catid=17; 2, view statements creating views         SHOW CREATE view viewname;        Examples :        mysql> show CREATE view v_pic_url; 3, modify or update view     alter view  view name  [ (column name 1, column Name 2,...)] As SQL statements        You can drop the view first, and then use the CREATE statement for creating;        You can also use the Create OR REPLACE view statement directly; Nbsp;4, delete view         DROP view viewname;        example:        MySQL > Drop View v_pic_url;  Four, update view data         Typically, views are updatable (that is, you can use INSERT, UPDATE, and delete for them). Updating a view will be moreThe new base table. If you add or delete rows to a view, you are actually adding or deleting rows to their base tables.         However, not all views are updatable. If you have the following actions in the view definition, you cannot update the view:        grouping (using group by and having);        Junction;    &N Bsp   subquery;        and;        Focus functions;        distinct;  &nbs P     Export (computed) columns;        Generally, the view should be used for retrieval and not for updates.   

PHP View actions

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.