mysqlde sequences nasil ayarlabilirim illa bir table mi olusturmali onun icin
mesela
ASGH1
ASGH2
ASGH3
diye devam etmesi gereken bir fieldim var ben gendcz diye table olusturdum ve her defasinda deger almak icin
select concat('ASGH',seq_dcz()); diyerek yeni bir deger elde ediyorum
ve bunun benim table sayisi sirf squence icin artikca artiyor
bu durumu nasil halledebilirim
//table
CREATE TABLE `gendcz` (
`num` int(11) NOT NULL auto_increment,
PRIMARY KEY (`num`)
);
//sequence function
CREATE FUNCTION `seq_dcz`()
RETURNS int(10)
DETERMINISTIC
SQL SECURITY DEFINER
COMMENT ''
BEGIN INSERT INTO `gendcz` VALUES (0) ON DUPLICATE KEY UPDATE `num` = LAST_INSERT_ID(`num` + 1); RETURN LAST_INSERT_ID(); END;