Discuz教程网

[使用教程] Discuz常用的60个sql语句

[复制链接]
authicon dly 发表于 2012-10-7 11:09:54 | 显示全部楼层 |阅读模式
把某个用户组会员转移到另一个用户组
  1. update cdb_members set groupid=特殊用户组的id where groupid=新手上路用户组的id and adminid=0
复制代码
所有板块的特殊主题开启

  1. UPDATE `cdb_forums` SET `allowpostspecial` = '31'
复制代码

调整某个帖子的点击数
  1. UPDATE cdb_threads SET views=点击数 WHERE tid=主题编号;
复制代码
所有板块开启media代码

  1. UPDATE `cdb_forums` SET `allowmediacode` = '1'
复制代码

调整所有用户最大头像尺寸(像素)为120

  1. update cdb_settings set value = 120 WHERE variable = 'maxavatarpixel'
复制代码

一次性关闭板块fid20帖子

  1. UPDATE `cdb_threads` SET `closed` = '1' WHERE `fid` =20 ;
复制代码


把发帖数为0的用户都转到某个用户组
  1. update cdb_members set groupid = * where posts = 0;
复制代码

开启全部用户组的邀请注册权限  并设置价格

  1. UPDATE `cdb_usergroups` SET `allowinvite` = '1', `inviteprice` = '价格';
复制代码

去除水印图片类型

  1. replace INTO cdb_settings VALUES ('watermarktype','0');
复制代码
调整用户最后登录时间为 2007年8月10日

  1. update cdb_members set lastpost='1186675200';
复制代码
调整 板块隐藏的sql!

  1. UPDATE `cdb_forums` SET `status` = '1',
  2. `lastpost` = '' WHERE `fid` =6 LIMIT 1 ;
复制代码


完整关闭supesite的sql语句:
  1. UPDATE `cdb_settings` SET `value` = '' WHERE `variable` = 'supe_siteurl' ;
  2. UPDATE `cdb_settings` SET `value` = '' WHERE  `variable`   = 'supe_sitename';
  3. UPDATE `cdb_settings` SET `value` = '0' WHERE `variable`  = 'supe_status';
  4. UPDATE `cdb_settings` SET `value` = '' WHERE `variable`    = 'supe_tablepre';
  5. UPDATE `cdb_settings` SET `value` = '0' WHERE `variable`  = 'supe_circlestatus';
复制代码

将A板块的所有帖子转到B板块的C分类里,执行前备份一下数据库


  1. update cdb_threads set fid=B板块ID,typeid=c分类的ID where  fid=A板块ID;
  2. update cdb_posts set fid=B板块ID  where  fid=A板块ID;
复制代码


去除后台管理员ip登录限制
  1. UPDATE `cdb_settings` SET `value` = '' WHERE CONVERT( `variable` USING utf8 ) ='adminipaccess' LIMIT 1 ;
复制代码


删除风格5
  1. delete from cdb_styles where styleid=5 limit 1;
复制代码

论坛所有用户短消息提示音修改为提示音1

  1. UPDATE `cdb_members` SET `pmsound` = '1'
复制代码

删除groupid = 0的用户组

  1. delete from cdb_usergroups where groupid = 0
复制代码

所有板块开启允许编辑帖子

  1. UPDATE `cdb_forums` SET `alloweditpost` = '1'
复制代码

论坛后台 解除insenz绑定语句
  1. delete from cdb_settings where variable='insenz'
复制代码

论坛后台执行后 就可以 重新注册和绑定了


关闭游客浏览所有版块的语句
可以这样构造SQL语句
  1. update cdb_forumfields  set  viewperm ='\t允许浏览的用户组的ID\t'  where  fid in(论坛板块ID)
复制代码

如:
  1. update cdb_forumfields  set  viewperm ='\t1\t2\t'  where  fid in(1,2)
复制代码

所有板块的板块规则设置~!

  1. UPDATE `cdb_forumfields` SET `rules` = '板块规则'
复制代码


开启所有板块的**码

  1. UPDATE `cdb_forums` SET `jammer` = '1'
复制代码


开启所有会员组邀请注册的权限
  1. UPDATE cdb_usergroups SET allowinvite=1, allowmailinvite=1, maxinvitenum=10, maxinviteday=15, inviteprice=10;
复制代码
  1. //allowinvite  允许使用邀请注册:
  2. //allowmailinvite 允许发送邀请注册:
  3. //maxinvitenum 24小时内购买邀请码最大数量:
  4. //maxinviteday 邀请码有效期:
  5. //inviteprice 邀请码购买价格:
复制代码


修改最高日发帖数
  1. UPDATE `cdb_settings` SET `value` = '昨日发帖数 最高日发帖数' WHERE `variable` ='historyposts' LIMIT 1 ;
复制代码

昨日发帖数 和  最高日发帖数 修改为你需要的数字即可, 升级完sql后,更新缓存

'昨日发帖数 最高日发帖数' 中间的空格是tab键~!


关闭论坛的gzip设置!
  1. UPDATE `cdb_settings` SET `value` = '0' WHERE CONVERT( `variable` USING utf8 ) = 'gzipcompress' LIMIT 1 ;
复制代码


批量对用户组禁言
  1. update cdb_members set adminid='-1', groupid='4' where groupid='?';
  2. delete from cdb_threads where authorid=0;
  3. delete from cdb_posts where authorid=0;

复制代码


批量删除游客组的发帖和主题
uid 2000~3000的会员全部积分清零
  1. update cdb_members set credits=0,extcredits1=0,extcredits2=0,extcredits3=0,extcredits4=0,extcredits5=0,extcredits6=0,extcredits7=0,extcredits8=0 where uid > 2000 and uid < 3000;
复制代码

指定范围内的审核主题通过审核
  1. update cdb_threads set displayorder=0 where tid > 最小的 tid and tid < 最大的 tid
复制代码

指定范围内的审核帖子通过审核
  1. update cdb_posts set invisible = 0 where tid > 最小的tid and tid < 最大的 tid
复制代码

批量删除未审核通过的帖子和主题
  1. delete from cdb_threads  where displayorder=-2;
  2. delete from cdb_posts  where invisible=-2;
复制代码

批量关闭投票
  1. UPDATE cdb_threads SET closed = 1 WHERE special=1
复制代码

清空用户安全问答!
  1. UPDATE `cdb_members` SET `secques` = ''
复制代码



清空某个用户组的全部积分sql:
  1. update cdb_members set credits = 0, extcredits1 = 0, extcredits2 = 0, extcredits3 = 0, extcredits4 = 0, extcredits5 = 0, extcredits6 = 0, extcredits7 = 0, extcredits8 = 0, where groupid = 用户组id;
复制代码


关闭所有用户组的积分转账

  1. update cdb_usergroups set allowtransfer=0
复制代码


修改05年11月29日21点33份20秒   前的主题阅读权限100
其中1133300000 是unix时间戳 (以秒为单位) 代表 05年11月29日21点33份20秒   
readperm=100 代表阅读权限

  1. update cdb_threads set readperm=100 where dateline<1133300000  
复制代码

把2005年1月1日以前的阅读权限设高.

  1. update cdb_threads set readperm=100 where dateline<1104537600 and digest=0
复制代码

批量替换帖子里面的评分者的用户名

  1. update cdb_ratelog set uid = '新uid', username = '新username' where uid = '旧的 uid';
复制代码

所有的附件默认阅读权限为1

  1. update cdb_attachments set readperm=1
复制代码

统计发帖量大约0的所有用户积分1的总量

  1. SELECT count(`extcredits1`) FROM `cdb_members` where `posts`=0
复制代码

批量修改uid1~6会员的 showemail 为 1

  1. UPDATE `cdb_members` SET `showemail` ='1' WHERE `uid` in(1,2,3,4,5,6);
复制代码

将主题tid大于14651的所有主题减去16761780 ,此操作前请注意备份!!(按照5.0数据表进行修改的  6.0的需要查看下数据库对比下)

  1. update cdb_threads set tid=tid-16761780 where tid>14651;
  2. update cdb_posts set tid=tid-16761780 where tid>14651;
  3. update cdb_attachments set tid=tid-16761780 where tid>14651;
  4. update cdb_myposts set tid=tid-16761780 where tid>14651;
  5. update cdb_activities set tid=tid-16761780 where tid>14651;
  6. update cdb_activityapplies set tid=tid-16761780 where tid>14651;
  7. update cdb_favorites set tid=tid-16761780 where tid>14651;
  8. update cdb_mythreads set tid=tid-16761780 where tid>14651;
  9. update cdb_paymentlog set tid=tid-16761780 where tid>14651;
  10. update cdb_pollopti** set tid=tid-16761780 where tid>14651;
  11. update cdb_polls set tid=tid-16761780 where tid>14651;
  12. update cdb_pushedthreads set tid=tid-16761780 where tid>14651;
  13. update cdb_relatedthreads set tid=tid-16761780 where tid>14651;
  14. update cdb_rewardlog set tid=tid-16761780 where tid>14651;
  15. update cdb_rsscaches set tid=tid-16761780 where tid>14651;
  16. update cdb_sessi** set tid=tid-16761780 where tid>14651;
  17. update cdb_subscripti** set tid=tid-16761780 where tid>14651;
  18. update cdb_threadsmod set tid=tid-16761780 where tid>14651;
  19. update cdb_tradelog set tid=tid-16761780 where tid>14651;
  20. update cdb_trades set tid=tid-16761780 where tid>14651;
复制代码


将积分1×2的值全部转换成积分2 的SQL语句
比如 我积分1的值是10  积分2的值是100
转换後我积分1的值是0
积分2的值是100+10×2=120

  1. UPDATE cdb_members SET extcredits2 = extcredits1 *2 + extcredits2;
  2. UPDATE cdb_members SET extcredits1 =0;
复制代码


仅作参考!

将积分1加到积分2上  并清零积分1的sql

  1. update cdb_members set extcredits1=extcredits1+extcredits2;
  2. update cdb_members set extcredits1='0';
复制代码

把300天未登录的ID移到某一特殊用户组

  1. update cdb_members set adminid=-1,groupid=特殊用户组ID where  lastactivity< unix_timestamp()-300*24*3600
复制代码

服务器上禁止IP访问命令

  1. iptables -I INPUT -p TCP -s 218.0.211.0/24 --dport 80 -j DROP
复制代码

查一个IP有哪个会员登录

  1. select * from cdb_membsers where lastip="IP"
复制代码
  1. UPDATE cdb_posts p, cdb_attachments a SET p.attachment=1 WHERE p.pid=a.pid;
复制代码


找回丢失附件的sql语句


更新昨日发贴数
昨日发贴数:
   
  1. select count(*) from cdb_posts where   dateline>昨天0时的时间戳 and     dateline<今天0时的时间戳
复制代码


更新昨日发贴数:
   
  1. UPDATE `cdb_settings` SET `value` = '昨日发帖数\t1428' WHERE `variable` ='historyposts' LIMIT 1 ;
复制代码

把"新手上路"用户组下的所有会员转换到另一个特殊的用户组
pl:特殊用户组没有关联任何的管理组

  1. update cdb_members set groupid=特殊用户组的id where groupid=新手上路用户组的id and adminid=0
复制代码

删除一个板块的所有回复

  1. delete from cdb_posts where fid = '需要删除回复的版块id' and first = 0;
复制代码

删除fid23的板块
  1. delete from cdb_forums where fid=23 limit 1;
复制代码

圈子sgid字段缺少 添加的sql

  1. ALTER TABLE cdb_threads ADD sgid mediumint(8) unsigned NOT NULL default '0'
复制代码



更新tid27708主题的统计

  1. update cdb_threads set replies=(select count(*) from cdb_posts where tid=47708) where tid=47708
复制代码

关闭所有板块的允许其它模块共享

  1. update cdb_forums set allowshare=0
复制代码

所有用户的签名清空

  1. UPDATE `cdb_memberfields` SET `sightml` = ' '
复制代码

批量替换帖子中的回复* #的显示为 *楼

  1. UPDATE cdb_posts SET subject=REPLACE(subject,'#','楼');
复制代码

删除一个主题的所有回复

  1. delete from cdb_posts where tid = '需要删除回复的主题的tid' and first = 0;
复制代码

设置缩略图为     为图片附件添加缩略图
  1. UPDATE `cdb_settings` SET `value` = '1' WHERE CONVERT( `variable` USING utf8 ) = 'thumbstatus' LIMIT 1 ;
复制代码

设置缩略图为     将图片附件缩到指定的大小
  1. UPDATE `cdb_settings` SET `value` = '2' WHERE CONVERT( `variable` USING utf8 ) = 'thumbstatus' LIMIT 1 ;
复制代码

批量验证所有未验证的会员
  1. UPDATE `cdb_members` SET `groupid` = '10' WHERE groupid='8';
复制代码


批量删除游客回帖和主题
  1. delete from cdb_threads where authorid=0;
  2. delete from cdb_posts where authorid=0;
复制代码

删除在180天之前的全部短消息
  1. delete from cdb_pms where dateline<1190518730
复制代码

清空某个用户的已发短消息
   
  1. update cdb_pms set delstatus=1 where msgfromid=发送者ID
复制代码

所有用户组(包括系统用户组,普通用户组,特殊用户组)都可以参与投票的SQL语句:
  1. update cdb_usergroups set allowvote=1 where groupid<4 or groupid>9
复制代码

开启所有用户组的扩展积分1和2的评分值为 最小-1 最大1 24小时100
  1. UPDATE `cdb_usergroups` SET `raterange` = '1\t-1\t1\t100\n2\t-1\t1\t100'
复制代码

图片附件设置正确 但是不直接显示的调整sql:
  1. update cdb_attachments set `isimage` =1 where SUBSTRING(`filename`,-3,3)='jpg' or SUBSTRING(`filename`,-3,3)='gif'
复制代码

固定天数内一部份附件到远程附件的sql
  1. update cdb_attachments set remote = '1' where dateline<unix_timestamp()-86400*天数
复制代码

修改所有用户组评分的SQL语句
   
  1. update `cdb_usergroups` set `raterange`='扩展积分ID\t评分最小值\t评分最大值\t24小时最大评分数\n扩展积分ID\t评分最小值\t评分最大值\t24小时最大评分数'
复制代码


游客,如果您要查看本帖隐藏内容请回复




上一篇:Discuz X2.5驻马店论坛精致在线客服/客服中心/右侧浮动客服插件
下一篇:首页N格怎么修改文字为维吾尔文?
authicon swabe 发表于 2012-10-9 22:52:33 | 显示全部楼层
好东西谢谢分享
authicon Mad_World 发表于 2012-10-13 10:43:06 | 显示全部楼层
学习一下
3Q
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

1314学习网 ( 浙ICP备10214163号 )

GMT+8, 2024-5-16 20:20

Powered by Discuz! X3.4

© 2001-2013 Comsenz Inc.

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