update table1 t set name=name||(select case when count(1)>0 then count(1) end from table1 where name=t.name and rowid<t.rowid);
试一下吧 update tab A set name=(select name from (select rowid recordid,name||decode(ROW_NUMBER() OVER (PARTITION BY name order by name),1,null,ROW_NUMBER() OVER (PARTITION BY name order by name)-1) as name from tab) where recordid=a.rowid)
受4楼启发,还可以简略 update table1 t set name=(select t.name||sum(1) from table1 where name=t.name and rowid<t.rowid);
http://blog.csdn.net/bw555/article/details/38037211
set name=name||(select case when count(1)>0 then count(1) end from table1 where name=t.name and rowid<t.rowid);
update tab A
set name=(select name from
(select rowid recordid,name||decode(ROW_NUMBER() OVER (PARTITION BY name order by name),1,null,ROW_NUMBER() OVER (PARTITION BY name order by name)-1) as name from tab)
where recordid=a.rowid)
update table1 t
set name=(select t.name||sum(1) from table1 where name=t.name and rowid<t.rowid);
rowid是行的唯一标识,不会重复