2019独角兽企业重金招聘Python工程师标准>>>
drop procedure TestVoucher;
-- 定义存储过程
delimiter $$
create procedure TestVoucher()
begin
DECLARE max int;
DECLARE rc int;
declare tempVoucherId VARCHAR(60); -- 随机数
declare TEMP_VOUCHER_NO VARCHAR(60); -- 随机数
declare TEMP_GOODS_ID varCHAR(60);
declare TEMP_GOODS_NAME varCHAR(60);
declare time TIMESTAMP ;
set max =100;
set rc =1;
loopl: while rc
SELECT FLOOR(7 + (RAND() * 6)); 取7到12的随机整数,包括7到12
SELECT FLOOR(12+(rand()*13)); 取12到24的随机整数,包括12到24
LPAD(FLOOR(0 + (RAND() * 23)),2,0) 取0-24之间的随机数,不够2位的前补0
格式 : 2008-12-11 17:43:11
举例:
给用户赋一个随机入职日期,年份为1990-2014
select CONCAT(FLOOR(1990 + (RAND() * 25)),'-',LPAD(FLOOR(1 + (RAND() * 12)),2,0),'-',LPAD(FLOOR(3 + (RAND() * 8)),2,0))
结果:1999-10-07
select CONCAT(LPAD(FLOOR(0 + (RAND() * 23)),2,0),':',LPAD(FLOOR(0 + (RAND() * 59)),2,0),':',LPAD(FLOOR(0 + (RAND() * 59)),2,0))
结果:15:39:18
拼好之后,再写update语句就可以了