Skip to main content
Skip to main content

generateRandom Table Function

Generates random data with a given schema. Allows populating test tables with that data. Not all types are supported.

Arguments

  • name — Name of corresponding column.
  • TypeName — Type of corresponding column.
  • random_seed — Specify random seed manually to produce stable results. If NULL — seed is randomly generated.
  • max_string_length — Maximum string length for all generated strings. Defaults to 10.
  • max_array_length — Maximum elements for all generated arrays or maps. Defaults to 10.

Returned Value

A table object with requested schema.

Usage Example

In combination with generateRandomStructure:

With missing structure argument (in this case the structure is random):

With random seed both for random structure and random data:

Note: generateRandom(generateRandomStructure(), [random seed], max_string_length, max_array_length) with large enough max_array_length can generate really huge output due to possible big nesting depth (up to 16) of complex types (Array, Tuple, Map, Nested).

Try ClickHouse Cloud for FREE

Easy data ingestion, automatic scaling, built-in SQL console and lots more.

Try it for Free