Update rows with random number....

Hello All,
    I'm trying to update a column in a table, with about 1000 rows, with a randon string.
This is what i tried....

update tab1 set col1 = (select dbms_random.string('X', 5) from dual)

This doesnt seem to work..   its not getting a new random number.
Is there a simple solution.
Appreciate your time.
queryanalyzerAsked:
Who is Participating?
 
actonwangCommented:
update tab1 set col1 = dbms_random.string('U',5)
/
0
 
actonwangCommented:
>>update tab1 set col1 = (select dbms_random.string('X', 5) from dual)
 
    if you do this, dbms_random will only execute once for all columns.

      :)
0
 
queryanalyzerAuthor Commented:
Ok..   that look simple.
I ended up trying something like this...

update tab1 t1 set t1.col1 = (select dbms_random.string('X', 5) from dual, tab1 t2 where t1.pk = t2.pk)

0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
actonwangCommented:
You just need to use my query if you just want some random strings.
0
 
actonwangCommented:
why do you need dual to come into play in your case? I don't think you need dual there.
0
 
paquicubaCommented:
update ( SELECT col1, dbms_random.string('X', 5) STRING from TAB1) SET COL1 = STRING;
0
 
queryanalyzerAuthor Commented:
actonwang,
     You are right i dont need it.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.