Mysql
 sql >> Database >  >> RDS >> Mysql

MySQL:incremento automatico in guid

Usa i trigger.

CREATE TABLE `tbl_test` (
  `GUID` char(40) NOT NULL,
  `Name` varchar(50) NOT NULL,
  PRIMARY KEY (`GUID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

table e pk, ora trigger..

DELIMITER //
CREATE TRIGGER `t_GUID` BEFORE INSERT ON `tbl_test`
 FOR EACH ROW begin
 SET new.GUID = uuid();
end//
DELIMITER ;

Ora prova,

insert into tbl_test(Name) value('trigger happy...');

saluti,/t