大家不知道merge 语句吗??还是太简单了?
解决方案 »
- 100 分 求一sql语句
- oracle的ORA-24812 问题谁遇到过,高分求解决办法。
- 求大侠相助阿!急。。
- Oracle SQL Plus 登录界面显示乱码,进如何,系统提示和反馈系统也是乱码,如何解决
- 谁用过form builder能讲一讲吗?
- ▲▲▲请问Oracle 9i应如何安装???▲▲▲
- 菜鸟请教用select返回前10条数据的写法
- 关于oracle 9i死寂的问题
- Oracle 9i JDeveloper如何安装?
- 使用impdp导入时报错,ora39082报了好多个,导入数据库结束后发现一个表都没有导入进来,这个要怎么解决,请大神告知
- Oracle 时间问题,请指教
- oracle sql语句问题
using test1 t2
on (t1.id = t2.id)
when matched then update set t1.amount = t2.amount, t1.id = t2.id
when not matched then insert (t1.id,t1.amount) values(t2.id,t2.amount)ORA-00904: "T1"."ID": 无效的标识符把set t1.id = t2.id 换成别的列就行了,注意不能是on(...)子句里的列merge into test2 t1
using test1 t2
on (t1.id = t2.id)
when matched then update set t1.amount = t2.amount, t1.code = t2.code
when not matched then insert (t1.id,t1.amount) values(t2.id,t2.amount)Done
merge into emp01 as e1
using emp02 e2
on(e1.empno=e2.empno)
when matched then
update set e1.ename=e2.ename
when not matched then
insert values(e2.ename);
依然不好使,还是老毛病!!
merge into emp01 as e1
using emp02 e2
on(e1.empno=e2.empno)
when matched then
update set e1.ename=e2.ename
when not matched then
insert(e1.ename)
values(e2.ename)
哪位大虾告诉我为什么,应为我看到的所有资料里merge语句都支持别名!!
merge into emp01 as e1
using emp02 e2
on(e1.empno=e2.empno)
when matched then
update set e1.ename=e2.ename
when not matched then
insert(e1.ename)
values(e2.ename)这里判断如果e1.empno=e2.empno的话,就更新e1的纪录,这是e1的empno和e2的empno本来是一样的,所以就不要更新,而not matched得时候,就是e1里面不存在e1.empno=e2.empno这条纪录,这时插入的时候就必须要插入e1.empno,这样才能保证插入后e1里存在e1.empno=e2.empno这条纪录
我用的是oracle92
merge into emp01 as e1应为(没有as的)
merge into emp01 e1