标签:mysql
最近在mysql上要造一些数据,涉及到随机数
这是造一个8位的随机字符串,有数字和字符,是通过uuid来造的
SET @bian = ( SELECT LEFT (( SELECT REPLACE (uuid(), ‘-‘, ‘‘)), 8 ));
造一个随机日期,日期格式可以修改
SET @datetime = ( SELECT FLOOR( 1401675501 + (RAND() * 91675501)));
SET @finaldate = ( SELECT FROM_UNIXTIME( @datetime, ‘%Y-%m-%d %H:%i:%s‘ ));
2. 具体存储过程
CREATE PROCEDURE pro15 () BEGIN DECLARE i INT DEFAULT 0;
loop_label : LOOP SET @bian = ( SELECT LEFT (( SELECT REPLACE (uuid(), ‘-‘, ‘‘)), 8 ));
SET @datetime = ( SELECT FLOOR( 1401675501 + (RAND() * 91675501)));
SET @finaldate = ( SELECT FROM_UNIXTIME( @datetime, ‘%Y-%m-%d %H:%i:%s‘ ));
INSERT INTO app_cfg VALUES ( "/PP/T1test1/test1" ,@bian ,@bian, 0 ,@bian, "1.0.2" ,@finaldate, TRUE );
SET i = i + 1;
IF i >= 20000 THEN LEAVE loop_label;
END IF;
END LOOP;
END;
本文出自 “测试星空” 博客,请务必保留此出处http://nickren.blog.51cto.com/7892233/1729491
标签:mysql
原文地址:http://nickren.blog.51cto.com/7892233/1729491