Thursday, December 29, 2011

How to fill a increasing values in a column of a table?

How to fill a increasing values in a column of a table?

Lets assume we have a table
Table name : test

NameValue
Yogesh0
Yogesh0
Yogesh0
Yogesh0
Yogesh0
Suresh0
Suresh0

Requirement : to insert 1, 2, 3 .... corresponding to values Yogesh

Query to Update :
create sequence seq start with 1 increment by 1;
update test set Value=seq.nextval where Name='Yogesh';
commit;

Output :
NameValue
Yogesh1
Yogesh2
Yogesh3
Yogesh4
Yogesh5
Suresh0
Suresh0

No comments:

Post a Comment