赞
踩
- -- 创建视图
- CREATE OR REPLACE VIEW stu_1 AS SELECT id,username from ev_users WHERE id<=10
- -- 展示视图创建的SQL
- SHOW CREATE VIEW stu_1
- -- 查看视图
- SELECT * FROM stu_1
- -- 修改视图
- ALTER VIEW stu_1 AS SELECT id from ev_users WHERE id<=10
-
- CREATE OR REPLACE VIEW stu_1 AS SELECT id,username from ev_users WHERE id<=10
- -- 删除视图
- DROP VIEW IF EXISTS stu_1
CREATE OR REPLACE VIEW stu_1 AS SELECT id,username from ev_users WHERE id<=10 WITH CASCADED CHECK OPTION
WITH CASCADED CHECK OPTION:检查新增、修改、删除操作是否符合视图定义时条件
casecaded会检查本条及关联本条sql所关联的所有上级视图
local只检查本级的要求,如果他没写,则不会强制检查上级视图
视图内与表内要是1对1的形式,1对多则无法更新数据
视图可以保证数据原结构的安全性,用户看到可以给用户看的数据
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。