我想将AUTO_INCREMENT更改为UUID

问题描述 投票:0回答:1

好的,我有这个,

CREATE TABLE `order` (
  `id` INT NOT NULL AUTO_INCREMENT,
    PRIMARY KEY(id),
  `title` text,
  `content` longtext,
  `encrypt` text,
  `password` text,
  `now_time` text,
  `s_date` text,
  `views` text,
  `ip` text,
  `date` text,
  `member` text,
  `expiry` text,
  `visible` text,
  `code` longtext
);

我想将AUTO_INCREMENT更改为随机ID或UUID。我该怎么做?

mysql database auto-increment uuid
1个回答
0
投票
CREATE TRIGGER before_insert_table
BEFORE INSERT ON table
FOR EACH ROW
SET new.ID = uuid();

创建触发器。

© www.soinside.com 2019 - 2024. All rights reserved.