Oracle-仅在表中插入具有不存在的列值的行

发布于 2025-02-09 19:04:56 字数 423 浏览 2 评论 0原文

我在Oracle中有两个相同的表(按结构相同)-table_temp和table_total。

我需要基于以下条件从table_temp中插入table_total行 - 仅在table_total中不存在的player_id值的行应插入table_total中。

Table_temp有1,12英里的记录。

我尝试了许多解决方案,但是花费了太长时间的处理,所以我停止执行。这是我的最后一次尝试,我在7个小时后停了下来:

INSERT INTO table_total
SELECT * 
FROM table_temp 
WHERE table_temp.player_id NOT IN (SELECT player_id FROM table_total)

什么是最佳/最快的解决方案?索引列是不可接受的解决方案...

I have two identical tables in Oracle (identical by structure) - table_temp and table_total.

I need to insert in table_total rows from table_temp based on following condition - only rows from table_temp with PLAYER_ID value which doesn't exist in table_total should be inserted in table_total.

Table_temp has 112 milions of records.

I tried many solutions but it took too long time to process so I stopped execution. This is my last try I stopped after 7 hours:

INSERT INTO table_total
SELECT * 
FROM table_temp 
WHERE table_temp.player_id NOT IN (SELECT player_id FROM table_total)

What is best/fastest solution for this? Indexing column is not acceptable solution...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

生寂 2025-02-16 19:04:56

使用合并语句:

MERGE INTO table_total dst
USING table_temp src
ON (src.player_id = dst.player_id)
WHEN NOT MATCHED THEN
  INSERT (player_id, col1, col2, col3)
  VALUES (scr.player_id, src.col1, src.col2, src.col3);

Use a MERGE statement:

MERGE INTO table_total dst
USING table_temp src
ON (src.player_id = dst.player_id)
WHEN NOT MATCHED THEN
  INSERT (player_id, col1, col2, col3)
  VALUES (scr.player_id, src.col1, src.col2, src.col3);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文