insert a random number into each row in table

前端 未结 2 1850
误落风尘
误落风尘 2021-01-15 05:26

I currently have an oracle table (lovalarm) containing around 600,000 rows. I need to be able to run a query which will cycle through each row and update a field (lovsiteid

相关标签:
2条回答
  • Just not use subquery:

    update lovalarm
    set lovsiteid = TRUNC(dbms_random.value(14300,17300))
    
    0 讨论(0)
  • 2021-01-15 05:57

    Try this:

    update lovalarm set lovsiteid = (select FLOOR(RAND() * (17300 - 14300) + 14300))
    

    works in MySQL

    0 讨论(0)
提交回复
热议问题