DISCUZ论坛常用批量修改SQL语句汇总

我们在做论坛网站时,经常需要对论坛内容进行批量修改,如果不采用数据库批量修改,就会把你累爬下。

下面是学做网站论坛汇总DISCUZ论坛常用批量修改SQL语句,根据自己的需要,使用常用SQL语句。注意在使用SQL语句前,一定要备份自己网站数据库。

DISCUZ论坛常用批量修改SQL语句汇总

所有板块的特殊主题开启
UPDATE `cdb_forums` SET `allowpostspecial` = ’31’

调整某个帖子的点击数
UPDATE cdb_threads SET views=点击数 WHERE tid=主题编号;

所有板块开启media代码
UPDATE `cdb_forums` SET `allowmediacode` = ‘1’

调整所有用户最大头像尺寸(像素)为120
update cdb_settings set value = 120 WHERE variable = ‘maxavatarpixel’

一次性关闭板块fid20帖子
UPDATE `cdb_threads` SET `closed` = ‘1’ WHERE `fid` =20 ;

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

UPDATE `cdb_usergroups` SET `allowinvite` = ‘1’, `inviteprice` = ‘价格’;
开启全部用户组的邀请注册权限   并设置价格

replace INTO cdb_settings VALUES (‘watermarktype’,’0′);
去除水印图片类型

update cdb_members set lastpost=’1186675200′;
调整用户最后登录时间为 2007年8月10日

UPDATE `cdb_forums` SET `status` = ‘1’,
`lastpost` = ” WHERE `fid` =6 LIMIT 1 ;
调整 板块隐藏的sql!

完整关闭supesite的sql语句:
UPDATE `cdb_settings` SET `value` = ” WHERE `variable` = ‘supe_siteurl’ ;
UPDATE `cdb_settings` SET `value` = ” WHERE   `variable` = ‘supe_sitename’;
UPDATE `cdb_settings` SET `value` = ‘0’ WHERE `variable`   = ‘supe_status’;
UPDATE `cdb_settings` SET `value` = ” WHERE `variable` = ‘supe_tablepre’;
UPDATE `cdb_settings` SET `value` = ‘0’ WHERE `variable`   = ‘supe_circlestatus’;

将A板块的所有帖子转到B板块的C分类里
update cdb_threads set fid=B板块ID,typeid=c分类的ID where   fid=A板块ID;
update cdb_posts set fid=B板块ID   where   fid=A板块ID;
执行前备份一下数据

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

删除风格5
delete from cdb_styles where styleid=5 limit 1;

UPDATE `cdb_members` SET `pmsound` = ‘1’
论坛所有用户短消息提示音修改为提示音1

delete from cdb_usergroups where groupid = 0
删除groupid = 0的用户组

UPDATE `cdb_forums` SET `alloweditpost` = ‘1’
所有板块开启允许编辑帖子
论坛后台 解除insenz绑定语句
delete from cdb_settings where variable=’insenz’
论坛后台执行后 就可以 重新注册和绑定了

关闭游客浏览所有版块的语句
可以这样构造SQL语句
update cdb_forumfields   set   viewperm =’t允许浏览的用户组的IDt’   where   fid in(论坛板块ID)
如:
update cdb_forumfields   set   viewperm =’t1t2t’   where   fid in(1,2)

UPDATE `cdb_forumfields` SET `rules` = ‘板块规则’
所有板块的板块规则设置~!

UPDATE `cdb_forums` SET `jammer` = ‘1’
开启所有板块的干扰码

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

修改特别高日发帖数
UPDATE `cdb_settings` SET `value` = ‘昨日发帖数 特别高日发帖数’ WHERE `variable` =’historyposts’ LIMIT 1 ;
昨日发帖数 和   特别高日发帖数 修改为你需要的数字即可, 升级完sql后,更新缓存

‘昨日发帖数 特别高日发帖数’ 中间的空格是tab键~!

UPDATE `cdb_settings` SET `value` = ‘0’ WHERE CONVERT( `variable` USING utf8 ) = ‘gzipcompress’ LIMIT 1 ;
关闭论坛的gzip设置!

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

批量删除游客组的发帖和主题
uid 2000~3000的会员全部积分清零
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;

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

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

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

批量关闭投票
UPDATE cdb_threads SET closed = 1 WHERE special=1

UPDATE `cdb_members` SET `secques` = ”
清空用户安全问答!

清空某个用户组的全部积分sql:
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;

update cdb_usergroups set allowtransfer=0

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

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

把2005年1月1日以前的阅读权限设高.
update cdb_threads set readperm=100 where dateline<1104537600 and digest=0

批量替换帖子里面的评分者的用户名
update cdb_ratelog set uid = ‘新uid’, username = ‘新username’ where uid = ‘旧的 uid’;

所有的附件默认阅读权限为1
update cdb_attachments set readperm=1

统计发帖量大约0的所有用户积分1的总量
SELECT count(`extcredits1`) FROM `cdb_members` where `posts`=0

批量修改uid1~6会员的 showemail 为 1
UPDATE `cdb_members` SET `showemail` =’1′ WHERE `uid` in(1,2,3,4,5,6);

主题tid大于14651的所有主题减去16761780
update cdb_threads set tid=tid-16761780 where tid>14651;
update cdb_posts set tid=tid-16761780 where tid>14651;
update cdb_attachments set tid=tid-16761780 where tid>14651;
update cdb_myposts set tid=tid-16761780 where tid>14651;
update cdb_activities set tid=tid-16761780 where tid>14651;
update cdb_activityapplies set tid=tid-16761780 where tid>14651;
update cdb_favorites set tid=tid-16761780 where tid>14651;
update cdb_mythreads set tid=tid-16761780 where tid>14651;
update cdb_paymentlog set tid=tid-16761780 where tid>14651;
update cdb_polloptions set tid=tid-16761780 where tid>14651;
update cdb_polls set tid=tid-16761780 where tid>14651;
update cdb_pushedthreads set tid=tid-16761780 where tid>14651;
update cdb_relatedthreads set tid=tid-16761780 where tid>14651;
update cdb_rewardlog set tid=tid-16761780 where tid>14651;
update cdb_rsscaches set tid=tid-16761780 where tid>14651;
update cdb_sessions set tid=tid-16761780 where tid>14651;
update cdb_subscriptions set tid=tid-16761780 where tid>14651;
update cdb_threadsmod set tid=tid-16761780 where tid>14651;
update cdb_tradelog set tid=tid-16761780 where tid>14651;
update cdb_trades set tid=tid-16761780 where tid>14651;
此操作前请注意网站备份!!(按照5.0数据表进行修改的   6.0的需要查看下数据库对比下)

将积分1加到积分2上   并清零积分1的sql
update cdb_members set extcredits1=extcredits1+extcredits2;
update cdb_members set extcredits1=’0′;

把300天未登录的ID移到某一特殊用户组
update cdb_members set adminid=-1,groupid=特殊用户组ID where   lastactivity< unix_timestamp()-300*24*3600

服务器上禁止IP访问命令
iptables -I INPUT -p TCP -s 218.0.211.0/24 –dport 80 -j DROP

查一个IP有哪个会员登录
select * from cdb_membsers where lastip=”IP”

UPDATE cdb_posts p, cdb_attachments a SET p.attachment=1 WHERE p.pid=a.pid;
找回丢失附件的sql语句

更新昨日发贴数
昨日发贴数:
select count(*) from cdb_posts where dateline>昨天0时的时间戳 and     dateline<今天0时的时间戳
更新昨日发贴数:
UPDATE `cdb_settings` SET `value` = ‘昨日发帖数t1428′ WHERE `variable` =’historyposts’ LIMIT 1 ;

把”新手上路”用户组下的所有会员转换到另一个特殊的用户组
pl:特殊用户组没有关联任意的管理组
update cdb_members set groupid=特殊用户组的id where groupid=新手上路用户组的id and adminid=0

删除一个板块的所有回复
delete from cdb_posts where fid = ‘需要删除回复的版块id’ and first = 0;

delete from cdb_forums where fid=23 limit 1;
删除fid23的板块

圈子sgid字段缺少 添加的sql
ALTER TABLE cdb_threads ADD sgid mediumint(8) unsigned NOT NULL default ‘0’

update cdb_threads set replies=(select count(*) from cdb_posts where tid=47708) where tid=47708
更新tid27708主题的统计

关闭所有板块的允许其它模块共享
update cdb_forums set allowshare=0

UPDATE `cdb_memberfields` SET `sightml` = ‘ ‘
所有用户的签名清空

UPDATE cdb_posts SET subject=REPLACE(subject,’#’,’楼’);
批量替换帖子中的回复* #的显示为 *楼

删除一个主题的所有回复
delete from cdb_posts where tid = ‘需要删除回复的主题的tid’ and first = 0;

UPDATE `cdb_settings` SET `value` = ‘1’ WHERE CONVERT( `variable` USING utf8 ) = ‘thumbstatus’ LIMIT 1 ;
设置缩略图为     为图片附件添加缩略图

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

批量验证所有未验证的会员
UPDATE `cdb_members` SET `groupid` = ’10’ WHERE groupid=’8′;

批量删除游客回帖和主题
delete from cdb_threads where authorid=0;
delete from cdb_posts where authorid=0;

删除在180天之前的全部短消息
delete from cdb_pms where dateline<1190518730

清空某个用户的已发短消息

update cdb_pms set delstatus=1 where msgfromid=发送者ID

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

UPDATE `cdb_usergroups` SET `raterange` = ‘1t-1t1t100n2t-1t1t100′
开启所有用户组的扩展积分1和2的评分值为 最小-1 最大1 24小时100

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

固定天数内一部份附件到远程附件的sql
update cdb_attachments set remote = ‘1’ where dateline<unix_timestamp()-86400*天数

修改所有用户组评分的SQL语句

update `cdb_usergroups` set `raterange`=’扩展积分IDt评分最小值t评分最大值t24小时最大评分数n扩展积分IDt评分最小值t评分最大值t24小时最大评分数’

主题tid大于4009的所有主题减去16773200
update cdb_activities set tid=tid-16773200 where tid>4009;
update cdb_activityapplies set tid=tid-16773200 where tid>4009;
update cdb_attachments set tid=tid-16773200 where tid>4009;
update cdb_campaigns set tid=tid-16773200 where tid>4009;
update cdb_debateposts set tid=tid-16773200 where tid>4009;
update cdb_debates set tid=tid-16773200 where tid>4009;
update cdb_favorites set tid=tid-16773200 where tid>4009;
update cdb_forumrecommend set tid=tid-16773200 where tid>4009;
update cdb_myposts set tid=tid-16773200 where tid>4009;
update cdb_mythreads set tid=tid-16773200 where tid>4009;
update cdb_paymentlog set tid=tid-16773200 where tid>4009;
update cdb_polloptions set tid=tid-16773200 where tid>4009;
update cdb_polls set tid=tid-16773200 where tid>4009;
update cdb_posts set tid=tid-16773200 where tid>4009;
update cdb_relatedthreads set tid=tid-16773200 where tid>4009;
update cdb_rewardlog set tid=tid-16773200 where tid>4009;
update cdb_rsscaches set tid=tid-16773200 where tid>4009;
update cdb_sessions set tid=tid-16773200 where tid>4009;
update cdb_subscriptions set tid=tid-16773200 where tid>4009;
update cdb_threads set tid=tid-16773200 where tid>4009;
update cdb_threadsmod set tid=tid-16773200 where tid>4009;
update cdb_threadtags set tid=tid-16773200 where tid>4009;
update cdb_tradelog set tid=tid-16773200 where tid>4009;
update cdb_trades set tid=tid-16773200 where tid>4009;
update cdb_typeoptionvars set tid=tid-16773200 where tid>4009;
update cdb_videos set tid=tid-16773200 where tid>4009;
update cdb_videotags set tid=tid-16773200 where tid>4009;
如果安装了supesite   有了推送主题表还加上:
update cdb_pushedthreads set tid=tid-16773200 where tid>4009;
以上sql为6.0版本

批量替换论坛标题内容
UPDATE `cdb_threads` SET `subject` = replace (`subject`,’需要替换的’,’替换后的’)

UPDATE `cdb_attachments` SET `thumb` = ‘0’
取消所有附件的缩略图数据

UPDATE `cdb_threads` SET `highlight` = ‘0’
取消全部帖子的高亮显示

论坛里所有回复长度小于20的而且没有附件的贴子全部删除掉
delete from cdb_posts where length(message)<20 and attachment=0

查询ftp上的附件是否在数据库内
phpmyadmin中 执行sql:
select * from cdb_attachments where attachment like “%文件名称%”

一次性给一个贴内的所有回帖人加积分
update cdb_members set extcredits2=extcredits2+10   where uid in(SELECT authorid FROM `cdb_posts` WHERE tid=主题ID)
extcredits2   是需要增加的积分字段 , 使用的时候要注意增加的哪个积分字段

truncate cdb_validating
清空用户审核数据表

UPDATE `cdb_members` SET `oltime` = ‘0’
所有用户的在线时间修改为0

把体积大于 819200kb的附件指定为远程附件
update cdb_attachments set remote = ‘1’ WHERE filesize > 819200

ALTER TABLE `cdb_threads` CHANGE `tid` `tid` MEDIUMINT(8) UNSIGNED NOT NULL AUTO_INCREMENT;

© 版权声明
THE END
喜欢就支持一下吧
点赞11
评论 抢沙发
头像
欢迎您留下宝贵的见解!
提交
头像

昵称

取消
昵称

    暂无评论内容

随即推荐
IPA软件源预览系统源码-铁虎资源网

IPA软件源预览系统源码

这是一款IPA软件源预览系统源码,搭建这个源码一定记住没有软件源的别搭建,因为你玩不明白,不是做ipa软件源的不要下载这套源码,简单的测试了,UI很舒服,喜欢的自行部署!
DustyBeato的头像-铁虎资源网DustyBeato14天前
05013
AI音乐创作工具实操商业应用,构建从技术入门到变现的完整知识闭环-铁虎资源网

AI音乐创作工具实操商业应用,构建从技术入门到变现的完整知识闭环

本课程围绕AI音乐创作展开三大核心模块:商业应用(广告歌/爱情歌制作)、工具实操(SunoAI注册与进阶使用)、创意实验(唐诗摇滚/老照片音乐化)。通过6大专项训练,构建从技术入门到商业变现...
Jeromesoymn的头像-铁虎资源网Jeromesoymn6天前
0509

多线服务器具有什么优势?5大隐藏优势告别单线卡顿

多线服务器具有什么优势?多线服务器通过整合不同运营商(如电信、联通、移动)及国际优质线路(如CN2GIA),实现流量智能调度与故障自动切换,有效解决跨网延迟、单点故障等问题。其核心价值在...
admin的头像-铁虎资源网admin18天前
0476
彩虹易支付新模板-铁虎资源网

彩虹易支付新模板

免费分享一个易支付商户登录页模板
g123456的头像-铁虎资源网g12345617天前
02110
心理类短视频小众赛道变现实战,选题策略、素材积累、视频制作全流程教学-铁虎资源网

心理类短视频小众赛道变现实战,选题策略、素材积累、视频制作全流程教学

这是一套专注于心理类短视频制作的实战课程,通过38个作品实现12万粉丝增长,验证了心理领域的小众赛道变现潜力。课程包含选题策略、素材积累、视频制作全流程教学,并提供现成素材模板,重点教...
Prostokva__whol的头像-铁虎资源网Prostokva__whol18天前
03014
QQ号码价值评估系统html代码-铁虎资源网

QQ号码价值评估系统html代码

由于前面刷视频经常刷到有人直播QQ号码价值评估,想着也搞一个玩玩,找了一圈接口好像很多都用不来,下面提供一个自己随便搞得页面,有兴趣的大佬可以完善下
Prof40avalt的头像-铁虎资源网Prof40avalt20天前
0279
实现从写作小白到变现达人蜕变-铁虎资源网

实现从写作小白到变现达人蜕变

专为女频短篇写作新手打造的系统课,涵盖 “短篇认知→必备技能→爆款公式→实战避坑” 全流程:18 节视频课拆解拆文技巧、导语钩子、冲突节奏等核心要素,配套《上岸实操手册》解析爽文、虐文...
CF诗晨的头像-铁虎资源网CF诗晨20天前
0436
零基础(AN)沙雕动画制作全流程,系统掌握从动画制作到账号运营的完整技能-铁虎资源网

零基础(AN)沙雕动画制作全流程,系统掌握从动画制作到账号运营的完整技能

本课程为零基础学员提供Adobe Animate(AN)沙雕动画制作全流程教学,从软件安装、界面设置到素材管理、动画制作技巧,涵盖人物表情控制、场景移动、音频处理等核心功能。课程包含入门操作、文...
test41297315的头像-铁虎资源网test41297315昨天
05014
遥控精灵v5.3.5国际版,支持控制全球7000+种电器-铁虎资源网

遥控精灵v5.3.5国际版,支持控制全球7000+种电器

可能有朋友对 “遥控精灵” 并不陌生,也有可能用过同类型 App,但这款堪称遥控类 APP 中的标杆,官方宣称支持全球 7000 + 种电器的控制。不过国内版本广告繁多,据说使用一次就弹一次广告,而...
test32576033的头像-铁虎资源网test325760336天前
0478