清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>
----用于保存主键 CREATE TABLE `c_guid` ( `Id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(50) NOT NULL DEFAULT '', `guid` int(11) NOT NULL DEFAULT '1', `desc` varchar(255) DEFAULT NULL, PRIMARY KEY (`Id`), UNIQUE KEY `name` (`name`) ) ENGINE=MyISAM AUTO_INCREMENT=52 DEFAULT CHARSET=utf8; ----如果存在此key,则返回下一个id(既id+1)。否则,创建一条新记录,写入新id为1并返回此id. CREATE PROCEDURE `nextGUID`(IN p_name varchar(50)) BEGIN insert into c_guid (name,guid) values(p_name,1) ON DUPLICATE KEY UPDATE guid=guid+1; select guid from c_guid where name=p_name; END; call nextGuid('user_pk');