k
kavya A

Posted on 25th April 2024|57 views

0
votes

Postgresql Order By Random

Explain Order by Random() in PostgfreSQL?

Answers
P
jordan chris

Posted on 25th April 2024

Order by random() used for testing purposes where you need random data then we go with this Order by random() functionality.

PostgreSQL fetches all the columns from the mentioned table and then selects a random row. Therefore, this is quite helpful and fast for small tables but large tables like tables having 750 million columns. It takes a few minutes, which is a drawback for this functionality. 

Syntax:

SELECT column FROM table

ORDER BY RANDOM ()

LIMIT 1  

 

Write your answer

STILL GOT QUERIES?

Get a Live FREE Demo
  • Explore the trending and niche courses and learning maps
  • Learn about tuition fee, payment plans, and scholarships
  • Get access to webinars and self-paced learning videos