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 -> ; 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