我向视图中插入一条记录,语句写好后,命令执行成功,但是打开视图表却没有发现这条记录,而是在基本表中发现插入了这条记录,
各位高手请教,有没有方法,可以在视图中发现这条插入的记录.
各位高手请教,有没有方法,可以在视图中发现这条插入的记录.
解决方案 »
- 求sql语句
- sql查询同一字段的问题
- 请问Sql Server 2005可以为视图的某个列设置索引吗?
- 数据库恢复的问题
- 产品入库时,同时修改库存数量的问题
- SELECT COUNT(*) 计划数, 生产完成数, 完成百分比 from 数据表 group by 项目编号
- 指定的所有者名称'a51118101'不存在,或者您没有使用该名称的权限
- 这种类型的问题的解决办法?
- sqlserver 应用系统(asp.net)发现某些操作很慢.
- 同一天同一用户所购买商品并排排列
- 你还在用GUID作数据库表的主键吗? 对于影响数据库性能的几个方案的实测对比
- SQLSERVER2005中服务无法启动的麻烦问题!请高手指教!
go
create view v
as
select * from tb
goinsert into v values(1,2,3)select * from vdrop view v
drop table tb
insert
into IS_Student
values ('200215129','赵新',20)select *
from IS_Student
as
select Sno,Sname,Sage
from Student
where Sdept='IS';
应该是被这句过滤掉了.
我是觉得插入到IS_Student中,应该默认是Sdept='IS'吧
楼主可把视图语句改为create view [dbo].[IS_Student]
as
select Sno,Sname,Sage
from Student
where isnull(Sdept,'IS')= 'IS ';
试下
where isnull(Sdept,'IS')= 'IS '; 不过这条语句起到什么作用了呢?
可和后面的='IS'边起来,哪位说说:
isnull(Sdept,'IS')= 'IS ';
是什么意思?
where Sdept is null
等价于 where Sdept is null or Sdept='IS'
插入的数据不符合视图的条件
use tempdb;create table dbo.test_tb1
(
bvalue int not null,
cvalue int not null
)
insert into dbo.test_tb1
select 13,7 union all
select 14,9 union all
select 14,10 union all
select 15,8 union all
select 16,6 union all
select 16,14 union all
select 17,13 union all
select 18,17 union all
select 17,10 ;
go
create view vie_test
as
select bvalue,cvalue
from dbo.test_tb1
where bvalue>15 and cvalue>12
with check option
go
insert into vie_test
select 200,200;
select bvalue,cvalue
from vie_test;
/**
bvalue cvalue
----------- -----------
16 14
17 13
18 17
200 200(4 行受影响)
**/
insert into vie_test
select 17,2
/**
消息 550,级别 16,状态 1,第 1 行
试图进行的插入或更新已失败,原因是目标视图或者目标视图所跨越的某一视图指定了 WITH CHECK OPTION,而该操作的一个或多个结果行又不符合 CHECK OPTION 约束。
语句已终止。
**/