@shellex说: 我预感有不好的事情发生了

来一段生成大量测试数据的MySQL存储过程

为了对大量记录的测试嘛。

DELIMITER $$

DROP PROCEDURE IF EXISTS `SysAnywhere`.`test_inert_root_batch`$$
CREATE DEFINER=`root`@`localhost` PROCEDURE `test_inert_root_batch`(IN n int(10))
BEGIN
declare i int(10);
set i = 1;
while i<=n do
-- concat('("',concat('fake_name_', i), '","',concat('fake_pwd_', i),'","',concat('fake_contact_', i), '")');
	set @sqltext = concat('("',concat('fake_name_', i), '","',concat('fake_pwd_', i),'","',concat('fake_contact_', i), '")');
	set @sqltext = concat('insert into `Root` (Name, Pwd, Contact) values', @sqltext);
	prepare stmt from @sqltext;
	execute stmt;
	set i = i + 1;
end while;
END$$

DELIMITER ;
  1. On November 4, 2008 at 1:23 am
    DUSTMAN :

    这是啥语言..

    Notify
  2. On November 4, 2008 at 10:34 am

    @DUSTMAN,
    python。
    关键是,不知道哥哥最终目的是干嘛。

    Notify
  3. On November 4, 2008 at 7:24 pm
    shellex :

    @abettor,
    不是python,是MySQL的存储过程。
    shellex的目的是交课程作业….

    Notify

Leave a Reply