kuzu
kuzu copied to clipboard
Support `DEFAULT` value / auto-`UUID` column in `CREATE` (similar to `SERIAL`)
Discussed in https://github.com/kuzudb/kuzu/discussions/3125
Originally posted by sapalli2989 March 23, 2024
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 https://github.com/kuzudb/kuzu/issues/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 https://github.com/kuzudb/kuzu/issues/2911.
I think this would be a nice addition to usability of UUID
s.