解决方案 »

  1.   

    直接 update 客户表 set 客户编号=rownum?
      

  2.   

    或建立一个序列
    update 客户表 set 客户编号=序列.nextval
      

  3.   

    谢谢回应。
    不过不同用户,有特定的编号,所以不能够使用nextVal
      

  4.   

    用java程序来逐条读取是一种方式
    也可以将客户和客户编号的信息导入到数据库里的一张临时创建的表中,然后直接关联update即可
    至于如何导,可以用java读取dbf,可以导出txt文件用sqlldr导入,也可以直接导成excel文件,通过plsql dev粘贴到临时表中
      

  5.   

    谢谢版主回应。
    你意思说:导入客户和客户编号的DBF文件到新创的表(列如 :temp_customer_code)
    然后
    update customer  set customer.customer_code=(select temp_customer_code.customer_code from temp_customer_code where temp_customer_code.name=customer.name) 
    where exists(select temp_customer_code.name from temp_customer_code where temp_customer_code.name=customer.name)这样对吗?
    谢谢了
      

  6.   

    刚刚试了,出了错误
    SQL Error: ORA-01427: single-row subquery returns more than one row
    客户数据表里多过10万多记录,相对dbf里的客户编号也是一样
    请赐教SQL语句该怎样写才能更新客户表里的所有客户的客户编号相对于临时创建的表中的客户编号谢谢
      

  7.   

    一个客户对应了多个编号建议将条件中的exists(select ... from ...)改成
    where (select count(1) from .....)=1客户编号为空的部分再人工核对
      

  8.   

    谢谢回应小弟刚才试这样做了
    update TBL_MEMBER  set TBL_MEMBER.ACC_ID=(select TEMP_ACC_ID.Tien  from TEMP_ACC_ID where TEMP_ACC_ID.CALLING=TBL_MEMBER.MEMBER_ID AND ROWNUM<2) 不知道可以吗?
    请赐教。
    谢谢
      

  9.   

    主要是逻辑问题
    rownum<2可以将记录限定到1条,不会报错了,但是业务上来说,同一个叫张三的客户有10和20两个编号,随便给个10,会不会有问题
      

  10.   

    select * from temp_customer_code x
    where exists(select 1 from temp_customer_code where calling=x.calling and tien=x.tien and rowid<>x.rowid)
    order by calling,tien看看有没有记录。这些记录就是重复的