create view 视图名
as
查询语句;select * from 视图名 where 查询条件;
select * from v_ysq
1、方式一:
语法:create or replace view 视图名 as 查询语句;
例题:
CREATE OR REPLACE VIEW v_mwy AS SELECT AVG(age),tid FROM emp GROUP BY tid;
2、方式二:
语法:alter view 视图名 as 查询语句;
例题: ALTER VIEW v_mwy AS SELECT * FROM emp;
语法:drop view 视图名,视图名,...;
例题:DROP VIEW v_mwy ,v_m1,v_m2;
语法:DESC 视图名;
SHOW CREATE VIEW v_ysq;
CREATE OR REPLACE VIEW myv1 AS SELECT last_name,email,salary*12*(1+IFNULL(commission_pct,0)) "annual salary" FROM employees; CREATE OR REPLACE VIEW myv1 AS SELECT last_name,email FROM employees; #1.插入 INSERT INTO myv1 VALUES('张三','zf@qq.com') #2.修改 UPDATE myv1 SET last_name = '张三' WHERE last_name='李四'; #3.删除 DELETE FROM myv1 WHERE last_name = '张三';