четверг, 3 мая 2018 г.

Getting information about table size, lob segment and lob index segment size which belongs to table

  1. set linesize 256
  2. col owner for a30
  3. col table_name for a30
  4. col segment_name for a90
  5. col LOB_SECURED for a11
  6. col LOB_COMPRESSION for a15
  7. with t_tab as (
  8. select -- Information about table size
  9. t.OWNER,
  10. t.TABLE_NAME,
  11. t.COMPRESSION as TABLE_COMPRESSION,
  12. t.COMPRESS_FOR as TABLE_COMPRESS_FOR
  13. from DBA_TABLES t
  14. where 1 = 1
  15. and t.TABLE_NAME = NVL(UPPER('&s_table_name'), t.TABLE_NAME)
  16. and t.OWNER = NVL(UPPER('&s_owner'), t.OWNER)
  17. and t.OWNER not in ('SYS', 'SYSTEM', 'SYSMAN', 'CTXSYS', 'XDB')
  18. )
  19. select -- Information about table size
  20. t.OWNER,
  21. t.TABLE_NAME,
  22. t.TABLE_COMPRESSION,
  23. t.TABLE_COMPRESS_FOR,
  24. ts.SEGMENT_NAME as SEGMENT_NAME,
  25. cast(null as varchar2(30)) as LOB_SECURED,
  26. cast(null as varchar2(30)) as LOB_COMPRESSION,
  27. ROUND(ts.bytes/(1024*1024),2) SPACE_ALOCATED_MB
  28. from t_tab t
  29. join DBA_SEGMENTS ts
  30. on ts.SEGMENT_NAME = t.TABLE_NAME
  31. where 1 = 1
  32. union all
  33. select -- Information about lob columns size for table
  34. t.OWNER,
  35. t.TABLE_NAME,
  36. t.TABLE_COMPRESSION,
  37. t.TABLE_COMPRESS_FOR,
  38. ls.segment_type || ' "' || dl.segment_name || '" for table "' || dl.table_name || '"' as SEGMENT_NAME,
  39. dl.securefile as LOB_SECURED,
  40. dl.compression as LOB_COMPRESSION,
  41. ROUND(ls.bytes/(1024*1024),2) SPACE_ALOCATED_MB
  42. from t_tab t
  43. join DBA_LOBS dl
  44. on dl.table_name = t.TABLE_NAME
  45. join DBA_SEGMENTS ls
  46. on ls.SEGMENT_NAME = dl.segment_name
  47. where 1 = 1
  48. union all
  49. select -- Information about lob index for lob column
  50. t.OWNER,
  51. t.TABLE_NAME,
  52. t.TABLE_COMPRESSION,
  53. t.TABLE_COMPRESS_FOR,
  54. lis.segment_type || ' "' || dl.index_name || '" for LOBSEGMENT "' || dl.segment_name || '"' as SEGMENT_NAME,
  55. dl.securefile as LOB_SECURED,
  56. dl.compression as LOB_COMPRESSION,
  57. ROUND(lis.bytes/(1024*1024),2) SPACE_ALOCATED_MB
  58. from t_tab t
  59. join DBA_LOBS dl
  60. on dl.table_name = t.TABLE_NAME
  61. join DBA_SEGMENTS lis
  62. on lis.SEGMENT_NAME = dl.index_name
  63. where 1 = 1
  64. ORDER BY SPACE_ALOCATED_MB desc, OWNER, TABLE_NAME, SEGMENT_NAME
  65. ;

Комментариев нет:

Отправить комментарий