您现在的位置: 首页 > 帝国大学 > 常见问题

帝国cms重建数据索引表解决Duplicate entry错误

来源:开发妹源码 发布时间:2020-02-27 00:17:44热度:
提供Duplicate entry错误重建数据索引表的方法及sql语句用于恢复索引表到正常状态...
帝国cms在修改和添加任何内容的时候提示Duplicate entry错误,查看index数据表的记录值与其它的几个表的数量对应有一定的差别。

可以先偿试 在 系统 - 系统设置 -备份与恢复数据 中修复数据表,如果正常了以下就可以忽略。

查看字段除checked外都可以导出,哪么很可能是数据索引表坏掉了。需要重建一个数据表的索引,一个内容模型他是有8个表的,可以用以下语句依次恢复。

一次执行一个效率要高些,一个分号是一条语句下面的是新闻表的重建,其它的表对应修改。

CREATE TABLE [!db.pre!]ecms_newstemp AS(SELECT id,classid,newstime,truetime,lastdotime,havehtml FROM [!db.pre!]ecms_news); ALTER TABLE `[!db.pre!]ecms_newstemp` ADD COLUMN `checked` tinyint(1) not null DEFAULT 0 AFTER `classid`;
ALTER TABLE `[!db.pre!]ecms_newstemp` add primary key (id);
alter table [!db.pre!]ecms_news_index rename to [!db.pre!]ecms_news_indexbak;
alter table [!db.pre!]ecms_newstemp rename to [!db.pre!]ecms_news_index;
ALTER TABLE `[!db.pre!]ecms_news_index` CHANGE `id` `id` INT(10) NOT NULL AUTO_INCREMENT;
alter table [!db.pre!]ecms_news_index add index(classid);
alter table [!db.pre!]ecms_news_index add index(checked);
alter table [!db.pre!]ecms_news_index add index(newstime);
alter table [!db.pre!]ecms_news_index add index(truetime);
update [!db.pre!]ecms_news_index set checked=1;

帝国cms sql语句执行说明

执行的地方在:系统 - 系统设置 -备份与恢复数据 - 执行SQL语句 (在如上图的框里面执行)

 

本文地址:https://www.kaifamei.com/empirecms_faq/67.html

    责任编辑:开发妹源码网