MySQL generates random numbers

Source: Internet
Author: User

    1. Recently on MySQL to build some data, involving random numbers

      This is the creation of a 8-bit random string, with numbers and characters, created by the UUID.

      SET @bian = (select Left ((select REPLACE (UUID (), '-', ')), 8));


Create a random date, date format can be modified

SET @datetime = (SELECT floor (1401675501 + (RAND () * 91675501)));

SET @finaldate = (SELECT from_unixtime (@datetime, '%y-%m-%d%h:%i:%s '));


2. Specific stored procedures

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;


This article is from the "Test Stars" blog, so be sure to keep this source http://nickren.blog.51cto.com/7892233/1729491

MySQL generates random numbers

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.