發新話題

Discuz 論壇SQL語句大全:批量執行、設置、開關

Discuz 論壇SQL語句大全:批量執行、設置、開關

批量驗證所有未驗證的會員
UPDATE `cdb_members` SET `groupid` = '10' WHERE groupid='8';

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');

調整用戶最後登錄時間為 2007年8月10日

update cdb_members set lastpost='1186675200';

調整 板塊隱藏的sql
UPDATE `cdb_forums` SET `status` = '1',
`lastpost` = '' WHERE `fid` =6 LIMIT 1 ;

完整關閉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允許瀏覽的用戶組的ID\t' where fid in(論壇板塊ID)

如:

update cdb_forumfields set viewperm ='\t1\t2\t' 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` = '1\t-1\t1\t100\n2\t-1\t1\t100'
開啟所有用戶組的擴展積分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`='擴展積分ID\t評分最小值\t評分最大值\t24小時最大評分數\n擴展積分ID\t評分最小值\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;

TOP

轉換後,用戶組更新問題

原來版本:dvbbs7.1
轉到到:dz7.0
——
現在的問題是:
轉換後,用戶積分和對應的用戶組不匹配。請問這個問題該如何解決?
現在全部都是「新手上路」。
——-
謝謝樓下幫助!~
2010-4-2補充:

   1. UPDATE cdb_members m, cdb_usergroups u SET m.groupid = u.groupid WHERE u.type='member' AND m.credits < u.creditslower AND m.credits >= u.creditshigher AND m.adminid <=0;

需要增加一個判斷


UPDATE cdb_members m, cdb_usergroups u SET m.groupid = u.groupid WHERE u.type='member' AND m.credits < u.creditslower AND m.credits >= u.creditshigher AND m.adminid <=0 and m.groupid<>'4' and m.groupid<>'5'

不然會將原本轉換過來的禁言和不允許登陸的用戶也重新劃歸到積分對用的組裡了。
---------------------------------------------------------
在後台數據庫升級或者phpmyadmin裡執行這句話
UPDATE cdb_members m, cdb_usergroups u SET m.groupid = u.groupid WHERE u.type='member' AND m.credits < u.creditslower AND m.credits >= u.creditshigher AND m.adminid <=0;

TOP

發新話題

本站所有圖文均屬網友發表,僅代表作者的觀點與本站無關,如有侵權請通知版主會盡快刪除。