USE 数据库名称壹;
DROP PROCEDURE IF EXISTS 数据库名称一.积累进程名称;
delimiter $$
CREATE PROCEDURE 数据库名称一.存款和储蓄进度名称(in v_count bigint,in
v_count2 bigint)
BEGIN
set @vCount1=v_count;
set @vCount2=v_count2;

mysql存款和储蓄进度(批量生成论坛中发帖、回帖、焦点等数据),mysql存储进度

USE 数据库名称一;
DROP PROCEDURE IF EXISTS 数据库名称1.储存进度名称;
delimiter $$
CREATE PROCEDURE 数据库名称1.存储进度名称(in v_count bigint,in
v_count2 bigint)
BEGIN
set @vCount1=v_count;
set @vCount2=v_count2;

set @i=1;
set @vintervala=10000;
set @vintervalb=10000;
while(@i<[email protected])
do
#随机得到二个版块ID
select fid into @vfid from tps_forum_forum where fup<>0 and
`type`=’forum’ and `status`=1 order by rand() limit 1;

#获取pid
select ifnull(max(pid)+1,1) into @vpid from tps_forum_post;

#获取tid
select ifnull(max(tid)+1,1) into @vtid from tps_forum_post;

#获得发帖的storeid username
select m.uid,m.username into @vuida,@vusernamea from tps_common_member
m where m.uid>4 and m.`status`=0 order by rand() limit 1,1;

set
@[email protected][email protected];
set
@[email protected][email protected]*100;

set @vtitlea=concat(‘发帖标题’,floor(一+RAND()*10000000));
set
@vpostdate=unix_timestamp(DATE_FORMAT(LOCALTIME()[email protected],’%Y-%m-%d
%H:%i:%S’));

set @vip=’211.161.61.12′;
set @vmessagea=concat(‘发帖内容’,floor(一+RAND()*10000000),’\r\n’);
set @vporta=floor(10000+RAND()*55535);

#set @vportb=floor(10000+RAND()*55535);
set @vmessageb=concat(‘回复的第’,@vtid,’个帖子的内容’);

#3新添发送帖子的音讯
INSERT INTO `tps_forum_post` (`pid`, `fid`, `tid`, `first`,
`author`, `authorid`, `subject`, `dateline`, `message`,
`useip`, `port`,
`invisible`, `anonymous`, `usesig`, `htmlon`, `bbcodeoff`,
`smileyoff`, `parseurloff`, `attachment`, `rate`, `ratetimes`,
`status`, `tags`, `comment`, `replycredit`, `position`)
VALUES (@vpid, @vfid, @vtid, 1, @vusernamea, @vuida,
@vtitlea,@vpostdate,@vmessagea, @vip, @vporta, 0, 0, 1, 0, -1, -1, 0, 0,
0, 0, 0, ”, 0, 0, 1);

#最新大旨新闻表
INSERT INTO `tps_forum_newthread` (`tid`, `fid`, `dateline`)
VALUES (@vtid,@vfid, @vpostdate);

#分表和煦音信表
insert into tps_forum_post_tableid values();

#假使二个帖子有60000个回复
set @j=1;
while(@j<[email protected])
do
#获得回帖的storeid username
select m.uid,m.username into @vuidb,@vusernameb from tps_common_member
m where m.uid>4 and m.`status`=0 order by rand() limit 1000,1;

#获取pid
select ifnull(max(pid)+1,1) into @vpid from tps_forum_post;

set
@vreplaydate=unix_timestamp(DATE_FORMAT(LOCALTIME()[email protected],’%Y-%m-%d
%H:%i:%S’));

set
@[email protected]+1;

#二分表协和表
insert into tps_forum_post_tableid values();

#三新扩大回复帖子的新闻
INSERT INTO `tps_forum_post` (`pid`, `fid`, `tid`, `first`,
`author`, `authorid`, `subject`, `dateline`, `message`,
`useip`, `port`,
`invisible`, `anonymous`, `usesig`, `htmlon`, `bbcodeoff`,
`smileyoff`, `parseurloff`, `attachment`, `rate`, `ratetimes`,
`status`, `tags`, `comment`, `replycredit`, `position`)
VALUES (@vpid, @vfid, @vtid, 0, @vusernameb, @vuidb, ”, @vreplaydate,
@vmessageb, @vip, @vporta, 0, 0, 1, 0, -1, -1, 0, 0, 0, 0, 0, ‘0’, 0, 0,
@vposition);

#大旨插手者记录表,第一个回复的帖子新闻
INSERT INTO `tps_forum_threadpartake` (`tid`, `uid`,
`dateline`)
select tid,authorid,dateline
from tps_forum_post where
[email protected]
and
[email protected]
and first=0 and position=2;

#大旨插足者记录表,第@vCount二+一个回复的帖子新闻
INSERT INTO `tps_forum_threadpartake` (`tid`, `uid`,
`dateline`)
select tid,authorid,dateline
from tps_forum_post where
[email protected]
and
[email protected]
and first=0 and
[email protected]+1;

COMMIT;

set
@[email protected]+1;
end while;

#获取position
select max(position) into @vposition from tps_forum_post where first=0
and
[email protected];
select count(0) into @vreplay from tps_forum_post where first=0 and
[email protected];
select max(dateline) into @vreplaydate from tps_forum_post where
first=0 and
[email protected];

#一论坛主题新闻表
INSERT INTO `tps_forum_thread` (`tid`, `fid`, `posttableid`,
`typeid`, `sortid`, `readperm`, `price`, `author`,
`authorid`, `subject`, `dateline`, `lastpost`,
`lastposter`, `views`, `replies`, `displayorder`, `highlight`,
`digest`, `rate`, `special`, `attachment`, `moderated`,
`closed`, `stickreply`, `recommends`,
`recommend_add`, `recommend_sub`, `heats`, `status`,
`isgroup`, `favtimes`, `sharetimes`, `stamp`, `icon`,
`pushedaid`, `cover`, `replycredit`, `relatebytag`,
`maxposition`, `bgcolor`, `comments`, `hidden`)
VALUES (@vtid,@vfid, 0, 0, 0, 0, 0, @vusernamea, @vuida, @vtitlea,
@vpostdate, @vreplaydate,@vusernamea, floor(1000+rand()*10000),
@vreplay, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, floor(0+rand()*2), 32, 0, 0, 0, -1, -1, 0, 0, 0, ‘0’,
@vposition, ”, 0, 0);

#得到版块内主旨数量
select count(0) into @vthreadCount from tps_forum_thread where
[email protected];

#赢得版块内发帖子数量
select count(0) into @vpostCount from tps_forum_post where first=1 and
[email protected];

#收获前几日发帖数量
select count(0) into @vtodayposts from tps_forum_post where first=1
and
[email protected]
and dateline>=unix_timestamp(date_format(localtime(),’%Y-%m-%d’))
and
dateline<=unix_timestamp(DATE_ADD(date_format(localtime(),’%Y-%m-%d’),INTERVAL
24*60*60-1 SECOND));

#获得发帖综合新闻
select fp.pid,fp.message,fp.dateline,fp.author into
@vpid,@vmessage,@vdateline,@vauthor
from tps_forum_post fp where first=1 and
[email protected]
order by dateline desc limit 1;

#更新版块表中 大旨 帖子 明日发帖数据 及发帖综合新闻
update tps_forum_forum ff set
[email protected],[email protected],[email protected],
ff.lastpost=concat(@vpid,@vmessage,@vdateline,@vauthor) where
[email protected];

COMMIT;

set
@[email protected]+1;

END WHILE;
end $$
delimiter ;

call 数据库名称一.积攒进度名称(三,十);

USE 数据库名称1; DROP PROCEDURE IF EXISTS
数据库名称一.储存进度名称…

set @i=1;
set @vintervala=10000;
set @vintervalb=10000;
while(@i<=@vCount1)
do
#随机得到多少个版块ID
select fid into @vfid from tps_forum_forum where fup<>0 and
`type`=’forum’ and `status`=1 order by rand() limit 1;

#获取pid
select ifnull(max(pid)+1,1) into @vpid from tps_forum_post;

#获取tid
select ifnull(max(tid)+1,1) into @vtid from tps_forum_post;

#获得发帖的storeid username
select m.uid,m.username into @vuida,@vusernamea from tps_common_member
m where m.uid>4 and m.`status`=0 order by rand() limit 1,1;

set @vintervala=@vintervala+@i;
set @vintervalb=@vintervalb+@i*100;

set @vtitlea=concat(‘发帖标题’,floor(1+RAND()*10000000));
set
@vpostdate=unix_timestamp(DATE_FORMAT(LOCALTIME()+@vintervala,’%Y-%m-%d
%H:%i:%S’));

set @vip=’192.168.1.1′;
set @vmessagea=concat(‘发帖内容’,floor(一+RAND()*10000000),’\r\n’);
set @vporta=floor(10000+RAND()*55535);

#set @vportb=floor(10000+RAND()*55535);
set @vmessageb=concat(‘回复的第’,@vtid,’个帖子的剧情’);

#叁新扩张发送帖子的音信
INSERT INTO `tps_forum_post` (`pid`, `fid`, `tid`, `first`,
`author`, `authorid`, `subject`, `dateline`, `message`,
`useip`, `port`,
`invisible`, `anonymous`, `usesig`, `htmlon`, `bbcodeoff`,
`smileyoff`, `parseurloff`, `attachment`, `rate`, `ratetimes`,
`status`, `tags`, `comment`, `replycredit`, `position`)
VALUES (@vpid, @vfid, @vtid, 1, @vusernamea, @vuida,
@vtitlea,@vpostdate,@vmessagea, @vip, @vporta, 0, 0, 1, 0, -1, -1, 0, 0,
0, 0, 0, ”, 0, 0, 1);

#最新主题音讯表
INSERT INTO `tps_forum_newthread` (`tid`, `fid`, `dateline`)
VALUES (@vtid,@vfid, @vpostdate);

#分表谐和新闻表
insert into tps_forum_post_tableid values();

#若是叁个帖子有50000个回复
set @j=1;
while(@j<=@vCount2)
do
#获得回帖的storeid username
select m.uid,m.username into @vuidb,@vusernameb from tps_common_member
m where m.uid>4 and m.`status`=0 order by rand() limit 1000,1;

#获取pid
select ifnull(max(pid)+1,1) into @vpid from tps_forum_post;

set
@vreplaydate=unix_timestamp(DATE_FORMAT(LOCALTIME()+@vintervalb,’%Y-%m-%d
%H:%i:%S’));

set @vposition=@j+1;

#贰分表和谐表
insert into tps_forum_post_tableid values();