0

Since MariaDB does not have a UUID data type, based on search I realized that people usually define a column with char(36) as its data type and they can also define a default using uuid() function for it.

However, it's still possible for somebody to insert invalid data directly.

I searched for another function like is_uuid() to be used a in check constraint.

Is there such a thing in MariaDB? Or should I write my own function for this purpose?

5
  • 1
    Since MariaDB does not have a UUID data type. in fact it has. The UUID data type was added in a MariaDB 10.7.0 preview. Commented Jul 14, 2022 at 10:54
  • @ErgestBasha, really? Such good news. At last. Commented Jul 14, 2022 at 11:00
  • uuid blog and docs.
    – danblack
    Commented Jul 14, 2022 at 11:43
  • Which version of MariaDB? The latest version(s) have a datatype UUID.
    – Rick James
    Commented Jul 14, 2022 at 19:24
  • 1
    Pre 10.7 (but at least >= 10.2) you can use a CHECK constraint using REGEPX to check for a valid UUID string my_uuid varchar(36) check (msg regexp '^[[:xdigit:]]{8}-[[:xdigit:]]{4}-[[:xdigit:]]{4}-[[:xdigit:]]{4}-[[:xdigit:]]{12}$') Commented Jul 24, 2022 at 23:00

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.