BINARY(16) you convert by hand.
vsql_uuid adds a real uuid column type that holds 16 bytes, prints as the
familiar 36-character form, and sorts by its own comparison rule. It also
generates versions 1, 3, 4, 5, 6, and 7, where MySQL’s own UUID() produces
version 1 only.
Install
vsql_uuid.veb is already in the server’s lib/veb/ directory if you installed
VillageSQL with the install script, the Docker image, or a release tarball.
Install it into the server with one statement:
What it adds
The uuid type
Declare the column asuuid. It occupies 16 bytes and works as a primary key.
Functions
Example
Use a version 7 identifier as the primary key, so rows written later sort after rows written earlier, then read the version back:The ordering above holds only across milliseconds. Version 7 puts a
millisecond timestamp at the front and fills the rest randomly, with no
counter, so two values generated in the same millisecond sort in a random
order relative to each other. That is why the example inserts the two rows in
separate statements. Use
UUID_V6() when you need ordering finer than that.A
uuid column accepts a string literal, but not a string expression. So
INSERT INTO orders VALUES ('550e8400-e29b-41d4-a716-446655440000', ...)
works, while INSERT INTO orders VALUES (UUID(), ...) fails with
ERROR 3219 (HY000): Incorrect uuid value: cannot implicitly cast string expression. Use explicit conversion for column 'id' at row 1. Generate the
value with one of the functions above instead.See also
- UUIDs in MySQL — what each version is for and which to choose
- Primary key strategies — where a UUID key helps and where it costs
- Install extensions — how
INSTALL EXTENSIONworks and where the server looks for a bundle - Available extensions — the full catalog
- villagesql/vsql-uuid — source, build instructions, and the known limitations

