UUID and TIMEUUID
AttentionThis page documents an earlier version. Go to the latest (v2.1)version.
Synopsis
UUID
datatype is used to specify columns for data of universally unique ids. TIMEUUID
is a universal unique identifier variant that includes time information.
DataType | Description |
---|---|
UUID | UUID (all versions) |
TIMEUUID | UUID (version 1) |
Syntax
type_specification ::= { UUID | TIMEUUID }
uuid_literal ::= 4hex_block 4hex_block '-' 4hex_block '-' 4hex_block '-' 4hex_block '-' 4hex_block 4hex_block 4hex_block
4hex_block ::= hex_digit hex_digit hex_digit hex_digit
Where
hex_digit
is a hexadecimal digit ([0-9a-fA-F]
).
Semantics
- Columns of type
UUID
orTIMEUUID
can be part of thePRIMARY KEY
. - Implicitly, values of type
UUID
andTIMEUUID
datatypes are neither convertible nor comparable to other datatypes. TIMEUUID
s are version 1 UUIDs: they include the date and time of their generation and a spatially unique node identifier.- Comparison of
TIMEUUID
values first compares the time component and then (if time is equal) the node identifier.
Examples
You can do this as shown below.
cqlsh:example> CREATE TABLE devices(id UUID PRIMARY KEY, ordered_id TIMEUUID);
cqlsh:example> INSERT INTO devices (id, ordered_id)
VALUES (123e4567-e89b-12d3-a456-426655440000, 123e4567-e89b-12d3-a456-426655440000);
cqlsh:example> INSERT INTO devices (id, ordered_id)
VALUES (123e4567-e89b-42d3-a456-426655440000, 123e4567-e89b-12d3-a456-426655440000);
cqlsh:example> UPDATE devices SET ordered_id = 00000000-0000-1000-0000-000000000000
WHERE id = 123e4567-e89b-42d3-a456-426655440000;
cqlsh:example> SELECT * FROM devices;
id | ordered_id
--------------------------------------+--------------------------------------
123e4567-e89b-12d3-a456-426655440000 | 123e4567-e89b-12d3-a456-426655440000
123e4567-e89b-42d3-a456-426655440000 | 00000000-0000-1000-0000-000000000000
See Also
当前内容版权归 YugabyteDB 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 YugabyteDB .