MyISAM引擎将为您做到这一点-
表定义:
CREATE TABLE `sequence` ( `label` char(30) CHARACTER SET latin1 NOT NULL, `id` mediumint(9) NOT NULL AUTO_INCREMENT, PRIMARY KEY (`label`,`id`)) ENGINE=MyISAM DEFAULT CHARSET=utf8;
填充表:
INSERT INTO sequence VALUES ('a', NULL); -- add some 'a' labelsINSERT INTO sequence VALUES ('a', NULL);INSERT INTO sequence VALUES ('a', NULL);INSERT INTO sequence VALUES ('b', NULL); -- add another labels 'b'INSERT INTO sequence VALUES ('b', NULL);INSERT INTO sequence VALUES ('a', NULL); -- add some 'a' labelsINSERT INTO sequence VALUES ('a', NULL);
显示结果:
SELECt * FROM sequence;+-------+----+| label | id |+-------+----+| a | 1 || a | 2 || a | 3 || a | 4 || a | 5 || a | 6 || b | 1 || b | 2 |+-------+----+
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)