↑↓ select ↵ open ⌫ change scope Open full search

PG.CENTER connects PostgreSQL documentation, reference, and ecosystem knowledge. Maintained by Pigsty.

Functions / Mathematical Functions And Operators

Returns a random value in the range 0.0 <= x < 1.0

Reading PG 18current·documented in 27 of 27 versions, 7.1 to 20

Signatures & examples

random ( ) → double precision
Returns a random value in the range 0.0 <= x < 1.0
random() → 0.897124072839091
random ( min integer, max integer ) → integer
Returns a random value in the range min <= x <= max. For type numeric, the result will have the same number of fractional decimal digits as min or max, whichever has more.
random(1, 10) → 7
random(-0.499, 0.499) → 0.347
random ( min bigint, max bigint ) → bigint
Returns a random value in the range min <= x <= max. For type numeric, the result will have the same number of fractional decimal digits as min or max, whichever has more.
random(1, 10) → 7
random(-0.499, 0.499) → 0.347
random ( min numeric, max numeric ) → numeric
Returns a random value in the range min <= x <= max. For type numeric, the result will have the same number of fractional decimal digits as min or max, whichever has more.
random(1, 10) → 7
random(-0.499, 0.499) → 0.347
Version history 5
  1. 18 → 19 changed
  2. 16 → 17 changed
  3. 12 → 13 changed
  4. 8.1 → 8.2 changed
  5. 7.2 → 7.3 changed

Definition snapshot: b7bd9cda · English manual source