2020-04-03 13:23:32 +00:00
|
|
|
---
|
2022-08-28 14:53:34 +00:00
|
|
|
slug: /en/engines/table-engines/special/generate
|
2022-04-09 13:29:05 +00:00
|
|
|
sidebar_position: 140
|
|
|
|
sidebar_label: GenerateRandom
|
2022-08-28 21:34:50 +00:00
|
|
|
title: "GenerateRandom Table Engine"
|
2020-04-03 13:23:32 +00:00
|
|
|
---
|
|
|
|
|
2020-03-06 02:19:55 +00:00
|
|
|
The GenerateRandom table engine produces random data for given table schema.
|
2020-02-28 09:19:11 +00:00
|
|
|
|
|
|
|
Usage examples:
|
|
|
|
|
2023-04-19 15:55:29 +00:00
|
|
|
- Use in test to populate reproducible large table.
|
|
|
|
- Generate random input for fuzzing tests.
|
2020-02-28 09:19:11 +00:00
|
|
|
|
2020-04-30 18:19:18 +00:00
|
|
|
## Usage in ClickHouse Server {#usage-in-clickhouse-server}
|
2020-02-28 09:19:11 +00:00
|
|
|
|
2020-03-20 10:10:48 +00:00
|
|
|
``` sql
|
2023-03-22 13:58:10 +00:00
|
|
|
ENGINE = GenerateRandom([random_seed [,max_string_length [,max_array_length]]])
|
2020-02-28 09:19:11 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
The `max_array_length` and `max_string_length` parameters specify maximum length of all
|
2023-01-30 14:23:22 +00:00
|
|
|
array or map columns and strings correspondingly in generated data.
|
2020-02-28 09:19:11 +00:00
|
|
|
|
|
|
|
Generate table engine supports only `SELECT` queries.
|
|
|
|
|
2020-04-30 18:19:18 +00:00
|
|
|
It supports all [DataTypes](../../../sql-reference/data-types/index.md) that can be stored in a table except `LowCardinality` and `AggregateFunction`.
|
2020-02-28 09:19:11 +00:00
|
|
|
|
2020-06-18 08:24:31 +00:00
|
|
|
## Example {#example}
|
2020-02-28 09:19:11 +00:00
|
|
|
|
|
|
|
**1.** Set up the `generate_engine_table` table:
|
|
|
|
|
2020-03-20 10:10:48 +00:00
|
|
|
``` sql
|
2020-03-07 20:35:55 +00:00
|
|
|
CREATE TABLE generate_engine_table (name String, value UInt32) ENGINE = GenerateRandom(1, 5, 3)
|
2020-02-28 09:19:11 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
**2.** Query the data:
|
|
|
|
|
2020-03-20 10:10:48 +00:00
|
|
|
``` sql
|
2020-02-28 09:19:11 +00:00
|
|
|
SELECT * FROM generate_engine_table LIMIT 3
|
|
|
|
```
|
|
|
|
|
2020-03-20 10:10:48 +00:00
|
|
|
``` text
|
2020-02-28 09:19:11 +00:00
|
|
|
┌─name─┬──────value─┐
|
|
|
|
│ c4xJ │ 1412771199 │
|
|
|
|
│ r │ 1791099446 │
|
|
|
|
│ 7#$ │ 124312908 │
|
|
|
|
└──────┴────────────┘
|
|
|
|
```
|
|
|
|
|
2020-04-30 18:19:18 +00:00
|
|
|
## Details of Implementation {#details-of-implementation}
|
2020-03-20 10:10:48 +00:00
|
|
|
|
2023-04-19 15:55:29 +00:00
|
|
|
- Not supported:
|
|
|
|
- `ALTER`
|
|
|
|
- `SELECT ... SAMPLE`
|
|
|
|
- `INSERT`
|
|
|
|
- Indices
|
|
|
|
- Replication
|