首页 文章

Oracle 10g - 插入临时表 - 记录select和insert之间的计数不匹配

提问于
浏览
1

我们正在尝试从select查询中插入记录到临时表中,临时表中缺少一些记录 . select语句有多个连接和联合所有它很复杂的查询 . 简单来说,脚本包含2部分第一部分插入到临时表第二部分选择具有多个连接的查询,内联子查询,联合和按类和条件分组

例如 . 如果我们单独执行select语句,它会返回一些计数,例如=> 60000插入临时表后,在临时表中计数大约是42000,为什么区别?

Also, we have some other observation. It only happens in its 2nd execution and not its first run. Hope there might be some cache problem


我们得到了一个解决方案,一旦我们清除了会话缓存(checkpoint,flush shared_pool和buffer_cache),它就可以正常运行Re_Run .

但是,我们不知道这个解决方案好吗?以及如何清除缓存在后台运行和插入失败 . 如果是真的,配置设置有误,我猜 .

代码看起来像sql = "insert in to temptable select x,y,z,.... from xxx,abc,pqr..where...."; (逻辑但非真实是非常复杂的700行,有多个连接,内联子查询,分组等)stmt = conn.createStatement(); rCount = stmt.executeUpdate(sql); Actual issue is rCount = xxxx = Count(temptable) < count(select x,y,z,.... from xxx,abc,pqr..where....) 为什么会出现这种差异?在select中填充但未插入临时表的某些记录

谁能解释一下?

提前感谢您的努力和帮助 .

湿婆 .

2 回答

  • 0

    在我看来,连接应该是Full Outer Join,因此两个表中的记录虽然不匹配,但会出现在结果中 . 请检查:http://en.wikipedia.org/wiki/Join_%28SQL%29#Full_outer_join

  • 0

    We got a solution, once we clear session cache (checkpoint, flush shared_pool and buffer_cache) it works fine for Re_Run. 但是,我们不是这个解决方案好吗?以及如何清除缓存在后台运行和插入失败 . 如果是真的,配置设置有误,我猜 .

    谁能解释一下?

相关问题