ORA-01407: cannot update错误
来源:互联网 发布:淘宝图片如何搬家 编辑:程序博客网 时间:2024/06/06 02:45
前提:有两个表
1、学生表:student(id,name,t_id); t_id是非空的
2、教师表:teacher(id,name)
需求:把学生表中t_id都更新成teacher表的name
sql语句:
update student t
set t.t_id=(select s.name from teacher s where s.id=t.t_id)
报ORA-01407错。
解决方法:
update student t
set t.t_id=(select s.name from teacher s where s.id=t.t_id)
where exists(select 1 from teacher s where s.id=t.t_id)说明:
如果不想报ORA-01407这个错误,有两种办法
1、student,teacher两张表的记录要完全一样
2、要update的表记录要比对照表的记录少
不然update的时候在最后就要加一个 where exists 语句,这个和merge的用法很像,当然这只是一个特例,对于没有指定not null的列,普通的update是完全没有问题的
参考链接:
http://blog.sina.com.cn/s/blog_4a5eb9980101bt8x.html
阅读全文
0 0
- ORA-01407: cannot update错误
- ORA-01407: cannot update to null 错误解决
- UPDATE子查询的ORA-1779错误
- wince 系统error C2471: cannot update program database 错误解决办法。
- GreenDao使用错误Cannot update entity without key
- ORA-01407 错误解决
- ORA-16038: log 3 sequence# 6 cannot be archived错误
- ORA-04092: cannot COMMIT in a trigger错误的解决
- 错误 ORA-01102: cannot mount database in EXCLUSIVE mode
- oracle 启动时出现ORA-01157: cannot identify/lock data和ORA-01110: data file 错误
- 对存在如两张表连接的视图进行UPDATE时产生ORA-1779错误
- MySQL外键 Cannot add or update a child row错误的实例解释
- MySQL外键 Cannot add or update a child row错误的实例解释
- MySQL外键 Cannot add or update a child row错误的实例解释
- MySQL错误号1451-Cannot delete or update a parent row: a foreign key constraint fails
- Maven项目无法产生Maven Dependencies且无法update project报cannot nest错误
- MySQL外键 Cannot add or update a child row错误的实例解释
- Maven项目无法产生Maven Dependencies且无法update project报cannot nest错误
- 论程序开发的战略与战术
- C语言实现扫雷游戏
- 关于行为树插件Behavior Designer的学习(四)_Decorators装饰任务
- Python 字符串常用方法
- Android 仿今日头条视频播放器实现(不使用节操哟)
- ORA-01407: cannot update错误
- sublime text package安装后不出来
- 管理和管理人员的开发
- Docker之WARNING: IPv4 forwarding is disabled. Networking will not work.
- Spring学习笔记
- 神坑
- 扫盲系列之字符集编码常识
- Python 错误:AttributeError: 'module' object has no attribute
- EasyUI DataGrid 弹框编辑反选