在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]