update customer set account = '09'||substr(account,3,6)
where companycode = '206';

解决方案 »

  1.   

    update customer set account = '73'||substr(to_char(account,'00000000'),4) where companycode = '206';
      

  2.   

    我试过用concat函数:
    update customer set account = concat('73',to_char(account,'000000')) where companycode = '206';很遗憾,73后面会跟个空格:'73 001234'
      

  3.   

    to_char(account,'00000000')也有空格
    因此从第4个字符开始截取to_char
    substr
    这些函数在oracle帮助文档里面介绍得很详细,包括各种参数
      

  4.   

    update customer set account='73'||substr(account,3);
      

  5.   

    谢谢各位:我的SQL问题已经解决,bzszp(SongZip)的回答update customer set account = '73'||substr(to_char(account,'00000000'),4) where companycode = '206';完全正确!我将给他(她?)80分其它大大不用回答了。另外SQLplus的手册没有独立的吗?例如chm格式的。
    我是oracle新手,哈哈,虽然sql语言还是很熟悉的,
    可是那些函数不熟悉,简直没法干活。oracle的书太多,
    而我又过了啃书的年龄,头痛的时候才去医头!
      

  6.   

    update customer set account = '73'||substr(lpad(account,8,'0'),4) where companycode = '206';函数:
    http://download-west.oracle.com/docs/cd/A87860_01/doc/server.817/a85397/function.htm#998166
      

  7.   

    今天第一次在oracle论坛提问,
    得到bzszp(SongZip)大大的大力帮助,非常感谢!
    哈哈,bzszp(SongZip)大大一条语句:
    update customer set account = '73'||substr(to_char(account,'00000000'),4) where companycode = '206';
    回答了我两个问题,真是高手!
    有机会还要向老大学习,兄弟的分数是大大的有(5位数),哈哈。to:
    beckhambobo(beckham),lpad(account,8,'0')并不能在account前补'0'。
      

  8.   

    向各位提议用lpad函数的老大道歉:
    我没有说清楚account字段是char(40),它虽然只使用了8位但后面是补空格的。
    所以lpad要和rtrim搭配使用才行:
    lpad(rtrim(account), 8, '0')再次感谢!