01_backup.sql 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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=PMS_TEST;
  6. declare
  7. v_count number;
  8. begin
  9. select count(*)
  10. into v_count
  11. from all_tables
  12. where owner = 'PMS_TEST'
  13. and table_name = 'PMS_FJYRJC_GRCD_BAK_20261119';
  14. if v_count = 0 then
  15. execute immediate
  16. 'create table PMS_TEST.PMS_FJYRJC_GRCD_BAK_20261119 as '
  17. || 'select * from PMS_TEST.GRCD where SJGRCDID = 1025885';
  18. end if;
  19. select count(*)
  20. into v_count
  21. from all_tables
  22. where owner = 'PMS_TEST'
  23. and table_name = 'PMS_FJYRJC_GW_BAK_20261119';
  24. if v_count = 0 then
  25. execute immediate
  26. 'create table PMS_TEST.PMS_FJYRJC_GW_BAK_20261119 as '
  27. || 'select * from PMS_TEST.GW where GWID in (102121, 1015484)';
  28. end if;
  29. end;
  30. /
  31. select 'GRCD' source,count(*) row_count from PMS_TEST.PMS_FJYRJC_GRCD_BAK_20261119
  32. union all
  33. select 'GW',count(*) from PMS_TEST.PMS_FJYRJC_GW_BAK_20261119;
  34. exit