Generating random data is useful for various purposes, but more often than not, we want to generate random data for testing, development, and benchmarking. For example, you might want to populate data in your local development environment, or you might want to test some query optimization techniques and you need a big table.

The RANDOM function

To generate random numbers PostgreSQL provides a random function. The function then returns a value between 0 and 1:

Get hands-on with 1400+ tech skills courses.