Relational Data - Functions - Ulid Functions

From FojiSoft Docs
Revision as of 18:52, 28 August 2024 by Chris.Hansen (talk | contribs) (Import ClickHouse Docs: Wed Aug 28 2024 14:52:40 GMT-0400 (Eastern Daylight Time))
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

generateULID

Generates the ULID.

Syntax

generateULID([x])

Arguments

Returned value

The FixedString type value.

Usage example

SELECT generateULID()
┌─generateULID()─────────────┐
│ 01GNB2S2FGN2P93QPXDNB4EN2R │
└────────────────────────────┘

Usage example if it is needed to generate multiple values in one row

SELECT generateULID(1), generateULID(2)
┌─generateULID(1)────────────┬─generateULID(2)────────────┐
│ 01GNB2SGG4RHKVNT9ZGA4FFMNP │ 01GNB2SGG4V0HMQVH4VBVPSSRB │
└────────────────────────────┴────────────────────────────┘

ULIDStringToDateTime

This function extracts the timestamp from a ULID.

Syntax

ULIDStringToDateTime(ulid[, timezone])

Arguments

Returned value

Usage example

SELECT ULIDStringToDateTime('01GNB2S2FGN2P93QPXDNB4EN2R')
┌─ULIDStringToDateTime('01GNB2S2FGN2P93QPXDNB4EN2R')─┐
│                            2022-12-28 00:40:37.616 │
└────────────────────────────────────────────────────┘

See Also