0_delete_redundance_data.sql 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. -- 迁移前先清除冗余数据
  2. -- 需求场景:按站点迁移一个节点,须保留的站点id人工整理
  3. DELETE from wcmwebsite where siteid not in (124,120,66,108,35,52,101,91,76,88,184,195,188,177,194,193,187,190,183,186,191,189,175,176,180,179,174,169,130,166,165,164,199,198,197,173,182,155,171,196);
  4. -- 删除多余栏目
  5. DELETE from wcmchannel where siteId not in (SELECT siteId from wcmwebsite) or status < 0;
  6. -- 栏目模板触发发布关联关系
  7. DELETE from wcmchannelchildindexquote where FOLDERID not in (SELECT siteId from wcmwebsite) and FOLDERTYPE = 103;
  8. DELETE from wcmchannelchildindexquote where FOLDERID not in (SELECT channelId from wcmchannel) and FOLDERTYPE = 101;
  9. -- 栏目模板触发发布关联关系(似乎多余)
  10. DELETE from wcmchannelchildindexquote where TEMPLATEID not in (SELECT TEMPID from wcmtemplate);
  11. -- 文档分发关系
  12. DELETE from wcmchannelsyn where srcchannel not in (SELECT channelId from wcmchannel);
  13. DELETE from wcmchannelsyn where tochannel not in (SELECT channelId from wcmchannel);
  14. -- 存放路径
  15. DELETE from wcmfolderpublishconfig where FOLDERID not in (SELECT channelId from wcmchannel) and FOLDERTYPE = 101;
  16. DELETE from wcmfolderpublishconfig where FOLDERID not in (SELECT siteId from wcmwebsite) and FOLDERTYPE = 103;
  17. -- 多余模板
  18. DELETE from wcmtemplate where rootid <> 0 and rootid not in (SELECT siteId from wcmwebsite);
  19. -- 模板变量
  20. DELETE from wcmtemplateargument where TEMPLATEID not in (SELECT TEMPID from wcmtemplate);
  21. -- 模板栏目绑定关系
  22. DELETE from wcmtemplateemploy where EMPLOYERID not in (SELECT CHANNELID from wcmchannel) and EMPLOYERTYPE = 101;
  23. DELETE from wcmtemplateemploy where EMPLOYERID not in (SELECT siteId from wcmwebsite) and EMPLOYERTYPE = 103;
  24. DELETE from wcmtemplateemploy where TEMPLATEID not in (SELECT TEMPID from wcmtemplate);
  25. -- 嵌套模板信息
  26. DELETE from wcmtemplatenest where templateId not in (SELECT TEMPID from wcmtemplate);
  27. DELETE from wcmtemplatenest where nestedtemplateId not in (SELECT TEMPID from wcmtemplate);
  28. -- 模板引用信息
  29. DELETE from wcmtemplatequote where templateId not in (SELECT TEMPID from wcmtemplate);
  30. DELETE from wcmtemplatequote where quotedFolderId not in (SELECT CHANNELID from wcmchannel) and quotedFolderType = 101;
  31. DELETE from wcmtemplatequote where quotedFolderId not in (SELECT siteId from wcmwebsite) and quotedFolderType = 103;
  32. -- 栏目绑定的视图
  33. DELETE from xwcmmetaviewemployer where CHANNELID not in (SELECT CHANNELID from wcmchannel);
  34. -- 视图信息
  35. DELETE from xwcmviewinfo where VIEWINFOID not in (SELECT VIEWID from xwcmmetaviewemployer);
  36. -- 视图字段信息
  37. DELETE from xwcmviewfieldinfo where VIEWID not in (SELECT viewinfoid from xwcmviewinfo);
  38. DELETE from xwcmmetaviewfieldgroup where metaviewid not in (SELECT viewinfoid from xwcmviewinfo);
  39. -- 元数据表信息
  40. DELETE from xwcmtableinfo where TABLEINFOID not in (SELECT MAINTABLEID from xwcmviewinfo);
  41. DELETE from xwcmdbfieldinfo where TABLEID not in (SELECT TABLEINFOID from xwcmtableinfo);
  42. -- --------数据记录
  43. -- chnldoc记录
  44. DELETE from wcmchnldoc where CHNLID not in (SELECT CHANNELID from wcmchannel);
  45. -- 时间: 609.133s
  46. -- document
  47. DELETE from wcmdocument where docchannel not in (SELECT CHANNELID from wcmchannel);
  48. -- 时间: 1295.934s
  49. -- metatable如何清理?