How to create tables with primary key UUID columns in SQLite

After loading the UUID extension, in SQLite you can create tables with a UUID primary key with an automatic value defined by its default value:

1
2
3
create table my_table (
  uuid blob primary key default(uuid_blob(uuid())),
);

Something like autoincrementing for UUID columns.

Tags: SQL SQLite TIL