update (select tb_spec.attribute2,tb_spec.attribute1
from tb_spec join tb_storage on tb_spec.spec_id=tb_storage.spec_id
where tb_storage.storage_id=47445)
set attribute2='张飞',attribute1='韩国'
执行的出错信息是:无法修改与非键值保存表对应的列
其中tb_spec和tb_storage都是表,不是视图.
他们都有自己的主键,tb_spec的是spec_id,tb_storage的是storage_id.
from tb_spec join tb_storage on tb_spec.spec_id=tb_storage.spec_id
where tb_storage.storage_id=47445)
set attribute2='张飞',attribute1='韩国'
执行的出错信息是:无法修改与非键值保存表对应的列
其中tb_spec和tb_storage都是表,不是视图.
他们都有自己的主键,tb_spec的是spec_id,tb_storage的是storage_id.
解决方案 »
- 身份证号验证程序
- 关于sqlldr个人觉得相当复杂的一个问题,求解
- 用包发送查询 时间格式出错。那位大虾帮一下忙?检查一下错误在那里?
- 数据库关掉连接出错
- 如何利用存储过程动态创建表?
- 看看怎么处理?
- oracle中日期的问题!!!
- 客户机怎样用一个数据库别名分别连接两个服务器(ORACLE OPS)?
- 当选中几个checkbox,进行and检索或者or检索,这个sql语句怎么写??请大家帮忙,多谢了,一定加分。。。!!!!
- sqlload 可以导入非指定文件嘛?
- 如果在oracle 中显示sqlserver的数据库?就如同在sqlserver中建与oracle的链接一样的功能
- 高分求助:一个SQL文的写法,谢谢!
update tb_spec a
set attribute2='张飞',attribute1='韩国'
where exists
(select 1 from tb_storage where a.spec_id=b.spec_id and b.storage_id=47445)
-----------------------------
update 可以更新视图的,但前提是关联到的从表的字段必须有主键约束
http://community.csdn.net/Expert/topic/4158/4158385.xml?temp=.8785364
select * from tb_spec where spec_id=(select tb_spec.spec_id from tb_spec join tb_storage
on tb_spec.spec_id=tb_storage.spec_id
where tb_storage.storage_id='34072')
可以运行了.
但我想知道题目那么写的错误原因是什么?