11_backup_prod.sql 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. set define off
  2. set echo on
  3. whenever sqlerror exit sql.sqlcode
  4. alter session set container=ORCLPDB;
  5. alter session set current_schema=C##DC;
  6. declare
  7. v_count number;
  8. begin
  9. select count(*) into v_count from all_tables
  10. where owner='C##DC' and table_name='PMS_FJYRJC_CSSG1_GRJJ_BAK_20261119';
  11. if v_count = 0 then
  12. execute immediate 'create table "C##DC".PMS_FJYRJC_CSSG1_GRJJ_BAK_20261119 as '
  13. || 'select * from "C##DC".GRJJ where YYRYID=111157142';
  14. end if;
  15. select count(*) into v_count from all_tables
  16. where owner='C##DC' and table_name='PMS_FJYRJC_CSSG1_GRJJ_TEMPLATE_BAK_20261119';
  17. if v_count = 0 then
  18. execute immediate 'create table "C##DC".PMS_FJYRJC_CSSG1_GRJJ_TEMPLATE_BAK_20261119 as '
  19. || 'select * from "C##DC".GRJJ where GRJJMBID=10523';
  20. end if;
  21. select count(*) into v_count from all_tables
  22. where owner='C##DC' and table_name='PMS_FJYRJC_CSSG1_QZ_BAK_20261119';
  23. if v_count = 0 then
  24. execute immediate 'create table "C##DC".PMS_FJYRJC_CSSG1_QZ_BAK_20261119 as '
  25. || 'select * from "C##DC".QZ where YYRYID=111157142 or MC=''cssg1-风纪仪容检查授权''';
  26. end if;
  27. select count(*) into v_count from all_tables
  28. where owner='C##DC' and table_name='PMS_FJYRJC_CSSG1_QZCY_BAK_20261119';
  29. if v_count = 0 then
  30. execute immediate 'create table "C##DC".PMS_FJYRJC_CSSG1_QZCY_BAK_20261119 as '
  31. || 'select qc.* from "C##DC".QZCY qc join "C##DC".QZ q on q.QZID=qc.QZID '
  32. || 'where q.YYRYID=111157142 or q.MC=''cssg1-风纪仪容检查授权''';
  33. end if;
  34. select count(*) into v_count from all_tables
  35. where owner='C##DC' and table_name='PMS_FJYRJC_CSSG1_CREATED_20261119';
  36. if v_count = 0 then
  37. execute immediate 'create table "C##DC".PMS_FJYRJC_CSSG1_CREATED_20261119 '
  38. || '(GRJJID number, QZID number, QZCYID number, CREATED_AT timestamp)';
  39. end if;
  40. end;
  41. /
  42. select 'GRJJ_PERSONAL' source,count(*) row_count from PMS_FJYRJC_CSSG1_GRJJ_BAK_20261119
  43. union all
  44. select 'GRJJ_TEMPLATE',count(*) from PMS_FJYRJC_CSSG1_GRJJ_TEMPLATE_BAK_20261119
  45. union all
  46. select 'QZ',count(*) from PMS_FJYRJC_CSSG1_QZ_BAK_20261119
  47. union all
  48. select 'QZCY',count(*) from PMS_FJYRJC_CSSG1_QZCY_BAK_20261119;
  49. exit