易读小说系统是一款开源的JAVA小说程序,可以帮你快速搭建自己的小说系统,但是往来自不同网站的数据会重复,如何解决数据重复的问题,有网友分享了以下的解决办法。
-
ssh登陆服务器
-
执行命令:
su - postgres
如果出现输入密码窗口, 输入postgres
psql -U postgres -d 你的数据库名
create unique index unique_index_articleno_chaptername ON t_chapter(articleno,chaptername);
create unique index unique_index_articlename_author ON t_article(articlename,author);
如果安装过程是默认的, 你的数据库名就是yidu, 如果改了, 就到web目录下进入WEB-INF/classes, 在jdbc.properties中找到数据库名 jdbc.url=jdbc:postgresql://127.0.0.1:5432/你的数据库名
添加两个唯一索引之前必须确保数据库中不存在重复章节、重复小说
以下两条sql分别查询重复章节和重复小说
--查询重复章节
select articleno,chapterno from t_chapter where chapterno in (
select max(chapterno) from t_chapter tc inner join (
select articleno ,chaptername from t_chapter
group by articleno,chaptername having count(1)>1
) tc1 on tc.chaptername = tc1.chaptername and tc.articleno = tc1.articleno
);
--查询重复小说
select articleno,articlename from t_article where articleno in (
select max(articleno) from t_article tc inner join (
select articlename from t_article
group by articlename having count(1)>1
) tc1 on tc.articlename = tc1.articlename
);
查询结果正确的话, 将select xxxx from 修改为 delete from 重新执行即可。