在mysql中操作视图的方法:1.使用CREATE语句创建视图;2.使用ALTER语句修改视图;3.使用DROP VIEW语句删除视图;
具体方法如下:
1.创建视图
CREATE [OR REPLACE] [ALGORITHM = {UNDEFINED | MERGE | TEMPTABLE}]
VIEW view_name [(column_list)]
AS select_statement
[WITH [CASCADED | LOCAL] CHECK OPTION]
参数:
LOCAL:满足本视图的条件即可更新。
CASCADED:默认值,必须满足所有针对该视图所有条件才可以更新。
2.修改视图
ALTER [ALGORITHM = {UNDEFINED | MERGE | TEMPTABLE}]
VIEW view_name [(column_list)]
AS select_statement
[WITH [CASCADED | LOCAL] CHECK OPTION]
3.删除视图
DROP VIEW [IF EXISTS] view_name [, view_name] ...[RESTRICT | CASCADE]