create table stue
(
id int auto_increment primary key comment ' 客户编号',
name varchar(20) comment '客户名称',
mima varchar(100) comment'客户密码 ' ,
phonr varchar(20) comment '客户电话',
xb char(2) comment '选则男,女',
y_x varchar(20) comment '邮箱 ' ,
d_z varchar(20) comment'地址'
)comment'记录客户基本信息';
insert into stue (id, name, mima, phonr, xb, y_x, d_z) values (1,'小草','123451','183953...','男','1273@qq','安徽'),
(2,'小理','123452','18783...','男','1253@qq','安徽'),
(3,'小马','123453','18353...','女','1238@qq','安徽'),
(4,'小了','123454','18334...','男','1223@qq','安徽'),
(5,'小个','123455','18327...','女','1283@qq','安徽'),
(6,'小逼','123456','18369...','女','12309@qq','安徽'),
(7,'小了就','123454','18334...','男','12523@qq','安徽'),
(8,'小个好','123455','18327...','女','12873@qq','安徽'),
(9,'小逼个','123456','18369...','女','12396@qq','安徽'),
(10,'小了是','123454','18334...','男','12423@qq','安徽'),
(11,'小个女','123455','18327...','女','12283@qq','安徽');
-- local
create or replace view stu_v_7 as select id, name from stue where id <= 13;
insert into stu_v_7 values (5, 'Tom');-- 视图插入成功 符合条件 id <= 13,数据存入stue基表当中
insert into stu_v_7 values (16, 'Tob1'); -- 视图中插入失败,插入语句不符合视图stu_v-7的select语句的id <=13,但是基表stue中数据保存成功)
create or replace view stu_v_8 as select id, name from stu_v_7 where id >= 7 with local check option ;-- 基于stu_v_7的条件id<=13的基础上创建新的视图stu_v_8,且stu_v_8的条件是id>=7
insert into stu_v_8 values (8, 'sdds'); -- 视图中插入成功,插入语句符合视图stu_v_8的select语句id >=7,也符合stu_v_8的基表stu_v_7 的id <= 13)
stu_v_8
stu_v_7