create or replace view stu_viewB as select * from student where home_address = '上海' with check option; 创建了视图 ###### 问题遇到的现象和发生背景
insert into stu_viewb values(201710100001,'张小明',123456,'男',102,2,'2000-01-01',11000000003,'昆明'); 向视图中插入数据,###### 用代码块功能插入代码,请勿粘贴截图
Column count doesn't match value count at row 1 运行结果 。报错###### 运行结果及报错内容
是哪里出问题了,有解答吗
回答:你把student表的结构给一下,有可能是数据类型或者字段数目和提供的 values 对不上
----先确认一下 insert 语句 values 中的字段个数是否够,不够补齐字段。或者改写 insert into stu_viewb (a,b,c,d) values(1,2,3,4) 指定字段格式。
确认第一个问题是缺少第10个字段造成的。
insert into stu_viewB values(201710100001, '小明', 123456, '男', 102, 2, '2000-01-01', 11000000003, '昆明')
> 1136 - Column count doesn't match value count at row 1
insert into stu_viewB values(201710100002, '小明', 123456, '男', 102, 2, '2000-01-01', 11000000003, '上海', 'describe')
> Affected rows: 1
> 时间: 0.005s
第二个问题是因为where home_address = '上海' with check option 只能插入上海的记录。