Skip to content

Instantly share code, notes, and snippets.

@dnnta
Created September 16, 2010 14:51
Show Gist options
  • Save dnnta/582549 to your computer and use it in GitHub Desktop.
Save dnnta/582549 to your computer and use it in GitHub Desktop.
oracle: select * from table_name order by dbms_random.value
#扫描记录时给每条记录生成一个随机值,然后根据这个值进行排序
mssql: select top N * from table_name order by newid()
mysql: select * from table_name order by rand()
#mysql用随机值更新记录
update articles set views = rand()* 1000
sqlite3: select * from table_name order by random()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment