Dba owner to tablespace

De wiki.nexiat.fr
Aller à la navigation Aller à la recherche
Fiche express
Type Script SQL*Plus de diagnostic
Domaine Administration (segments / stockage)
Voir aussi Dba highwater mark · Dba object summary

Dba owner to tablespace résume, pour chaque propriétaire, la répartition des segments (tables, index, LOB...) entre tablespaces : nombre de segments et volume occupé, groupés par type de segment.

Vue d'ensemble utile pour répondre à des questions comme "combien d'espace APP_OWNER occupe-t-il, et dans quels tablespaces" — sans avoir à interroger tablespace par tablespace.

Script

SET TERMOUT OFF
COLUMN current_instance NEW_VALUE current_instance NOPRINT
SELECT RPAD(instance_name, 17) current_instance FROM v$instance;
SET TERMOUT ON

PROMPT
PROMPT +------------------------------------------------------------------------+
PROMPT | Report   : Owner to Tablespace Report                                  |
PROMPT | Instance : &current_instance                                          |
PROMPT +------------------------------------------------------------------------+

SET ECHO      OFF
SET FEEDBACK  6
SET HEADING   ON
SET LINESIZE  180
SET PAGESIZE  50000
SET VERIFY    OFF

COLUMN owner           FORMAT a20               HEADING "Owner"
COLUMN tablespace_name FORMAT a30               HEADING "Tablespace Name"
COLUMN segment_type    FORMAT a18               HEADING "Segment Type"
COLUMN bytes           FORMAT 9,999,999,999,999 HEADING "Size (in Bytes)"
COLUMN seg_count       FORMAT 9,999,999,999     HEADING "Segment Count"

BREAK ON report ON owner SKIP 2

COMPUTE sum LABEL ""               OF seg_count bytes ON owner
COMPUTE sum LABEL "Grand Total: "  OF seg_count bytes ON report

SELECT
    owner
  , tablespace_name
  , segment_type
  , SUM(bytes) bytes
  , COUNT(*)   seg_count
FROM dba_segments
GROUP BY owner, tablespace_name, segment_type
ORDER BY owner, tablespace_name, segment_type
/

Colonnes / sortie

  • Owner — propriétaire des segments.
  • Tablespace Name — tablespace où résident ces segments.
  • Segment Type — type (TABLE, INDEX, LOBSEGMENT, LOBINDEX...).
  • Size (in Bytes) — volume total occupé, avec sous-total par propriétaire et total général.
  • Segment Count — nombre de segments concernés.

Comme pour Dba highwater mark, ces chiffres reflètent l'espace alloué (jusqu'au HWM), pas l'espace réellement utile aux données — un owner peut apparaître ici avec un volume important simplement parce que ses tables n'ont jamais été réorganisées après des suppressions massives.

Voir aussi

  • Dba highwater mark — comprendre pourquoi l'espace alloué peut dépasser largement l'espace réellement utile
  • Dba object summary — même logique de regroupement par owner, côté nombre d'objets plutôt que volume