Skip to main content
Skip to main content

system.primes

Description​

This table contains a single UInt64 column named prime that contains prime numbers in ascending order, starting from 2.

You can use this table for tests, or if you need to do a brute force search over prime numbers.

Reads from this table are not parallelized.

This is similar to the primes table function.

You can also limit the output by predicates.

Columns​

Example​

The first 10 primes.

SELECT * FROM system.primes LIMIT 10;
  ┌─prime─┐
  │     2 │
  │     3 │
  │     5 │
  │     7 │
  │    11 │
  │    13 │
  │    17 │
  │    19 │
  │    23 │
  │    29 │
  └───────┘

The first prime greater than 1e15.

SELECT prime FROM system.primes WHERE prime > 1e15 LIMIT 1;
  ┌────────────prime─┐
  │ 1000000000000037 │ -- 1.00 quadrillion
  └──────────────────┘