老张小站

  1. 欢迎光临

    感谢访问老张的博客!

  • 1
1,107

Discuz! X 批量删除或通过待审核的帖子

分类 网站技术/村民张先生 发布于 2019-11-28 05:47
0

执行以下SQL语句即可,为避免出错,建议操作前备份数据库。
注意:有分表时,需要对分表也执行相关语句。仅供参考,谨慎操作!

批量审核通过待审核的主题

update pre_forum_thread set displayorder=0 where displayorder=-2;
update pre_forum_post set invisible=0 where invisible=-2 and first=1;
delete from pre_forum_thread_moderate where status=0;

批量审核通过待审核、已忽略的主题

update pre_forum_thread set displayorder=0 where displayorder=-3;
update pre_forum_post set invisible=0 where invisible=-3 and first=1;
delete from pre_forum_thread_moderate where status=1;

批量审核通过待审核的回帖

update pre_forum_post set invisible=0 where invisible=-2;
delete from pre_forum_post_moderate where status=0;

批量审核通过待审核、已忽略的回帖

update pre_forum_post set invisible=0 where invisible=-3;
delete from pre_forum_post_moderate where status=1;

批量执行上述四项操作

update pre_forum_thread set displayorder=0 where displayorder in (-2,-3);
update pre_forum_post set invisible=0 where invisible in (-2,-3);
TRUNCATE pre_forum_thread_moderate;
TRUNCATE pre_forum_post_moderate;

批量删除等待审核的主题

delete from pre_forum_thread where displayorder=-2;
delete from pre_forum_thread_moderate where status=0;

批量删除等待审核、已忽略的主题

delete from pre_forum_thread where displayorder=-3;
delete from pre_forum_thread_moderate where status=1;

批量删除等待审核的回帖

delete from pre_forum_post where invisible=-2;
delete from pre_forum_post_moderate where status=0;

批量删除等待审核、已忽略的回帖

delete from pre_forum_post where invisible=-3;
delete from pre_forum_post_moderate where status=1;

批量执行上述四项操作

delete from pre_forum_thread where displayorder in (-2,-3);
TRUNCATE pre_forum_thread_moderate;
delete from pre_forum_post where invisible in (-2,-3);
TRUNCATE pre_forum_post_moderate;

批量移除待审核、草稿、回收站内容

delete from pre_forum_thread where displayorder<0;
TRUNCATE pre_forum_thread_moderate;
delete from pre_forum_post where invisible<0;
TRUNCATE pre_forum_post_moderate;

清空回收站中的主题

DELETE FROM `pre_forum_thread` WHERE `displayorder` = -1

清空回收站中的回帖

DELETE FROM `pre_forum_post` WHERE `invisible` = -5

清空回收站中的日志

DELETE FROM `pre_home_blog` WHERE `status` = -1

冗余数据清理:

清除主帖已不存在的回帖,即post表中记录的tid在thread表中不存在时清除post表中的该行记录。
pre_forum_thread 有分表时禁用!pre_forum_post 有分表时,需要分别对每个分表执行下列语句(替换pre_forum_post为分表名,例如pre_forum_post_1)。
谨慎操作!!这边清理了一个月,未发现任何异常,但不排除有未知影响!

DELETE pre_forum_post FROM pre_forum_post LEFT JOIN pre_forum_thread ON pre_forum_post.tid=pre_forum_thread.tid WHERE pre_forum_thread.tid IS NULL

清除主帖已不存在的分类信息数据

DELETE pre_forum_typeoptionvar FROM pre_forum_typeoptionvar LEFT JOIN pre_forum_thread ON pre_forum_typeoptionvar.tid=pre_forum_thread.tid WHERE pre_forum_thread.tid IS NULL
欢迎转载分享,转载请注明 来源:大张小站 https://www.zhang.cq.cn/20192212.html
若您喜欢这篇文章,欢迎订阅老张小站以获得最新内容。 / 欢迎交流探讨,请发电子邮件至 mail[at]vdazhang.com 。


欢迎谈谈你的看法(无须登录) *正文中请勿包含"http://"否则将被拦截