uuid for general-purpose universally unique identifiers, and timeuuid for time-based UUIDs (version 1).
UUID
Theuuid type stores a 128-bit universally unique identifier of any version. The driver uses the uuid crate for UUID support.
Basic Usage
Creating UUIDs
Theuuid crate provides several ways to create UUIDs:
UUID as Primary Key
UUIDs are commonly used as primary keys in ScyllaDB/Cassandra:UUID Conversion
Timeuuid
Thetimeuuid type stores a version 1 UUID, which includes a timestamp component. This makes it useful for time-ordered data.
Basic Usage
Special Ordering
CqlTimeuuid has a special ordering that differs from standard UUID ordering. It orders by timestamp first (the time component of the UUID), then by the other components:
Converting Between UUID and Timeuuid
Timeuuid as Clustering Key
Timeuuid is commonly used as a clustering key for time-series data:Timeuuid Functions
CQL provides several functions for working with timeuuid:Extracting Timestamp from Timeuuid
Nullable UUIDs
Both UUID types can be nullable:Best Practices
Using UUID for Primary Keys
Using Timeuuid for Time-Series Data
Generating Timeuuids
Common Patterns
Pagination with Timeuuid
UUID String Formatting
See Also
- Primitive Types - Other basic data types
- Date and Time Types - Working with timestamps
- Collection Types - Lists and sets of UUIDs
