MySQL视图
MySQL视图
创建或修改视图
创建视图
CREATE [OR REPLACE] [ALGORITHM = {UNIFINED | MERGE | TEMPLATE}]
VIEW view_name [(column_list)]
AS select_statement
[WITH [CASCADED | LOCAL] CHECK OPTION]
修改视图
ALTER [ALGORITHM = {UNIFINED | MERGE | TEMPLATE}]
VIEW view_name [(column_list)]\
AS select_statement
[WITH [CASCADED | LOCAL] CHECK OPTION]
WITH [CASCADED | LOCAL] CHECK OPTION
决定了是否允许更新数据使记录不再满足视图的条件。
- LOCAL:只要满足本视图的条件就可以更新。
- CASDED:必须满足所有针对该视图的所有视图的条件才可以更新。
查看视图
show tables;
可以查看表和视图
show table status;
既可以查看表也可以查看视图信息。
删除视图
DROP VIEW [IF EXISTS] view_name [, view_name] ...[RESTRICT | CASCADE];