推广 热搜: 后台  帝国cms  DESTOON  位置  网站  帝国cms建站  Wordpress教程  内容  MAC系统  destoon模板 

易读小说拒绝重复采集的解决办法

   日期:2019-09-23     浏览:169    违规举报
 

易读小说系统是一款开源的JAVA小说程序,可以帮你快速搭建自己的小说系统,但是往来自不同网站的数据会重复,如何解决数据重复的问题,有网友分享了以下的解决办法。

  1. ssh登陆服务器

  2. 执行命令:

        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 重新执行即可。



删除重复章节
delete 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
);
删除重复小说
delete 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
);

删除指定小说全部章节

delete from t_chapter where articleno = 数字id;

--查询重复章节

select * from (

    select tc.articleno,tc.chapterno,row_number() over(partition by tc.chaptername order by tc.chapterno asc) mark

    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

) temp where mark<>1;

--查询重复小说

select * from (

    select tc.articleno,tc.articlename,row_number() over(partition by tc.articlename order by articleno asc) mark 

    from t_article tc inner join (

           select articlename from t_article

           group by articlename having count(1)>1

      ) tc1 on tc.articlename = tc1.articlename

) temp where mark<>1;



免责声明:
1、本站所收集的部分公开资料来源于互联网,转载的目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。
2、本站部分作品内容是由网友自主投稿和发布、编辑整理上传,对此类内容本站仅提供交流平台,不为其版权负责,更不为其观点承担任何责任。
3、因行业及专业性有限,故未能核验会员发布内容的真实性及有效性,不为其负责,如有虚假或违规内容敬请准备材料图片发邮件到info@n360.cn举报,本站核实后积极配合删除。
4、如果您发现网站上有侵犯您的知识产权的作品,请与我们取得联系,我们会及时处理或删除。
 
打赏
 
更多>同类网站技术
0相关评论

推荐图文
推荐网站技术
点击排行
网站首页  |  关于我们  |  联系方式  |  使用协议  |  免责声明  |  版权隐私  |  信息发布规则  |  网站地图  |  排名推广  |  广告服务  |  积分换礼  |  网站留言  |  RSS订阅  |  违规举报  |  粤ICP备2020081222号
Powered By DESTOON