mysql插入测试数据
时间:2021-07-01 10:21:17
帮助过:2人阅读
set_time_limit(0
);
ini_set("memory_limit", "256M"
);
$pre = "INSERT INTO `article` (`cid`, `name`, `post`) VALUES "
;
$sql =
$pre;
$content=‘‘
;
for(
$i=1;
$i<10000000;
$i++
){
$cid =
rand(1,100
);
$k =
mt_rand(5,50
);
for(
$j=3;
$j<=
$k;
$j++
){
$name .=
chr(
mt_rand(33, 126
));
}
$s =
mt_rand(10,100
);
for(
$q=10;
$q<=
$s;
$q++
){
$post .=
chr(
mt_rand(33, 126
));
}
$name =
mysql_real_escape_string(
$name);
$post =
mysql_real_escape_string(
$post);
$sql .= "(
$cid, ‘
$name‘, ‘
$post‘)"
;
if(
$i>0 &&
$i%1000==0
){
file_put_contents(‘D:/web/article.sql‘,
$sql.‘;‘,
FILE_APPEND);
$sql =
$pre;
}else{
$sql.=‘, ‘
;
}
unset(
$name,
$post);
}
2.登陆mysql导入sql文件
source d:/web/article.sql
mysql插入测试数据
标签: