Mysql批量插入随机测试数据
CREATE TABLE person_info
(
id INT NOT NULL auto_increment,
name VARCHAR(100) NOT NULL,
birthday DATE NOT NULL,
phone_number CHAR(11) NOT NULL,
country varchar(100) NOT NULL,
PRIMARY KEY (id),
KEY idx_name_birthday_phone_number (name,
birthday, phone_number)
);
create procedure zqtest80000()
begin
declare i int default 0;
set i = 0;
start transaction;
while i < 79900
do
insert into person_info(name, birthday, phone_number, country)
values (uuid(), date(from_unixtime(
unix_timestamp('2017-01-01')
+ floor(
rand() * (unix_timestamp('2018-08-08') - unix_timestamp('2017-01-01')
+ 1)
)
)), CONCAT('1', CEILING(RAND() * 9000000000 + 1000000000)), uuid());
set i = i + 1;
end while;
commit;
end;
call zqtest();;
SELECT CONCAT('1', CEILING(RAND() * 9000000000 + 1000000000));
select count(1) from person_info;
本作品采用 知识共享署名-相同方式共享 4.0 国际许可协议 进行许可。