SQL 23
BC Clean sysaux freepdb1 By allan on 18th December 2025 11:46:56 AM
  1. SET linesize 120
  2. SET pagesize 100
  3. col ash form a30
  4. col retention form a30
  5. col snap form a30
  6.  
  7. COLUMN "Item" FORMAT A25
  8. COLUMN "Space Used (GB)" FORMAT 999.99
  9. COLUMN "Schema" FORMAT A25
  10. COLUMN "Move Procedure" FORMAT A40
  11.  
  12. SELECT  occupant_name "Item",
  13. space_usage_kbytes/1048576 "Space Used (GB)",
  14. schema_name "Schema",
  15. move_procedure "Move Procedure"
  16. FROM v$sysaux_occupants
  17. WHERE occupant_name = 'SM/AWR'
  18. ORDER BY 1
  19. /
  20.  
  21. SELECT 'alter index '||segment_name||' rebuild online parallel (degree 4);'
  22. FROM dba_segments
  23. WHERE tablespace_name= 'SYSAUX'
  24. AND segment_name LIKE 'WRH$_%'
  25. AND segment_type='INDEX'
  26. ORDER BY segment_name;
  27.  
  28. /
  29.  
  30. --- Move SYSAUX WRH$_% tables to reclaim space
  31. SELECT 'exec dbms_pdb.exec_as_oracle_script(''alter table '||segment_name||' move tablespace sysaux'');'
  32. FROM dba_segments
  33. WHERE tablespace_name= 'SYSAUX'
  34. AND segment_name LIKE 'WRH$_%'
  35. AND segment_type = 'TABLE'  
  36. ORDER BY segment_name;
  37.  
  38. /
  39.  
  40. SELECT TABLE_NAME, COUNT(*)
  41. FROM dba_tab_partitions
  42. WHERE TABLE_NAME LIKE 'WRH$%'
  43. AND table_owner = 'SYS'
  44. GROUP BY TABLE_NAME
  45. ORDER BY 1;
  46.  
  47. /
  48.  
  49. BEGIN
  50.  EXECUTE IMMEDIATE 'alter session set "_swrf_test_action" = 72';
  51. END;
  52. /
  53.  
  54. SELECT MIN(sample_id), MAX(sample_id)
  55. FROM sys.wrh$_active_session_history;
  56. -- 80381470007  81701088731
  57.  
  58. EXEC dbms_workload_repository.drop_snapshot_range(low_snap_id=>80381470007, high_snap_id=>81701088731);
  59. /

Paste is for source code and general debugging text.

Login or Register to edit, delete and keep track of your pastes and more.

Raw Paste

Login or Register to edit or fork this paste. It's free.