mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-10-20 15:30:50 +00:00
2d2bc052e1
* Typo fix. * Links fix. * Fixed links in docs. * More fixes. * docs/en: cleaning some files * docs/en: cleaning data_types * docs/en: cleaning database_engines * docs/en: cleaning development * docs/en: cleaning getting_started * docs/en: cleaning interfaces * docs/en: cleaning operations * docs/en: cleaning query_lamguage * docs/en: cleaning en * docs/ru: cleaning data_types * docs/ru: cleaning index * docs/ru: cleaning database_engines * docs/ru: cleaning development * docs/ru: cleaning general * docs/ru: cleaning getting_started * docs/ru: cleaning interfaces * docs/ru: cleaning operations * docs/ru: cleaning query_language * docs: cleaning interfaces/http * Update docs/en/data_types/array.md decorated ``` Co-Authored-By: BayoNet <da-daos@yandex.ru> * Update docs/en/getting_started/example_datasets/nyc_taxi.md fixed typo Co-Authored-By: BayoNet <da-daos@yandex.ru> * Update docs/en/getting_started/example_datasets/ontime.md fixed typo Co-Authored-By: BayoNet <da-daos@yandex.ru> * Update docs/en/interfaces/formats.md fixed error Co-Authored-By: BayoNet <da-daos@yandex.ru> * Update docs/en/operations/table_engines/custom_partitioning_key.md Co-Authored-By: BayoNet <da-daos@yandex.ru> * Update docs/en/operations/utils/clickhouse-local.md Co-Authored-By: BayoNet <da-daos@yandex.ru> * Update docs/en/query_language/dicts/external_dicts_dict_sources.md Co-Authored-By: BayoNet <da-daos@yandex.ru> * Update docs/en/operations/utils/clickhouse-local.md Co-Authored-By: BayoNet <da-daos@yandex.ru> * Update docs/en/query_language/functions/json_functions.md Co-Authored-By: BayoNet <da-daos@yandex.ru> * Update docs/en/query_language/functions/json_functions.md Co-Authored-By: BayoNet <da-daos@yandex.ru> * Update docs/en/query_language/functions/other_functions.md Co-Authored-By: BayoNet <da-daos@yandex.ru> * Update docs/en/query_language/functions/other_functions.md Co-Authored-By: BayoNet <da-daos@yandex.ru> * Update docs/en/query_language/functions/date_time_functions.md Co-Authored-By: BayoNet <da-daos@yandex.ru> * Update docs/en/operations/table_engines/jdbc.md Co-Authored-By: BayoNet <da-daos@yandex.ru> * docs: fixed error * docs: fixed error
66 lines
2.6 KiB
Markdown
66 lines
2.6 KiB
Markdown
# UUID {#uuid-data-type}
|
|
|
|
A universally unique identifier (UUID) is a 16-byte number used to identify records. For detailed information about the UUID, see [Wikipedia](https://en.wikipedia.org/wiki/Universally_unique_identifier).
|
|
|
|
The example of UUID type value is represented below:
|
|
|
|
```text
|
|
61f0c404-5cb3-11e7-907b-a6006ad3dba0
|
|
```
|
|
|
|
If you do not specify the UUID column value when inserting a new record, the UUID value is filled with zero:
|
|
|
|
```text
|
|
00000000-0000-0000-0000-000000000000
|
|
```
|
|
|
|
## How to generate
|
|
|
|
To generate the UUID value, ClickHouse provides the [generateUUIDv4](../query_language/functions/uuid_functions.md) function.
|
|
|
|
## Usage example
|
|
|
|
**Example 1**
|
|
|
|
This example demonstrates creating a table with the UUID type column and inserting a value into the table.
|
|
|
|
```sql
|
|
CREATE TABLE t_uuid (x UUID, y String) ENGINE=TinyLog
|
|
```
|
|
```sql
|
|
INSERT INTO t_uuid SELECT generateUUIDv4(), 'Example 1'
|
|
```
|
|
```sql
|
|
SELECT * FROM t_uuid
|
|
```
|
|
```text
|
|
┌────────────────────────────────────x─┬─y─────────┐
|
|
│ 417ddc5d-e556-4d27-95dd-a34d84e46a50 │ Example 1 │
|
|
└──────────────────────────────────────┴───────────┘
|
|
```
|
|
|
|
**Example 2**
|
|
|
|
In this example, the UUID column value is not specified when inserting a new record.
|
|
|
|
```sql
|
|
INSERT INTO t_uuid (y) VALUES ('Example 2')
|
|
```
|
|
```sql
|
|
SELECT * FROM t_uuid
|
|
```
|
|
```text
|
|
┌────────────────────────────────────x─┬─y─────────┐
|
|
│ 417ddc5d-e556-4d27-95dd-a34d84e46a50 │ Example 1 │
|
|
│ 00000000-0000-0000-0000-000000000000 │ Example 2 │
|
|
└──────────────────────────────────────┴───────────┘
|
|
```
|
|
|
|
## Restrictions
|
|
|
|
The UUID data type only supports functions which [String](string.md) data type also supports (for example, [min](../query_language/agg_functions/reference.md#agg_function-min), [max](../query_language/agg_functions/reference.md#agg_function-max), and [count](../query_language/agg_functions/reference.md#agg_function-count)).
|
|
|
|
The UUID data type is not supported by arithmetic operations (for example, [abs](../query_language/functions/arithmetic_functions.md#arithm_func-abs)) or aggregate functions, such as [sum](../query_language/agg_functions/reference.md#agg_function-sum) and [avg](../query_language/agg_functions/reference.md#agg_function-avg).
|
|
|
|
[Original article](https://clickhouse.yandex/docs/en/data_types/uuid/) <!--hide-->
|