各位专家,我有两个表,一个人口表,一个地址表
人口表(RKB)有五个主要字段,RYID(人员编号),RYXM(人员姓名),RYZZBH(人员住址编号),XQMC(小区名称),RYZZXZ(人员住址详址)
地址表(DZB)有三个主要字段,ZZBH(住址编号),(XQMC)小区名称,ZZXZ(住址详址)
现在人口表中有900多万条记录,住址表中有400多万条记录,现在我想把住址表的信息通过住址编号与人口表关联,更新到人口表中,但由于数据量太大,我用update语句更新,机器像死了一样,半天没有反映,请问各位专家,有什么好的招术,谢谢!

解决方案 »

  1.   

    不知道你是用JOIN ON 还是where a.x=b.y连接两个表的?
    用where a.x=b.y比join on 好,特别是连接的字段有索引的情况下!!还有就是创建簇CREATE CLUSTER 
    簇创建于有公共列的两个或多个表的集合
      

  2.   

    *^_^*救星来了.可以看看我的BLOG
    ThinkingInGirls.cnblogs.com
    ---------------------------------
    Oracle合并纪录.如果纪录存在Todo...如果纪录不存在则插入. 
    merge into linyang
    using (select * from usr) u
    on (u.usrid = linyang.usrid)
    when matched then
      update set linyang.name = '7995'
    when not matched then
      insert
      values
        (u.usrid,
         u.name,
         u.password,
         u.title,
         u.defgrp,
         u.acdgroup,
         u.islimited,
         u.purview,
         u.skill,
         u.verifgroup); 
    ---------------------------------------
    语法大致如下.有错的地方请大家指明,谢谢
    merge into 表1
    using (select 字段 from 表2) 起别名
    on (表1的字段=表2的字段)
    when matched then
    要执行的操作.例如:update set 表1的字段=值
    when not matched then
    要执行的操作.例如:insert values(表1的字段);
    ---------------------------------------
    MERGE INTO [your table-name] [rename your table here] USING ( [write your query here] )[rename your query-sql and using just like a table] ON ([conditional expression here] AND [...]...) WHEN MATHED THEN [here you can execute some update sql or something else ] WHEN NOT MATHED THEN [execute something else here ! ] 相信这个对你肯定有帮助原先我从别的地方导数据到我自己的库.200多万条数据用了10多分钟
    用了上面的只花了3秒多,呵呵,加油!
      

  3.   

    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:6407993912330
    If I had to update millions of records I would probably opt to NOT update.I would more likely do:CREATE TABLE new_table as select <do the update "here"> from old_table;index new_table
    grant on new table
    add constraints on new_table
    etc on new_tabledrop table old_table
    rename new_table to old_table;
    you can do that using parallel query, with nologging on most operations generating very 
    little redo and no undo at all -- in a fraction of the time it would take to update the 
    data.