MySQL Forums
Forum List  »  MySQL Workbench

Re: UUID() as a field initialization/default value
Posted by: Peter Brawley
Date: July 01, 2020 01:39PM

Obviously MySQL can implementUUID as a PK, eg ...

create table test(
  uuid binary(16) not null default ( uuid_to_bin( uuid() ) ),
  name varchar(100) not null default '' collate 'utf8mb4_unicode_ci',
  primary key(uuid) 
);

show create table test\G

CREATE TABLE `test` (
  `uuid` binary(16) NOT NULL DEFAULT (uuid_to_bin(uuid())),
  `name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  PRIMARY KEY (`uuid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
Works also for char(36).

WB is a complicated, ornery beast, if it's a WB issue, I'll need to see the exact WB steps that lead to your problem.

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: UUID() as a field initialization/default value
1041
July 01, 2020 01:39PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.