Discuz!官方免费开源建站系统

 找回密码
 立即注册
搜索

[修改] 那些你必须珍藏的有关帖子的SQL命令!!留作备用!!

[复制链接]
凯旋森林 发表于 2011-9-2 14:48:16 | 显示全部楼层 |阅读模式
本帖最后由 凯旋森林 于 2011-9-2 14:52 编辑

自己常用的SQL分享给大家,别说我没提醒过你,如果你不备份就操作,你就完了!一个SQL命令能清空你论坛所有帖子

1.论坛附件转为远程:

  1. update pre_forum_attachment_0 set remote=1 where remote=0;
  2. update pre_forum_attachment_1 set remote=1 where remote=0;
  3. update pre_forum_attachment_2 set remote=1 where remote=0;
  4. update pre_forum_attachment_3 set remote=1 where remote=0;
  5. update pre_forum_attachment_4 set remote=1 where remote=0;
  6. update pre_forum_attachment_5 set remote=1 where remote=0;
  7. update pre_forum_attachment_6 set remote=1 where remote=0;
  8. update pre_forum_attachment_7 set remote=1 where remote=0;
  9. update pre_forum_attachment_8 set remote=1 where remote=0;
  10. update pre_forum_attachment_9 set remote=1 where remote=0;
复制代码
建议大家别开什么远程服务器,填写即可,然后把附件上传的图片服务器,这样即可使减少图片压力,又可以把图片传到本地服务器(速度快,错误少啊),定期转移即可
如果图片服务器崩溃,下面是把所有远程附件变本地SQL

  1. update pre_forum_attachment_0 set remote=0 where remote=1;
  2. update pre_forum_attachment_1 set remote=0 where remote=1;
  3. update pre_forum_attachment_2 set remote=0 where remote=1;
  4. update pre_forum_attachment_3 set remote=0 where remote=1;
  5. update pre_forum_attachment_4 set remote=0 where remote=1;
  6. update pre_forum_attachment_5 set remote=0 where remote=1;
  7. update pre_forum_attachment_6 set remote=0 where remote=1;
  8. update pre_forum_attachment_7 set remote=0 where remote=1;
  9. update pre_forum_attachment_8 set remote=0 where remote=1;
  10. update pre_forum_attachment_9 set remote=0 where remote=1;
复制代码
赠送一条:把体积大于 819200kb的附件指定为远程附件
  1. update cdb_attachments set remote = '1' WHERE filesize > 819200;
复制代码

2.锁帖:
把ID为82的板块里的帖子全部锁帖,CLOSED改为0,就是解锁

  1. UPDATE pre_forum_thread SET closed= '1' WHERE fid ='82';
复制代码
把ID为82的板块里的没有附件的帖子全部锁帖,CLOSED改为0,就是解锁

  1. UPDATE pre_forum_thread SET closed= '1' WHERE fid ='82' and attachment ='0';
复制代码
把板块82里时间戳小于1298912461(年月日)的帖子锁帖,时间戳查询网址 http://tool.chinaz.com/Tools/unixtime.aspx
  1. UPDATE pre_forum_thread SET closed= '1' WHERE fid ='82' and dateline<1298912461;
复制代码

3.移动帖子
把版块57所有没有都移动到155里
  1. UPDATE pre_forum_thread SET fid ='155' WHERE fid ='57';
复制代码
把版块57所有没有附件的帖子都移动到155里,attachment更改为1就是所有有附加的帖子
  1. UPDATE pre_forum_thread SET fid ='155' WHERE fid ='57' and attachment ='0';
复制代码
将A板块的所有帖子转到B板块的C分类里
  1. update pre_forum_thread set fid=B板块ID,typeid=c分类的ID where  fid=A板块ID;
复制代码

4.售价
把板块1的帖子售价全部设定为100,

  1. update pre_forum_thread set price=100 where fid='1';
复制代码
price=price+100 所有售价加100  减法为“-”
price=price*10 所有售价乘以10  除法为“/”
售价和附件组合使用例子,把板块1的有附件的帖子售价全部设定为100

  1. update pre_forum_thread set price=100 where fid='1' and and attachment ='1';
复制代码

5.批量删帖,谨慎使用啊,我以前经常用,现在很少了。把论坛列表页显示设定为300,在前台几个批量删除就OK。当然使用下面的SQL不管多少帖子只有1秒。
删除版块53下所有帖子
  1. delete from pre_forum_thread where fid = '53';
复制代码
删除82版块没有附件的所有帖子
  1. delete from pre_forum_thread where fid = '82' and attachment ='0';
复制代码
删除53版块下,所有指定时间前的帖子
  1. delete from pre_forum_thread where fid = '51' and dateline<1262275200;
复制代码

6.权限设置
修改05年11月29日21点33份20秒   前的主题阅读权限100
  1. update pre_forum_thread set readperm=100 where dateline<1133300000;
复制代码
cdb_attachments0(0-9)的附件默认阅读权限为1
  1. update cdb_attachments0 set readperm=1;
复制代码

回复

使用道具 举报

韩_风 发表于 2011-9-2 14:52:27 | 显示全部楼层
:o:o。。。。
回复

使用道具 举报

ngwinking 发表于 2011-9-2 14:53:20 | 显示全部楼层
回复

使用道具 举报

lianjia 发表于 2011-9-2 15:01:17 | 显示全部楼层
大力支持你
回复

使用道具 举报

4700鸡动地蛋疼 发表于 2011-9-2 15:02:12 | 显示全部楼层
好插件,就是要顶啊
回复

使用道具 举报

282108708 发表于 2011-9-25 18:04:34 | 显示全部楼层
期待楼主继续补充。
回复

使用道具 举报

ilei365 发表于 2011-9-25 18:13:44 | 显示全部楼层
不会。。。。。。
回复

使用道具 举报

zhangwjc 发表于 2011-12-10 14:29:09 | 显示全部楼层
delete from pre_forum_thread where fid = '38'
delete from pre_forum_thread where fid = '39'
回复

使用道具 举报

goldlink 发表于 2012-3-24 17:03:48 | 显示全部楼层
楼主,如果想批量设置某个版块下所有贴子的阅读权限该怎么弄?谢谢。
回复

使用道具 举报

大藏南 发表于 2012-3-26 14:50:10 | 显示全部楼层
备用是没错的
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|Discuz! 官方站 ( 皖ICP备16010102号 )star

GMT+8, 2025-8-25 08:14 , Processed in 0.104004 second(s), 14 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表