Skip to content
This repository was archived by the owner on Oct 10, 2025. It is now read-only.

Support DEFAULT value / auto-UUID column in CREATE (similar to SERIAL) #3124

@sapalli2989

Description

@sapalli2989

It would be great, if we could declare within CREATE/DDL, that ids of a UUID column are to be auto-created via gen_random_uuid(). This feature would be analogue to SERIAL for integer sequences.

Currently Kuzu provides gen_random_uuid() for UUIDv4 auto-creation. But the need to invoke this function manually for new nodes with UUID primary key is inconvenient and sometimes not easily possible - as seen with MERGE in #3014. Actually I think proposal here is more useful than linked one.

PostgreSQL provides DEFAULT value keyword within CREATE in combination with equally named gen_random_uuid() for these cases (more examples in 1, 2):

CREATE TABLE table_name (
    unique_id UUID DEFAULT gen_random_uuid(),
    ...
    PRIMARY KEY (unique_id)
);

or with directly prepended PRIMARY KEY:

CREATE TABLE table_name (
    unique_id UUID DEFAULT gen_random_uuid() PRIMARY KEY,
    ...
);

, requested for Kuzu in #2911.

I think this would be a nice addition to usability of UUIDs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions