日期:2014-05-17  浏览次数:20855 次

问个更新主键的问题
有个表的   主键   是     char(5)       原来里面存的是     类似   00001     这样的数据     想改成     'P '+0001     的     就是以字母P打头的数据         想把现有表的数据更新成这样     SQL该怎么写?     谢谢

------解决方案--------------------
update tablename set col= 'P '||substr(col,-4)
------解决方案--------------------
update tablename set col= 'P '||substr(col,2);
------解决方案--------------------
update 表名 set 主键名= 'P '||substr(主键名,0,4)