【发布时间】:2015-04-08 12:30:04
【问题描述】:
MERGE
INTO cars2
USING abc
ON (
cars2.vehicleid = abc.vehicleid)
WHEN NOT matched THEN
INSERT
(
cars2.vehicleid,
cars2.brand,
cars2.model,
cars2.vehicle_type,
cars2.fuel_type,
cars2.transmission_type,
cars2.gearbox,
cars2.drive_type,
cars2.vehicle_number,
cars2.price
)
>>VALUES
(
abc.vehicleid,
abc.brand,
abc.model,
abc.vehicle_type,
abc.fuel_type,
abc.transmission_type,
abc.gearbox,
abc.drive_type,
abc.vehicle_number,
abc.price
)
WHERE abc.vehicleid < 1000;
当我执行上述操作时,它说插入了 0 行。但实际上它应该插入两行。有人可以帮我解决这个问题吗?
select VEHICLEID from abc where vehicleid > 1000;
输出:-
VEHICLEID
9977
9978
【问题讨论】:
-
在查询中您使用的是
>,但在合并中您使用的是<。哪一个是正确的? -
两个不同的过滤谓词,两个不同的结果集。那你有什么问题?
-
从 abc 中选择 VEHICLEID,其中车辆 ID > 1000;仅供参考,我已经证明我在 abc 表中有两个条目,车辆 ID 大于 1000。我在 MERGE 语句中使用“WHEN NOT MATCHED”,所以我使用了“where abc.vehicleid
-
添加评论,我是 Oracle 的新手。我想知道“WHEN NOT MATCHED”实际上是什么意思?因为当我使用“where abc.vehicleid > 1000;”时在 MERGE 语句中正确插入两行/
标签: sql oracle oracle11g merge oracle10g