Functions for working with UUID v7 in the uuid extension, courtesy of @nghduc97. Thank you, Đức!
uuid7
Generate a version 7 (time-ordered, random) UUID.
sqlite> select uuid7();
018ff383-3e37-7615-b764-c241f544e573
sqlite> select uuid7();
018ff383-94fd-70fa-8da6-339180b8e15d
uuid7_timestamp_ms
Extract unix timestamp in miliseconds from version 7 UUID X
. Returns null
if the detected UUID version is not 7.
sqlite> select uuid7_timestamp_ms('018ff38a-a5c9-712d-bc80-0550b3ad41a2');
1717777901001
sqlite> select datetime(uuid7_timestamp_ms('018ff38a-a5c9-712d-bc80-0550b3ad41a2') / 1000, 'unixepoch');
2024-06-07 16:31:41
sqlite> select uuid7_timestamp_ms(uuid4()) is null;
1