执行以下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=-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
复制代码 |