存储过程 插入大量数据
CREATE TABLE aaa ( `id` int(10) NOT NULL AUTO_INCREMENT, `title` varchar(200) NOT NULL, `cid` int(10) NOT NULL, `resume` text NOT NULL, `releasetime` int(10) NOT NULL, `uid` int(10) NOT NULL, `type` tinyint(1) unsigned NOT NULL DEFAULT '0', `hits` int(10) NOT NULL, `ifshare` tinyint(1) unsigned NOT NULL DEFAULT '0', `pic_url` varchar(255) NOT NULL, `search` varchar(255) NOT NULL, `cat` tinyint(2) unsigned NOT NULL DEFAULT '0', `replies` int(10) unsigned NOT NULL DEFAULT '0', `gameid` varchar(20) NOT NULL, `checked` tinyint(1) unsigned NOT NULL DEFAULT '0', `havepic` tinyint(1) unsigned NOT NULL DEFAULT '0', `siteid` int(11) unsigned NOT NULL DEFAULT '0', PRIMARY KEY (`siteid`,`id`), KEY `cid` (`cid`,`uid`), KEY `hits` (`hits`) ) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 ; delimiter // create procedure linsert() begin declare i varchar(20); set i=0; while i < 3 do insert into aquestion(f_title,f_content,f_added,f_added_num,f_uid,f_username,f_cid,f_reward,f_anony) select f_title,f_content,f_added,f_added_num,f_uid,f_username,f_cid,f_reward,f_anony from oho_ask_question; set i=i+1; end while; end// delimiter ; call linsert(); CREATE TABLE bb( `id` int(10) NOT NULL AUTO_INCREMENT, `title` varchar(200) NOT NULL, `resume` text NOT NULL, PRIMARY KEY (`id`) )ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 ; delimiter // insert into bb(title,resume) values ('我们','好朋友');