【问题标题】:Oracle sync data from two tables on string columnOracle同步字符串列上两个表的数据
【发布时间】:2016-07-07 12:58:38
【问题描述】:

我有两张地址表,例如:A1 与 Street、City、Building 和另一个 A2 与这三列和其他。这些表的结构不同,A1 没有主键,我无法添加主键,因为不在我的数据库中。

所以,我想插入 A1 中不在 A2 中的所有数据,比较 STREET、CITY 和 BUILDING 列。

我该怎么做,因为在 oracle 中字符串列的比较非常慢。我注意到我有很多数据。 我可以使用批处理和批量插入以某种方式做到这一点吗?

谢谢

【问题讨论】:

  • 在 A2 中插入数据?如果是,那么其他列的值应该是什么?空?
  • 是的,我想将数据插入A2
  • 不理解某些东西 - 如果问题是 Oracle 中的字符串比较非常慢,那么 batch 和 bulkinsert 会有什么帮助?它们如何加快字符串比较?
  • 如果我并行做一些事情,那是因为我要求批处理
  • 如果您没有索引,那么可能会进行全表扫描。解释计划显示什么?如果您在表上没有正确的键/索引,那么您就无法期望效率。

标签: oracle join insert bulkinsert


【解决方案1】:

更新:尝试合并,它基本上做同样的事情。另请查看是否可以在连接条件下为列创建索引,这将提高性能。

MERGE INTO A2
    USING A1
    ON (a1.street=a2.street and a1.city=a2.city and a1.building=a2.building)
  WHEN NOT MATCHED THEN
    INSERT (Street,City,Building)
    VALUES (a1.Street,a1.City,a1.Building);

上一个:

 insert into A2 (Street,City,Building)
 select a1.Street,a1.City,a1.Building 
 from a1 left join a2 
 on a1.street=a2.street and a1.city=a2.city and a1.building=a2.building
 where a2.street is null and a2.city is null and a2.building is null

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-04-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-13
    • 2013-03-02
    相关资源
    最近更新 更多