How to retrieve randomized data rows from a postgreSQL table?

前端 未结 2 499
春和景丽
春和景丽 2020-12-21 21:03

I have a table on a PostgreSQL server database with almost 3 million rows and I need to save all rows to a CSV file. The problem here is that the rows must

相关标签:
2条回答
  • 2020-12-21 21:07

    See this question Selecting random rows

    See this wonderful link Depesz MY THOUGHTS ON GETTING RANDOM ROW

    0 讨论(0)
  • 2020-12-21 21:20

    Typically, you can just ORDER BY a random function of your database flavor, like

    SELECT * FROM table ORDER BY RANDOM()
    

    This might be as slow as shuffling the list, depending on the database server or product.

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