Space occupied by the Oracle query table (table size)


Space occupied by the Oracle query table (table size)

1. Method 1: Use the object_space_usage function of the dbms_space package to check the size of the table.

On SQL:

DECLARE
  su NUMBER;
  sa NUMBER;
  cp NUMBER;
BEGIN
  dbms_space.object_space_usage('LOG'
                               ,'BIG_TABLE'
                               ,'TABLE'
                               ,NULL
                               ,su
                               ,sa
                               ,cp);
  dbms_output.put_line('Space Used: ' || to_char(su));
  dbms_output.put_line('Space Allocated: ' || to_char(sa));
  dbms_output.put_line('Chained Percentage: ' || to_char(cp));
END;

Output result:
insert image description here
insert image description here
insert image description here

2. Method 2: Check the dba_extents view.

On SQL:

SELECT segment_name "表名",
       segment_type "对象类型",
       sum(bytes) / 1024 / 1024 "占用空间(MB)"
  FROM dba_extents
 WHERE 1=1
   -- AND segment_name = '表名'
 GROUP BY segment_name, segment_type
 ORDER BY "占用空间(MB)" DESC;

insert image description here

3. Method 3: Check the dba_segments view.

On SQL:

SELECT owner,
       segment_name,
       segment_type,
       sum(bytes) / 1024 / 1024 "占用空间(MB)"
  FROM dba_segments
 WHERE 1=1
    -- AND owner = '表所有者'
 GROUP BY owner, segment_name, segment_type
 ORDER BY "占用空间(MB)" DESC;

insert image description here

Guess you like

Origin blog.csdn.net/tttzzzqqq2018/article/details/132255487