How to generate random bigint

From: Phillip Diffley <phillip6402(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: How to generate random bigint
Date: 2023-12-21 06:06:39
Message-ID: CAGAwPgQt6B0ORW_YfwsdRmWPhb_pG6c9HM7S=G4WGC_s8qaU+w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Postgres's random() function generates a random double. That can be
converted to a random int for smaller integers, but a double can't
represent all of the values in a bigint. Is there a recommended way to
generate a random bigint in Postgres?

Thanks,
Phillip

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2023-12-21 06:20:54 Re: How to generate random bigint
Previous Message Dominique Devienne 2023-12-20 10:49:45 Re: psql crash with custom build on RedHat 7