Dbms_space.space_usage

Hi,
I have installed Oracle 10g R2 on Win XP. Should I do something to be able to use dbms_space.space_usage package ?
Many thanks before.

Hi,
Well, take a look:
SYS@ORACLE10>  declare
  2   l_fs1_bytes number;
  3   l_fs2_bytes number;
  4   l_fs3_bytes number;
  5   l_fs4_bytes number;
  6   l_fs1_blocks number;
  7   l_fs2_blocks number;
  8   l_fs3_blocks number;
  9   l_fs4_blocks number;
10   l_full_bytes number;
11   l_full_blocks number;
12   l_unformatted_bytes number;
13   l_unformatted_blocks number;
14   begin
15   dbms_space.space_usage(
16   segment_owner => 'USER1',
17   segment_name => 'EMP',
18   segment_type => 'TABLE',
19   fs1_bytes => l_fs1_bytes,
20   fs1_blocks => l_fs1_blocks,
21   fs2_bytes => l_fs2_bytes,
22   fs2_blocks => l_fs2_blocks,
23   fs3_bytes => l_fs3_bytes,
24   fs3_blocks => l_fs3_blocks,
25   fs4_bytes => l_fs4_bytes,
26   fs4_blocks => l_fs4_blocks,
27   full_bytes => l_full_bytes,
28   full_blocks => l_full_blocks,
29   unformatted_blocks => l_unformatted_blocks,
30   unformatted_bytes => l_unformatted_bytes
31   );
32   dbms_output.put_line(' FS1 Blocks = '||l_fs1_blocks||' Bytes = '||l_fs1_bytes);
33   dbms_output.put_line(' FS2 Blocks = '||l_fs2_blocks||' Bytes = '||l_fs2_bytes);
34   dbms_output.put_line(' FS3 Blocks = '||l_fs3_blocks||' Bytes = '||l_fs3_bytes);
35   dbms_output.put_line(' FS4 Blocks = '||l_fs4_blocks||' Bytes = '||l_fs4_bytes);
36   dbms_output.put_line('Full Blocks = '||l_full_blocks||' Bytes = '||l_full_bytes);
37   end;
38  /
PL/SQL procedure successfully completed.
SYS@ORACLE10> set serveroutput on
SYS@ORACLE10> /
FS1 Blocks = 0 Bytes = 0
FS2 Blocks = 1 Bytes = 8192
FS3 Blocks = 0 Bytes = 0
FS4 Blocks = 4 Bytes = 32768
Full Blocks = 0 Bytes = 0
PL/SQL procedure successfully completed.Cheers

Similar Messages

  • Using DBMS_SPACE.SPACE_USAGE

    I have a partitioned table that contain one SECUREFILE column (Oracle 11.2.0.2 Linux 64bit).
    I would like to check its space usage in order to check if the compression and deduplication will help us to reduce the CLOB column's size.
    I've found the following note in metalink: How to Check Space Occupied by LOB Compression
    https://support.oracle.com/CSP/main/article?cmd=show&type=NOT&id=861344.1
    However, this link is refered to a regular table, not partitioned.
    I've seen in the documentation of DBMS_SPACE.SPACE_USAGE that there is a partition name attribute, but I'm not seem to use the procedure correctly.
    I'm trying to run the following code:
    DECLARE
    l_segment_size_blocks NUMBER;
    l_segment_size_bytes NUMBER;
    l_used_blocks NUMBER;
    l_used_bytes NUMBER;
    l_expired_blocks NUMBER;
    l_expired_bytes NUMBER;
    l_unexpired_blocks NUMBER;
    l_unexpired_bytes NUMBER;
    v_segname varchar2(30);
    BEGIN
    DBMS_SPACE.SPACE_USAGE(
    segment_owner => 'LOG',
    partition_name =>'PART_03_2009',
    segment_name => ' [https://support.oracle.com/CSP/main/article?cmd=show&type=NOT&id=861344.1|https://support.oracle.com/CSP/main/article?cmd=show&type=NOT&id=861344.1] SECURITY_LOG',
    segment_type => 'TABLE PARTITION',
    segment_size_blocks => l_segment_size_blocks,
    segment_size_bytes => l_segment_size_bytes,
    used_blocks => l_used_blocks,
    used_bytes => l_used_bytes,
    expired_blocks => l_expired_blocks,
    expired_bytes => l_expired_bytes,
    unexpired_blocks => l_unexpired_blocks,
    unexpired_bytes => l_unexpired_bytes
    DBMS_OUTPUT.ENABLE;
    DBMS_OUTPUT.PUT_LINE(' Segment Blocks = '||l_segment_size_blocks||' Bytes = '||l_segment_size_bytes);
    DBMS_OUTPUT.PUT_LINE(' Used Blocks = '||l_used_blocks||' Bytes = '||l_used_bytes);
    DBMS_OUTPUT.PUT_LINE(' Expired Blocks = '||l_expired_blocks||' Bytes = '||l_expired_bytes);
    DBMS_OUTPUT.PUT_LINE(' Unexpired Blocks = '||l_unexpired_blocks||' Bytes = '||l_unexpired_bytes);
    DBMS_OUTPUT.PUT_LINE('=============================================');
    END;
    And I get this error : ORA-03213: Invalid Lob Segment name for DBMS_SPACE package
    Some information
    select partition_name, interval, num_rows
    from dba_tab_partitions where table_owner = 'LOG'
    order by partition_position;
    1     PART_03_2009     NO     1235667
    2     PART_04_2009     NO     4621135
    3     PART_05_2009     NO     1322246
    4     PART_06_2009     NO     6442123
    SELECT segment_name, partition_name, segment_type
    FROM DBA_SEGMENTS
    WHERE OWNER = 'LOG'
    and segment_type in ('TABLE PARTITION','LOB PARTITION')
    order by 2;
    SECURITY_LOG                    PART_03_2009     TABLE PARTITION
    SECURITY_LOG                    PART_04_2009     TABLE PARTITION
    SECURITY_LOG                    PART_05_2009     TABLE PARTITION
    SECURITY_LOG                    PART_06_2009     TABLE PARTITION
    SYS_LOB0000048317C00014$$     SYS_LOB_P495     LOB PARTITION
    SYS_LOB0000048317C00014$$     SYS_LOB_P498     LOB PARTITION
    SYS_LOB0000048317C00014$$     SYS_LOB_P519     LOB PARTITION
    SYS_LOB0000048317C00014$$     SYS_LOB_P523     LOB PARTITION
    What am I doing wrong ? What should I change?
    Thanks in advance,
    Roni.

    Thank you for your link.
    I understood from Kyte's example how to use it and now it works.
    I used the table name and partition name of the table instead of the lob segment name and the lob segment partition name.
    Can you please tell me if there is a query that correlates between the lob segment partition name and the table partition name?
    I would like to know what is the lob segment partition name of the table partition 'PART_03_2009' (or what is the table partition name of lob segment partition SYS_LOB_P495) and so on.
    In the DBA_SEGMENTS I didn't find any fields that can help me connect between the two.
    Information from DBA_SEGMENTS
    SELECT segment_name, partition_name, segment_type
    FROM DBA_SEGMENTS
    WHERE OWNER = 'LOG'
    and segment_type in ('TABLE PARTITION','LOB PARTITION')
    order by 2;
    SECURITY_LOG     PART_03_2009     TABLE PARTITION
    SECURITY_LOG     PART_04_2009     TABLE PARTITION
    SECURITY_LOG     PART_05_2009     TABLE PARTITION
    SECURITY_LOG     PART_06_2009     TABLE PARTITION
    SYS_LOB0000048317C00014$$     SYS_LOB_P495     LOB PARTITION
    SYS_LOB0000048317C00014$$     SYS_LOB_P498     LOB PARTITION
    SYS_LOB0000048317C00014$$     SYS_LOB_P519     LOB PARTITION
    SYS_LOB0000048317C00014$$     SYS_LOB_P523     LOB PARTITION
    This anonymous block worked:*
    DECLARE
    l_segment_size_blocks NUMBER;
    l_segment_size_bytes NUMBER;
    l_used_blocks NUMBER;
    l_used_bytes NUMBER;
    l_expired_blocks NUMBER;
    l_expired_bytes NUMBER;
    l_unexpired_blocks NUMBER;
    l_unexpired_bytes NUMBER;
    v_segname varchar2(30);
    BEGIN
    DBMS_SPACE.SPACE_USAGE(
    segment_owner => 'LOG',
    partition_name =>'*SYS_LOB_P495*',
    segment_name => '*SYS_LOB0000048317C00014$$*',
    segment_type => 'LOB PARTITION',
    segment_size_blocks => l_segment_size_blocks,
    segment_size_bytes => l_segment_size_bytes,
    used_blocks => l_used_blocks,
    used_bytes => l_used_bytes,
    expired_blocks => l_expired_blocks,
    expired_bytes => l_expired_bytes,
    unexpired_blocks => l_unexpired_blocks,
    unexpired_bytes => l_unexpired_bytes
    DBMS_OUTPUT.ENABLE;
    DBMS_OUTPUT.PUT_LINE(' Segment Blocks = '||l_segment_size_blocks||' Bytes = '||l_segment_size_bytes);
    DBMS_OUTPUT.PUT_LINE(' Used Blocks = '||l_used_blocks||' Bytes = '||l_used_bytes);
    DBMS_OUTPUT.PUT_LINE(' Expired Blocks = '||l_expired_blocks||' Bytes = '||l_expired_bytes);
    DBMS_OUTPUT.PUT_LINE(' Unexpired Blocks = '||l_unexpired_blocks||' Bytes = '||l_unexpired_bytes);
    DBMS_OUTPUT.PUT_LINE('=============================================');
    END;
    /

  • Example about dbms_space.space_usage displays an error....

    Hi ,
    I try to execute the following anonymous block (as user sys) contained in the
    Oracle® Database PL/SQL Packages and Types Reference
    10g Release 2 (10.2)
    Part Number B14258-01
    The anonynous block is as follows....
    SQL> variable unf number;
    SQL> variable unfb number;
    SQL> variable fs1 number;
    SQL> variable fs1b number;
    SQL> variable fs2 number;
    SQL> variable fs2b number;
    SQL> variable fs3 number;
    SQL> variable fs3b number;
    SQL> variable fs4 number;
    SQL> variable fs4b number;
    SQL> variable full number;
    SQL> variable fullb number;
    SQL>
    SQL> begin
      2  dbms_space.space_usage('U1','T',
      3                          'TABLE',
      4                          :unf, :unfb,
      5                          :fs1, :fs1b,
      6                          :fs2, :fs2b,
      7                          :fs3, :fs3b,
      8                          :fs4, :fs4b,
      9                          :full, :fullb);
    10  end;
    11  /
    begin
    *ERROR in line 1
    ORA-00942 : table or view does not existWhat object may be missing.....????
    I have created the database using DBCA 10g......
    Thanks....
    Sim

    I cannot reproduce this issue with 10.2.0.2 (db also created with DBCA):
    SQL> show user
    USER est "SYS"
    SQL> desc test.t;
    Nom                                       NULL ?   Type
    X                                                  NUMBER(38)
    SQL> select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - Prod
    PL/SQL Release 10.2.0.2.0 - Production
    CORE    10.2.0.2.0      Production
    TNS for Linux: Version 10.2.0.2.0 - Production
    NLSRTL Version 10.2.0.2.0 - Production
    SQL> variable unf number;
    SQL> variable unfb number;
    SQL> variable fs1 number;
    SQL> variable fs1b number;
    SQL> variable fs2 number;
    SQL> variable fs2b number;
    SQL> variable fs3 number;
    SQL> variable fs3b number;
    SQL> variable fs4 number;
    SQL> variable fs4b number;
    SQL> variable full number;
    SQL> variable fullb number;
    SQL>
    SQL> begin
      2    dbms_space.space_usage('TEST','T',
      3                            'TABLE',
      4                            :unf, :unfb,
      5                            :fs1, :fs1b,
      6                            :fs2, :fs2b,
      7                            :fs3, :fs3b,
      8                            :fs4, :fs4b,
      9                            :full, :fullb);
    10    end;
    11  /
    Procedure PL/SQL terminee avec succes.It's not a role/ PL/SQL problem.
    Message was edited by:
    Pierre Forstmann

  • Pls help abt dbms_space.space_usage

    SQL> declare
    2
    3 l_fs1_bytes number;
    4 l_fs2_bytes number;
    5 l_fs3_bytes number;
    6 l_fs4_bytes number;
    7 l_fs1_blocks number;
    8 l_fs2_blocks number;
    9 l_fs3_blocks number;
    10 l_fs4_blocks number;
    11 l_full_bytes number;
    12 l_full_blocks number;
    13 l_unformatted_bytes number;
    14 l_unformatted_blocks number;
    15 begin
    16 dbms_space.space_usage(
    17 segment_owner => 'TEST',
    18 segment_name => 'EDGE_REQ_LOG',
    19 segment_type => 'TABLE',
    20 fs1_bytes => l_fs1_bytes,
    21 fs1_blocks => l_fs1_blocks,
    22 fs2_bytes => l_fs2_bytes,
    23 fs2_blocks => l_fs2_blocks,
    24 fs3_bytes => l_fs3_bytes,
    25 fs3_blocks => l_fs3_blocks,
    26 fs4_bytes => l_fs4_bytes,
    27 fs4_blocks => l_fs4_blocks,
    28 full_bytes => l_full_bytes,
    29 full_blocks => l_full_blocks,
    30 unformatted_blocks => l_unformatted_blocks,
    31 unformatted_bytes => l_unformatted_bytes
    32 );
    33 dbms_output.put_line(' FS1 Blocks = '||l_fs1_blocks||' Bytes = '||l_fs1_bytes);
    34 dbms_output.put_line(' FS2 Blocks = '||l_fs2_blocks||' Bytes = '||l_fs2_bytes);
    35 dbms_output.put_line(' FS3 Blocks = '||l_fs3_blocks||' Bytes = '||l_fs3_bytes);
    36 dbms_output.put_line(' FS4 Blocks = '||l_fs4_blocks||' Bytes = '||l_fs4_bytes);
    37 dbms_output.put_line('Full Blocks = '||l_full_blocks||' Bytes = '||l_full_bytes
    38 end;
    39 /
    PL/SQL procedure successfully completed.
    SQL> set serveroutput on
    SQL> /
    FS1 Blocks = 1 Bytes = 8192
    FS2 Blocks = 0 Bytes = 0
    FS3 Blocks = 0 Bytes = 0
    FS4 Blocks = 169 Bytes = 1384448
    Full Blocks = 22291 Bytes = 182607872
    PL/SQL procedure successfully completed.
    pls. help and tell me what the meaning of FS1,FS2,FS3,FS4 and Full Blocks rows
    Regards

    you'll find a good description and more here:http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_space.htm#CACIGFDB
    It is the docu: PL/SQL Packages and Types Reference
    regards
    Roman

  • Problem in SPACE_USAGE Procedure

    1 begin
    2 dbms_space.space_usage('LIVE', 'OE_PAYMENTS','OE_PAYMENTS_7', 'TABLE PARTITION',
    3 :unf, :unfb,
    4 :fs1, :fs1b,
    5 :fs2, :fs2b,
    6 :fs3, :fs3b,
    7 :fs4, :fs4b,
    8 :full, :fullb);
    9* end;
    dbms_space.space_usage('LIVE', 'OE_PAYMENTS','OE_PAYMENTS_7', 'TABLE PARTITION',
    ERROR at line 2:
    ORA-06550: line 2, column 61:
    PLS-00363: expression 'TABLE PARTITION' cannot be used as an assignment target
    ORA-06550: line 2, column 1:
    PL/SQL: Statement ignored
    OWNER SEGMENT_NAME PARTITION_NAME SEGMENT_TYPE
    LIVE OE_PAYMENTS OE_PAYMENTS_P7 TABLE PARTITION
    Ref Doc
    http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_space.htm#ARPLS056
    Any Help?
    Adith

    I think the parameters have got messed up.
    First three parameters for SPACE_USAGE are
    segment_owner IN VARCHAR2,
    segment_name IN VARCHAR2,
    segment_type IN VARCHAR2,
    and last parameter is
    partition_name IN VARCHAR2 DEFAULT NULL
    Whereas the table documenting the parameters for space_usage as combined IN parameters and OUT parameters.
    You might want to scope out the input parameters using =>.
    F.Ex. Partition_name=>'OE_PAYMENTS_7'

  • Procedure uses DBMS_SPACE error

    Hi ,
    I use this Stored Procedure with DBMS_SPACE.SPACE_USAGE
    ( p_owner in varchar2,
    p_name in varchar2,
    p_type in varchar2 default 'TABLE' )
    AS
    l_unformatted_blocks number;
    l_unformatted_bytes number;
    l_fs1_blocks number;
    l_fs1_bytes number;
    l_fs2_blocks number;
    l_fs2_bytes number;
    l_fs3_blocks number;
    l_fs3_bytes number;
    l_fs4_blocks number;
    l_fs4_bytes number;
    l_full_blocks number;
    l_full_bytes number;
    PROCEDURE p( p_label in varchar2, p_num in number )
    IS
    BEGIN
    dbms_output.put_line( rpad(p_label,50,'.') || p_num);
    END;
    BEGIN
    dbms_space.space_usage
    ( segment_owner => p_owner,
    segment_name => p_name,
    segment_type => p_type,
    unformatted_blocks => l_unformatted_blocks,
    unformatted_bytes => l_unformatted_bytes,
    fs1_blocks => l_fs1_blocks,
    fs1_bytes => l_fs1_bytes,
    fs2_blocks => l_fs2_blocks,
    fs2_bytes => l_fs2_bytes,
    fs3_blocks => l_fs3_blocks,
    fs3_bytes => l_fs3_bytes,
    fs4_blocks => l_fs4_blocks,
    fs4_bytes => l_fs4_bytes,
    full_blocks => l_full_blocks,
    full_bytes => l_full_bytes );
    p( 'Unformatted Blocks', l_unformatted_blocks);
    p( 'Unformatted Bytes',l_unformatted_bytes);
    p( 'FS1 Blocks',l_fs1_blocks);
    p( 'FS1 Bytes',l_fs1_bytes);
    P( 'FS2 Blocks',l_fs2_blocks);
    P( 'FS2 Bytes',l_fs2_bytes);
    P( 'FS3 Blocks',l_fs3_blocks);
    P( 'FS3 Bytes',l_fs3_bytes);
    p( 'FS4 Blocks',l_fs4_blocks);
    p( 'FS4 Bytes',l_fs4_bytes);
    P( 'Full Blocks',l_full_blocks);
    P( 'Full Bytes',l_full_bytes);
    END;
    When I run the Procedure one time it works after that occurs the error:
    SQL> show user
    USER ist "HR"
    exec show_used('HR','RACF','TABLE');
    FEHLER in Zeile 1:
    ORA-10614: Operation not allowed on this segment
    ORA-06512: in "SYS.DBMS_SPACE", Zeile 97
    ORA-06512: in "JOEFISH.SHOW_USED", Zeile 23
    ORA-06512: in Zeile 1
    Can anyone help?
    Regards
    MArcel

    ORA-10614:     Operation not allowed on this segment
    Cause:     This procedure can be used only on segments in tablespaces with AUTO SEGMENT SPACE MANAGEMENT.
    Action:     Recheck the segment name and type and re-issue the statement.
    Bye, Aron

  • DBMS_SPACE works in 10g not in 11g

    Hi,
    I have a code that uses DBMS_SPACE that works in Oracle 10g but not in 11g.
    Any clarification is appreciated.
    SQL> select * from v$version ;
    BANNER
    Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
    PL/SQL Release 11.1.0.6.0 - Production
    CORE    11.1.0.6.0      Production
    TNS for 32-bit Windows: Version 11.1.0.6.0 - Production
    NLSRTL Version 11.1.0.6.0 - Production
    SQL>
      1  declare
      2   -- IN vars
      3   v_segment_owner VARCHAR2(100):='HR';
      4   v_segment_name VARCHAR2(100) :='NAMES';
      5   v_segment_type VARCHAR2(100) :='TABLE';
      6   v_partition_name VARCHAR2(100) :=null;
      7   -- OUT vars
      8   v_unformatted_blocks   NUMBER;
      9   v_unformatted_bytes   NUMBER;
    10   v_fs1_blocks   NUMBER;
    11   v_fs1_bytes   NUMBER;
    12   v_fs2_blocks   NUMBER;
    13   v_fs2_bytes   NUMBER;
    14   v_fs3_blocks   NUMBER;
    15   v_fs3_bytes   NUMBER;
    16   v_fs4_blocks   NUMBER;
    17   v_fs4_bytes   NUMBER;
    18   v_full_blocks   NUMBER;
    19   v_full_bytes   NUMBER;
    20   v_segment_size_blocks NUMBER;
    21   v_segment_size_bytes NUMBER;
    22   v_used_blocks NUMBER;
    23   v_used_bytes NUMBER;
    24   v_expired_blocks NUMBER;
    25   v_expired_bytes NUMBER;
    26   v_unexpired_blocks NUMBER;
    27   v_unexpired_bytes NUMBER;
    28  begin
    29  DBMS_SPACE.SPACE_USAGE(
    30   segment_owner => v_segment_owner ,
    31   segment_name => v_segment_name ,
    32   segment_type => v_segment_type ,
    33   unformatted_blocks => v_unformatted_blocks ,
    34   unformatted_bytes => v_unformatted_bytes ,
    35   fs1_blocks => v_fs1_blocks  ,
    36   fs1_bytes => v_fs1_bytes ,
    37   fs2_blocks => v_fs2_blocks ,
    38   fs2_bytes => v_fs2_bytes ,
    39   fs3_blocks => v_fs3_blocks ,
    40   fs3_bytes => v_fs3_bytes ,
    41   fs4_blocks => v_fs4_blocks ,
    42   fs4_bytes => v_fs4_bytes ,
    43   full_blocks => v_full_blocks ,
    44   full_bytes => v_full_bytes ,
    45   partition_name => v_partition_name  );
    46* end;
    SQL> /
    declare
    ERROR at line 1:
    ORA-00942: table or view does not exist
    ORA-06512: at "SYS.DBMS_SPACE", line 190
    ORA-06512: at line 29
    SQL> show user
    USER is "SYS"
    SQL> select * from v$version ;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
    PL/SQL Release 10.2.0.1.0 - Production
    CORE    10.2.0.1.0      Production
    TNS for 32-bit Windows: Version 10.2.0.1.0 - Production
    NLSRTL Version 10.2.0.1.0 - Production
    SQL> declare
      2   -- IN vars
      3   v_segment_owner VARCHAR2(100):='HR';
      4   v_segment_name VARCHAR2(100) :='NAMES';
      5   v_segment_type VARCHAR2(100) :='TABLE';
      6   v_partition_name VARCHAR2(100) :=null;
      7 
      8   -- OUT vars
      9   v_unformatted_blocks   NUMBER;
    10   v_unformatted_bytes   NUMBER;
    11   v_fs1_blocks   NUMBER;
    12   v_fs1_bytes   NUMBER;
    13   v_fs2_blocks   NUMBER;
    14   v_fs2_bytes   NUMBER;
    15   v_fs3_blocks   NUMBER;
    16   v_fs3_bytes   NUMBER;
    17   v_fs4_blocks   NUMBER;
    18   v_fs4_bytes   NUMBER;
    19   v_full_blocks   NUMBER;
    20   v_full_bytes   NUMBER;
    21   v_segment_size_blocks NUMBER;
    22   v_segment_size_bytes NUMBER;
    23   v_used_blocks NUMBER;
    24   v_used_bytes NUMBER;
    25   v_expired_blocks NUMBER;
    26   v_expired_bytes NUMBER;
    27   v_unexpired_blocks NUMBER;
    28   v_unexpired_bytes NUMBER;
    29  begin
    30  DBMS_SPACE.SPACE_USAGE(
    31   segment_owner => v_segment_owner ,
    32   segment_name => v_segment_name ,
    33   segment_type => v_segment_type ,
    34   unformatted_blocks => v_unformatted_blocks ,
    35   unformatted_bytes => v_unformatted_bytes ,
    36   fs1_blocks => v_fs1_blocks  ,
    37   fs1_bytes => v_fs1_bytes ,
    38   fs2_blocks => v_fs2_blocks ,
    39   fs2_bytes => v_fs2_bytes ,
    40   fs3_blocks => v_fs3_blocks ,
    41   fs3_bytes => v_fs3_bytes ,
    42   fs4_blocks => v_fs4_blocks ,
    43   fs4_bytes => v_fs4_bytes ,
    44   full_blocks => v_full_blocks ,
    45   full_bytes => v_full_bytes ,
    46   partition_name => v_partition_name  );
    47  end;
    48  /
    PL/SQL procedure successfully completed.
    SQL> show user
    USER is "SYS"

    You make feel embarressed!!
    You are right.. the table wasn't there. I was connecting to the wrong database.
    Sorry for that.

  • Coalesce or compress this index? what is the best solution in this case?

    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64biI have executed the following query on a specific index that I suspected to be smashed and got the following result
    select
        keys_per_leaf, count(*) blocks
    from (  
          select   sys_op_lbid (154813, 'L', jus.rowid) block_id,
                 count (*)                            keys_per_leaf
          from xxx_table jus
           where jus.id is not null
                  or jus.dat is not null
          group by sys_op_lbid (154813, 'L', jus.rowid)
    group by keys_per_leaf
    order by keys_per_leaf;
    keys_per_leaf     blocks 
    1     80       
    2     1108       
    3     2816       
    4     3444       
    5     3512       
    6     2891       
    7     2579       
    8     2154       
    9     1943       
    10     1287       
    11     1222       
    12     1011       
    13     822       
    14     711       
    15     544       
    16     508       
    17     414       
    18     455       
    19     425       
    20     417       
    21     338       
    22     337       
    23     327       
    24     288       
    25     267       
    26     295       
    27     281       
    28     266       
    29     249       
    30     255       
    31     237       
    32     259       
    33     257       
    34     232       
    35     211       
    36     209       
    37     204       
    38     216       
    39     189       
    40     194       
    41     187       
    42     200       
    43     183       
    44     167       
    45     186       
    46     179       
    47     179       
    48     179       
    49     171       
    50     164       
    51     174       
    52     157       
    53     181       
    54     192       
    55     178       
    56     162       
    57     155       
    58     160       
    59     153       
    60     151       
    61     133       
    62     177       
    63     156       
    64     167       
    65     162       
    66     171       
    67     154       
    68     162       
    69     163       
    70     153       
    71     189       
    72     166       
    73     164       
    74     142       
    75     177       
    76     148       
    77     161       
    78     164       
    79     133       
    80     158       
    81     176       
    82     189       
    83     347       
    84     369       
    85     239       
    86     239       
    87     224       
    88     227       
    89     214       
    90     190       
    91     230       
    92     229       
    93     377       
    94     276       
    95     196       
    96     218       
    97     217       
    98     227       
    99     230       
    100     251       
    101     266       
    102     298       
    103     276       
    104     288       
    105     638       
    106     1134       
    107     1152     
    229     1       
    230     1      This is a 5 columns unique key index on (id number, dat date, id2 number, dat2 date type number).
    Furthermore, a space analysis of this index using dbms_space.space_usage gives the following picture
    Number of blocks with at least 0 to 25% free space            = 0                   -------> total bytes = 0
    Number of blocks with at least 25-50% free space              = 75                 -------> total bytes = ,5859375
    Number of Blocks with with at least 50 to 75% free space  = 0                   -------> Total Bytes = 0
    number of blocks with at least 75 to 100% free space        = 0                   -------> total bytes = 0
    Number of full blocks with no free space                              = 99848           -------> total bytes = 780,0625
    Total blocks ______________________________
    99923
    Total size MB______________________________
    799,384It seems for me that this index needs to be either coalesced or compressed.
    Then, what would be the best option in your opinion?
    Thanks in advance
    Mohamed Houri
    Edited by: Mohamed Houri on 12-janv.-2011 1:18

    So let me continue my case
    I first compressed the index as follows
    alter index my_index rebuild compress 2;which immediately presents two new situations
    (a) index space
    Number of blocks with at least 0 to 25% free space    = 0                -------> total bytes = 0
    Number of blocks with at least 25-50% free space      = 40              -------> total bytes =, 3125
    Number of Blocks with at least 50 to 75% free space   = 0                -------> total Bytes = 0
    Number of blocks with at least 75 to 100% free space  = 0                -------> total bytes = 0
    Number of full blocks with no free space                = 32361           -------> total bytes = 252, 8203125
    Total blocks ______________________________
    32401
    Total size Mb______________________________
    259,208meaning that the compress command freed up 67487 leaf blocks and reduced the size of the index from to 799,384 MB to 259,208 MB.
    It also shows a relative nice pictue of number of keys per leaf block (when compared to the previous situation)
    (b) on the number of key per leaf block
    KEYS_PER_LEAF     BLOCKS       
    4     1       
    6     1       
    13     1       
    15     1       
    25     1       
    62     1       
    63     1       
    88     1       
    97     1       
    122     1       
    123     3       
    124     6       
    125     4       
    126     2     
    289     4489       
    290     3887       
    291     3129       
    292     2273       
    293     1528       
    294     913       
    295     442       
    296     152       
    297     50       
    298     7       
    299     1      In a second step, I have coalesced the index as follows
    alter index my_index coalesce;which produces the new figure
    Number of blocks with at least 0 to 25% free space     = 0          -------> total bytes = 0
    Number of blocks with at least 25-50% free space      = 298        -------> total bytes = 2,328125
    Number of Blocks with at least 50 to 75% free space   = 0           -------> Total Bytes = 0
    Number of blocks with at least 75 to 100% free space = 0            -------> total bytes = 0
    Number of full blocks with no free space = 32375                    -------> total bytes = 252, 9296875
    Total blocks ______________________________
    32673
    Total size MB______________________________
    261,384meaning the the coalesce command has made
    (a)     298-40 = 258 new blocks with 25-50% of free space
    (b)     32375-32361 = 14 new additional blocks which have been made full
    (c)     The size of the index increased by 2,176MB (261,384-259,208)
    While the number of key per leaf block keeps in the same situation
    KEYS_PER_LEAF     BLOCKS       
    4     2       
    5     3       
    9     1       
    10     2       
    12     1       
    13     1       
    19     1       
    31     1       
    37     1       
    61     1       
    63     1       
    73     1       
    85     1       
    88     1       
    122     1       
    123     4       
    124     4       
    125     3       
    126     1     
    289     4492       
    290     3887       
    291     3125       
    292     2273       
    293     1525       
    294     913       
    295     441       
    296     152       
    297     50       
    298     7       
    299     1      Could you please through some light on the difference between the compress and the coalesce on the effect they have made on
    (a) the number of keys per leaf blocks within my index
    (b) the space and size of my index?
    Best regards
    Mohamed Houri

  • Exact space occupied by a table with LOB column

    Hi Gurus,
    I need to check the exact amount of space used (in bytes or MB) by a table which is having a BLOB column.
    I tried the following query but it is not giving the proper usage.
    select segment_name , sum(bytes)
    from dba_extents
    where segment_type='TABLE'
    and segment_name in ('TEST_CLOB','TEST_BLOB','TEST_CLOB_ADV','TEST_BLOB_ADV')
    group by segment_name;
    I even tried the following stored procedure
    create or replace procedure sp_get_table_size (p_table_name varchar2)
    as
        l_segment_name          varchar2(30);
        l_segment_size_blocks   number;
        l_segment_size_bytes    number;
        l_used_blocks           number; 
        l_used_bytes            number; 
        l_expired_blocks        number; 
        l_expired_bytes         number; 
        l_unexpired_blocks      number; 
        l_unexpired_bytes       number; 
    begin
        select segment_name
        into l_segment_name
        from dba_lobs
        where table_name = p_table_name;
        dbms_output.put_line('Segment Name=' || l_segment_name);
        dbms_space.space_usage(
            segment_owner           => 'dldbo', 
            segment_name            => l_segment_name,
            segment_type            => 'LOB',
            partition_name          => NULL,
            segment_size_blocks     => l_segment_size_blocks,
            segment_size_bytes      => l_segment_size_bytes,
            used_blocks             => l_used_blocks,
            used_bytes              => l_used_bytes,
            expired_blocks          => l_expired_blocks,
            expired_bytes           => l_expired_bytes,
            unexpired_blocks        => l_unexpired_blocks,
            unexpired_bytes         => l_unexpired_bytes
        dbms_output.put_line('segment_size_blocks       => '||  l_segment_size_blocks);
        dbms_output.put_line('segment_size_bytes        => '||  l_segment_size_bytes);
        dbms_output.put_line('used_blocks               => '||  l_used_blocks);
        dbms_output.put_line('used_bytes                => '||  l_used_bytes);
        dbms_output.put_line('expired_blocks            => '||  l_expired_blocks);
        dbms_output.put_line('expired_bytes             => '||  l_expired_bytes);
        dbms_output.put_line('unexpired_blocks          => '||  l_unexpired_blocks);
        dbms_output.put_line('unexpired_bytes           => '||  l_unexpired_bytes);
    end sp_get_table_size;
    But it is giving the error
    Error starting at line 298 in command:
    exec sp_get_table_size ('TEST_CLOB_ADV')
    Error report:
    ORA-03213: Invalid Lob Segment Name for DBMS_SPACE package
    ORA-06512: at "SYS.DBMS_SPACE", line 210
    ORA-06512: at "SYS.SP_GET_TABLE_SIZE", line 20
    ORA-06512: at line 1
    03213. 00000 -  "Invalid Lob Segment Name for DBMS_SPACE package"
    *Cause:    The Lob Segment specified in the DBMS_SPACE operation does not
               exist.
    *Action:   Fix the Segment Specification
    Although the LOB section is specified in create table syntax.
    Please help.
    Thanks
    Amitava.

    Here is a query that I use, to associate space from all segments under s schema (LOBs, indexes, etc.) back to the tables they support:
    with schema as (select '&your_schema' as name from dual),
    segs_by_table as(
      select 'TABLE' seg_supertype, seg.segment_name as related_table, seg.* from dba_segments seg, schema where seg.owner = schema.name and seg.segment_type in ('TABLE','TABLE PARTITION','TABLE SUBPARTITION')
      union all
      select 'INDEX' seg_supertype, i.table_name as related_table, seg.* from dba_segments seg, dba_indexes i, schema where seg.owner = schema.name and seg.segment_type in ('INDEX','INDEX PARTITION','INDEX SUBPARTITION')
      and Seg.OWNER = i.owner and seg.segment_name = i.index_name
      union all
      select 'LOB' seg_supertype, lob.table_name as related_table, seg.* from dba_segments seg, dba_lobs lob, schema where seg.owner = schema.name and seg.segment_type in ('LOBSEGMENT','LOB PARTITION')
      and seg.OWNER = lob.owner and seg.segment_name = lob.segment_name
    union all
      select 'LOB' seg_supertype, lob.table_name as related_table, seg.* from dba_segments seg, dba_lobs lob, schema where seg.owner = schema.name and seg.segment_type in ('LOBINDEX')
    and seg.OWNER = lob.owner and seg.segment_name = lob.index_name
    select owner,related_table,
    segment_type,   segment_name , partition_name, blocks
    from segs_by_table, schema
    where owner = schema.name
    --and related_table like 'BLOB_TEST%'
    order by owner,related_table,  segment_type, segment_name;
    You can revise as needed to limit to a single table, to summarize, etc.
    Mike

  • How to calculate the percentage of free space for a table in Oracle

    okay, I am a little confused here. I have been searching the web and looking at a lot of documents. What I basically want to find out is this, how do I calculate the difference between the number of bytes a table is using and the total bytes allocated to a table space (going that way to get percent free for a particular table). So I need a byte count of a table and total table space and the percentage difference. I have been looking at the DBA_TABLES DBA_TABLESPACES and DBA_SEGMENTS views. I have tried to calculated the space as num_rows * avg_row_len (if I am wrong, let me know). I have been trying to compare that calculation to the number in DBA_TABLESPACES and DBA_SEGMENTS. I am just looking for the total space allocated to the table space that the table sits in (seem logical right now) to make the percentage value work. Thus I want to be able to track the table as it grows as compated to the table space it sits in to see a value as it changes over time (days, weeks, etc.) each time I run this script I am working on.
    Can someone get me straight and help me to find out if I am looking in the right places. Any advice would help.
    Edward

    You can use a little modified version of dbms_space from Tom, show_space. Have a look,
    SQL> create table test222 as select * from all_objects;
    Table created.
    SQL> delete from test22 where rownum<=100;
    delete from test22 where rownum<=100
    ERROR at line 1:
    ORA-00942: table or view does not exist
    SQL> delete from test222 where rownum<=100;
    100 rows deleted.
    SQL> analyze table test222 compute statistics;
    Table analyzed.
    SQL>  create or replace procedure show_space
      2  ( p_segname in varchar2,
      3    p_owner   in varchar2 default user,
      4    p_type    in varchar2 default 'TABLE',
      5    p_partition in varchar2 default NULL )
      6  -- this procedure uses authid current user so it can query DBA_*
      7  -- views using privileges from a ROLE and so it can be installed
      8  -- once per database, instead of once per user that wanted to use it
      9  authid current_user
    10  as
    11      l_free_blks                 number;
    12      l_total_blocks              number;
    13      l_total_bytes               number;
    14      l_unused_blocks             number;
    15      l_unused_bytes              number;
    16      l_LastUsedExtFileId         number;
    17      l_LastUsedExtBlockId        number;
    18      l_LAST_USED_BLOCK           number;
    19      l_segment_space_mgmt        varchar2(255);
    20      l_unformatted_blocks number;
    21      l_unformatted_bytes number;
    22      l_fs1_blocks number; l_fs1_bytes number;
    23      l_fs2_blocks number; l_fs2_bytes number;
    24      l_fs3_blocks number; l_fs3_bytes number;
    25      l_fs4_blocks number; l_fs4_bytes number;
    26      l_full_blocks number; l_full_bytes number;
    27
    28      -- inline procedure to print out numbers nicely formatted
    29      -- with a simple label
    30      procedure p( p_label in varchar2, p_num in number )
    31      is
    32      begin
    33          dbms_output.put_line( rpad(p_label,40,'.') ||
    34                                to_char(p_num,'999,999,999,999') );
    35      end;
    36  begin
    37     -- this query is executed dynamically in order to allow this procedure
    38     -- to be created by a user who has access to DBA_SEGMENTS/TABLESPACES
    39     -- via a role as is customary.
    40     -- NOTE: at runtime, the invoker MUST have access to these two
    41     -- views!
    42     -- this query determines if the object is a ASSM object or not
    43     begin
    44        execute immediate
    45            'select ts.segment_space_management
    46               from dba_segments seg, dba_tablespaces ts
    47              where seg.segment_name      = :p_segname
    48                and (:p_partition is null or
    49                    seg.partition_name = :p_partition)
    50                and seg.owner = :p_owner
    51                and seg.tablespace_name = ts.tablespace_name'
    52               into l_segment_space_mgmt
    53              using p_segname, p_partition, p_partition, p_owner;
    54     exception
    55         when too_many_rows then
    56            dbms_output.put_line
    57            ( 'This must be a partitioned table, use p_partition => ');
    58            return;
    59     end;
    60
    61
    62     -- if the object is in an ASSM tablespace, we must use this API
    63     -- call to get space information, else we use the FREE_BLOCKS
    64     -- API for the user managed segments
    65     if l_segment_space_mgmt = 'AUTO'
    66     then
    67       dbms_space.space_usage
    68       ( p_owner, p_segname, p_type, l_unformatted_blocks,
    69         l_unformatted_bytes, l_fs1_blocks, l_fs1_bytes,
    70         l_fs2_blocks, l_fs2_bytes, l_fs3_blocks, l_fs3_bytes,
    71         l_fs4_blocks, l_fs4_bytes, l_full_blocks, l_full_bytes, p_partition);
    72
    73       p( 'Unformatted Blocks ', l_unformatted_blocks );
    74       p( 'FS1 Blocks (0-25)  ', l_fs1_blocks );
    75       p( 'FS2 Blocks (25-50) ', l_fs2_blocks );
    76       p( 'FS3 Blocks (50-75) ', l_fs3_blocks );
    77       p( 'FS4 Blocks (75-100)', l_fs4_blocks );
    78       p( 'Full Blocks        ', l_full_blocks );
    79    else
    80       dbms_space.free_blocks(
    81         segment_owner     => p_owner,
    82         segment_name      => p_segname,
    83         segment_type      => p_type,
    84         freelist_group_id => 0,
    85         free_blks         => l_free_blks);
    86
    87       p( 'Free Blocks', l_free_blks );
    88    end if;
    89
    90    -- and then the unused space API call to get the rest of the
    91    -- information
    92    dbms_space.unused_space
    93    ( segment_owner     => p_owner,
    94      segment_name      => p_segname,
    95      segment_type      => p_type,
    96      partition_name    => p_partition,
    97      total_blocks      => l_total_blocks,
    98      total_bytes       => l_total_bytes,
    99      unused_blocks     => l_unused_blocks,
    100      unused_bytes      => l_unused_bytes,
    101      LAST_USED_EXTENT_FILE_ID => l_LastUsedExtFileId,
    102      LAST_USED_EXTENT_BLOCK_ID => l_LastUsedExtBlockId,
    103      LAST_USED_BLOCK => l_LAST_USED_BLOCK );
    104
    105      p( 'Total Blocks', l_total_blocks );
    106      p( 'Total Bytes', l_total_bytes );
    107      p( 'Total MBytes', trunc(l_total_bytes/1024/1024) );
    108      p( 'Unused Blocks', l_unused_blocks );
    109      p( 'Unused Bytes', l_unused_bytes );
    110      p( 'Last Used Ext FileId', l_LastUsedExtFileId );
    111      p( 'Last Used Ext BlockId', l_LastUsedExtBlockId );
    112      p( 'Last Used Block', l_LAST_USED_BLOCK );
    113  end;
    114
    115  /
    Procedure created.
    SQL> desc show_space
    PROCEDURE show_space
    Argument Name                  Type                    In/Out Default?
    P_SEGNAME                      VARCHAR2                IN
    P_OWNER                        VARCHAR2                IN     DEFAULT
    P_TYPE                         VARCHAR2                IN     DEFAULT
    P_PARTITION                    VARCHAR2                IN     DEFAULT
    SQL> set serveroutput on
    SQL> exec show_space('TEST222','SCOTT');
    BEGIN show_space('TEST222','SCOTT'); END;
    ERROR at line 1:
    ORA-00942: table or view does not exist
    ORA-06512: at "SCOTT.SHOW_SPACE", line 44
    ORA-06512: at line 1
    SQL> conn / as sysdba
    Connected.
    SQL> grant sysdba to scott;
    Grant succeeded.
    SQL> conn scott/tiger as sysdba
    Connected.
    SQL> exec show_space('TEST222','SCOTT');
    BEGIN show_space('TEST222','SCOTT'); END;
    ERROR at line 1:
    ORA-06550: line 1, column 7:
    PLS-00201: identifier 'SHOW_SPACE' must be declared
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored
    SQL> exec scott.show_space('TEST222','SCOTT');
    PL/SQL procedure successfully completed.
    SQL> set serveroutput on
    SQL> exec scott.show_space('TEST222','SCOTT');
    Unformatted Blocks .....................               0
    FS1 Blocks (0-25)  .....................               0
    FS2 Blocks (25-50) .....................               1
    FS3 Blocks (50-75) .....................               0
    FS4 Blocks (75-100).....................               1
    Full Blocks        .....................             807
    Total Blocks............................             896
    Total Bytes.............................       7,340,032
    Total MBytes............................               7
    Unused Blocks...........................              65
    Unused Bytes............................         532,480
    Last Used Ext FileId....................               4
    Last Used Ext BlockId...................           1,289
    Last Used Block.........................              63
    PL/SQL procedure successfully completed.
    SQL>http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:5350053031470
    I use this to find the space allocations.
    Just read your post again,this is not going to show you the percentage of the free/used space. This is going to be the number of blocks which are free/used. For the growth trend, you can look at (in 10g) Oracle EM. It has added now,Segment Growth Trend report which can show you for each object,comparing to the allocated space to the object,how much space is being used by it.
    HTH
    Aman....

  • After Update 1.4 GB of space increase

    Hi,
    Last week we updated 23233865 number of records on single column on two tables and we were table to see 1.4GB of growth on DB.
    Total tables size=18GB data +10GB of indexes on this tables.
    So Kindly guide me do i need to rebuild the indexes or any way to tell how space can be reclaimed.
    select del_lf_rows * 100 / decode(lf_rows,0,1,lf_rows) from index_stats where name = 'TIBEX_ORDER_IDX_OLT';
    declare
           segment_owner              VARCHAR2(30) default 'TRD_SRV_OWNER';
           segment_name               VARCHAR2(30) default 'TIBEX_ORDER_ID_ORD_INS';
           segment_type               VARCHAR2(30) default 'INDEX';
           total_blocks               NUMBER;
           total_bytes                NUMBER;
           unused_blocks              NUMBER;
           unused_bytes               NUMBER;
           last_used_extent_file_id   NUMBER;
          last_used_extent_block_id  NUMBER;
          last_used_block            NUMBER;
          partition_name             VARCHAR2(30) DEFAULT NULL;
       begin
          DBMS_SPACE.UNUSED_SPACE (
          segment_owner              ,
          segment_name               ,
          segment_type               ,
          total_blocks               ,
          total_bytes                ,
          unused_blocks              ,
          unused_bytes               ,
          last_used_extent_file_id   ,
          last_used_extent_block_id  ,
          last_used_block            ,
          partition_name             );
          dbms_output.put_line('total blk : ' || total_blocks               );
          dbms_output.put_line('Unused blk : ' || unused_blocks              );
          dbms_output.put_line('last unused blk : ' || last_used_block            );
      end ;
    total blk : 560640
    Unused blk : 0
    last unused blk : 8192
      1  declare
      2         segment_owner              VARCHAR2(30) default 'TRD_SRV_OWNER';
      3         segment_name               VARCHAR2(30) default 'TIBEX_ORDER_IDX_OLT';
      4         segment_type               VARCHAR2(30) default 'INDEX';
      5         total_blocks               NUMBER;
      6         total_bytes                NUMBER;
      7         unused_blocks              NUMBER;
      8         unused_bytes               NUMBER;
      9         last_used_extent_file_id   NUMBER;
    10        last_used_extent_block_id  NUMBER;
    11        last_used_block            NUMBER;
    12        partition_name             VARCHAR2(30) DEFAULT NULL;
    13     begin
    14        DBMS_SPACE.UNUSED_SPACE (
    15        segment_owner              ,
    16        segment_name               ,
    17        segment_type               ,
    18        total_blocks               ,
    19        total_bytes                ,
    20        unused_blocks              ,
    21        unused_bytes               ,
    22        last_used_extent_file_id   ,
    23        last_used_extent_block_id  ,
    24        last_used_block            ,
    25        partition_name             );
    26        dbms_output.put_line('total blk : ' || total_blocks               );
    27        dbms_output.put_line('Unused blk : ' || unused_blocks              );
    28        dbms_output.put_line('last unused blk : ' || last_used_block            );
    29*   end ;
    sys@SURV1> /
    total blk : 296192
    Unused blk : 0
    last unused blk : 8192
      1  declare
      2         segment_owner              VARCHAR2(30) default 'TRD_SRV_OWNER';
      3         segment_name               VARCHAR2(30) default 'IX_ORDER_TIMESTAMP';
      4         segment_type               VARCHAR2(30) default 'INDEX';
      5         total_blocks               NUMBER;
      6         total_bytes                NUMBER;
      7         unused_blocks              NUMBER;
      8         unused_bytes               NUMBER;
      9         last_used_extent_file_id   NUMBER;
    10        last_used_extent_block_id  NUMBER;
    11        last_used_block            NUMBER;
    12        partition_name             VARCHAR2(30) DEFAULT NULL;
    13     begin
    14        DBMS_SPACE.UNUSED_SPACE (
    15        segment_owner              ,
    16        segment_name               ,
    17        segment_type               ,
    18        total_blocks               ,
    19        total_bytes                ,
    20        unused_blocks              ,
    21        unused_bytes               ,
    22        last_used_extent_file_id   ,
    23        last_used_extent_block_id  ,
    24        last_used_block            ,
    25        partition_name             );
    26        dbms_output.put_line('total blk : ' || total_blocks               );
    27        dbms_output.put_line('Unused blk : ' || unused_blocks              );
    28        dbms_output.put_line('last unused blk : ' || last_used_block            );
    29*   end ;
    sys@SURV1> /
    total blk : 197504
    Unused blk : 0
    last unused blk : 8192
      1  declare
      2         segment_owner              VARCHAR2(30) default 'TRD_SRV_OWNER';
      3         segment_name               VARCHAR2(30) default 'TIBEX_QUOTE_IDX_QLT';
      4         segment_type               VARCHAR2(30) default 'INDEX';
      5         total_blocks               NUMBER;
      6         total_bytes                NUMBER;
      7         unused_blocks              NUMBER;
      8         unused_bytes               NUMBER;
      9         last_used_extent_file_id   NUMBER;
    10        last_used_extent_block_id  NUMBER;
    11        last_used_block            NUMBER;
    12        partition_name             VARCHAR2(30) DEFAULT NULL;
    13     begin
    14        DBMS_SPACE.UNUSED_SPACE (
    15        segment_owner              ,
    16        segment_name               ,
    17        segment_type               ,
    18        total_blocks               ,
    19        total_bytes                ,
    20        unused_blocks              ,
    21        unused_bytes               ,
    22        last_used_extent_file_id   ,
    23        last_used_extent_block_id  ,
    24        last_used_block            ,
    25        partition_name             );
    26        dbms_output.put_line('total blk : ' || total_blocks               );
    27        dbms_output.put_line('Unused blk : ' || unused_blocks              );
    28        dbms_output.put_line('last unused blk : ' || last_used_block            );
    29*   end ;
    sys@SURV1> /
    total blk : 229760
    Unused blk : 0
    last unused blk : 8192
      1  declare
      2         segment_owner              VARCHAR2(30) default 'TRD_SRV_OWNER';
      3         segment_name               VARCHAR2(30) default 'IX_QUOTE_TIMESTAMP';
      4         segment_type               VARCHAR2(30) default 'INDEX';
      5         total_blocks               NUMBER;
      6         total_bytes                NUMBER;
      7         unused_blocks              NUMBER;
      8         unused_bytes               NUMBER;
      9         last_used_extent_file_id   NUMBER;
    10        last_used_extent_block_id  NUMBER;
    11        last_used_block            NUMBER;
    12        partition_name             VARCHAR2(30) DEFAULT NULL;
    13     begin
    14        DBMS_SPACE.UNUSED_SPACE (
    15        segment_owner              ,
    16        segment_name               ,
    17        segment_type               ,
    18        total_blocks               ,
    19        total_bytes                ,
    20        unused_blocks              ,
    21        unused_bytes               ,
    22        last_used_extent_file_id   ,
    23        last_used_extent_block_id  ,
    24        last_used_block            ,
    25        partition_name             );
    26        dbms_output.put_line('total blk : ' || total_blocks               );
    27        dbms_output.put_line('Unused blk : ' || unused_blocks              );
    28        dbms_output.put_line('last unused blk : ' || last_used_block            );
    29*   end ;
    sys@SURV1> /
    total blk : 147712
    Unused blk : 0
    last unused blk : 8192Current DB version 10.2.0.4 version on Solaris.
    Question is:
    Why did it used 1.4 GB of space only update.
    Regards
    Narasimha
    Edited by: NarasimhaMurthy on 23-May-2010 13:20

    Hi Ramesh,
    Thanks for your reply.
    trd_srv_owner@SURV1> declare
      2     l_fs1_bytes number;
      3     l_fs2_bytes number;
      4     l_fs3_bytes number;
      5     l_fs4_bytes number;
      6     l_fs1_blocks number;
      7     l_fs2_blocks number;
      8     l_fs3_blocks number;
      9     l_fs4_blocks number;
       l_full_bytes number;
    10   11     l_full_blocks number;
    12     l_unformatted_bytes number;
    13     l_unformatted_blocks number;
    14  begin
       dbms_space.space_usage(
    15   16        segment_owner      => user,
          segment_name       => 'TIBEX_ORDER',
          segment_type       => 'TABLE',
    17   18   19        fs1_bytes          => l_fs1_bytes,
    20        fs1_blocks         => l_fs1_blocks,
    21        fs2_bytes          => l_fs2_bytes,
    22        fs2_blocks         => l_fs2_blocks,
    23        fs3_bytes          => l_fs3_bytes,
    24        fs3_blocks         => l_fs3_blocks,
    25        fs4_bytes          => l_fs4_bytes,
    26        fs4_blocks         => l_fs4_blocks,
    27        full_bytes         => l_full_bytes,
    28        full_blocks        => l_full_blocks,
    29        unformatted_blocks => l_unformatted_blocks,
    30        unformatted_bytes  => l_unformatted_bytes
    31     );
    32     dbms_output.put_line(' FS1 Blocks = '||l_fs1_blocks||' Bytes = '||l_fs1_bytes);
    33     dbms_output.put_line(' FS2 Blocks = '||l_fs2_blocks||' Bytes = '||l_fs2_bytes);
    34     dbms_output.put_line(' FS3 Blocks = '||l_fs3_blocks||' Bytes = '||l_fs3_bytes);
    35     dbms_output.put_line(' FS4 Blocks = '||l_fs4_blocks||' Bytes = '||l_fs4_bytes);
       dbms_output.put_line('Full Blocks = '||l_full_blocks||' Bytes = '||l_full_bytes);
    36   37  end;
    38  /
    FS1 Blocks = 6409 Bytes = 52502528
    FS2 Blocks = 7 Bytes = 57344
    FS3 Blocks = 7 Bytes = 57344
    FS4 Blocks = 3612 Bytes = 29589504
    Full Blocks = 1264078 Bytes = 10355326976
    PL/SQL procedure successfully completed.
    trd_srv_owner@SURV1> declare
      2     l_fs1_bytes number;
      3     l_fs2_bytes number;
      4     l_fs3_bytes number;
      5     l_fs4_bytes number;
      6     l_fs1_blocks number;
      7     l_fs2_blocks number;
      8     l_fs3_blocks number;
      9     l_fs4_blocks number;
    10     l_full_bytes number;
    11     l_full_blocks number;
       l_unformatted_bytes number;
    12   13     l_unformatted_blocks number;
    14  begin
    15     dbms_space.space_usage(
    16        segment_owner      => user,
    17        segment_name       => 'TIBEX_QUOTE',
    18        segment_type       => 'TABLE',
    19        fs1_bytes          => l_fs1_bytes,
    20        fs1_blocks         => l_fs1_blocks,
    21        fs2_bytes          => l_fs2_bytes,
    22        fs2_blocks         => l_fs2_blocks,
    23        fs3_bytes          => l_fs3_bytes,
    24        fs3_blocks         => l_fs3_blocks,
    25        fs4_bytes          => l_fs4_bytes,
    26        fs4_blocks         => l_fs4_blocks,
    27        full_bytes         => l_full_bytes,
    28        full_blocks        => l_full_blocks,
    29        unformatted_blocks => l_unformatted_blocks,
    30        unformatted_bytes  => l_unformatted_bytes
    31     );
    32     dbms_output.put_line(' FS1 Blocks = '||l_fs1_blocks||' Bytes = '||l_fs1_bytes);
    33     dbms_output.put_line(' FS2 Blocks = '||l_fs2_blocks||' Bytes = '||l_fs2_bytes);
    34     dbms_output.put_line(' FS3 Blocks = '||l_fs3_blocks||' Bytes = '||l_fs3_bytes);
    35     dbms_output.put_line(' FS4 Blocks = '||l_fs4_blocks||' Bytes = '||l_fs4_bytes);
    36     dbms_output.put_line('Full Blocks = '||l_full_blocks||' Bytes = '||l_full_bytes);
    37  end;
    38  /
    FS1 Blocks = 7 Bytes = 57344
    FS2 Blocks = 4 Bytes = 32768
    FS3 Blocks = 2 Bytes = 16384
    FS4 Blocks = 3367 Bytes = 27582464
    Full Blocks = 1100447 Bytes = 9014861824
    trd_srv_owner@SURV1> declare
      2     l_fs1_bytes number;
      3     l_fs2_bytes number;
      4     l_fs3_bytes number;
      5     l_fs4_bytes number;
      6     l_fs1_blocks number;
      7     l_fs2_blocks number;
      8     l_fs3_blocks number;
      9     l_fs4_blocks number;
    10     l_full_bytes number;
    11     l_full_blocks number;
    12     l_unformatted_bytes number;
    13     l_unformatted_blocks number;
    14  begin
    15     dbms_space.space_usage(
    16        segment_owner      => user,
    17        segment_name       => 'TIBEX_EDPMARKETSTATE',
          segment_type       => 'TABLE',
    18   19        fs1_bytes          => l_fs1_bytes,
    20        fs1_blocks         => l_fs1_blocks,
    21        fs2_bytes          => l_fs2_bytes,
    22        fs2_blocks         => l_fs2_blocks,
    23        fs3_bytes          => l_fs3_bytes,
    24        fs3_blocks         => l_fs3_blocks,
    25        fs4_bytes          => l_fs4_bytes,
    26        fs4_blocks         => l_fs4_blocks,
    27        full_bytes         => l_full_bytes,
    28        full_blocks        => l_full_blocks,
    29        unformatted_blocks => l_unformatted_blocks,
    30        unformatted_bytes  => l_unformatted_bytes
    31     );
    32     dbms_output.put_line(' FS1 Blocks = '||l_fs1_blocks||' Bytes = '||l_fs1_bytes);
    33     dbms_output.put_line(' FS2 Blocks = '||l_fs2_blocks||' Bytes = '||l_fs2_bytes);
    34     dbms_output.put_line(' FS3 Blocks = '||l_fs3_blocks||' Bytes = '||l_fs3_bytes);
    35     dbms_output.put_line(' FS4 Blocks = '||l_fs4_blocks||' Bytes = '||l_fs4_bytes);
    36     dbms_output.put_line('Full Blocks = '||l_full_blocks||' Bytes = '||l_full_bytes);
    37  end;
    38  /
    FS1 Blocks = 6 Bytes = 49152
    FS2 Blocks = 8 Bytes = 65536
    FS3 Blocks = 4 Bytes = 32768
    FS4 Blocks = 3803 Bytes = 31154176
    Full Blocks = 163827 Bytes = 1342070784
    PL/SQL procedure successfully completed.
    trd_srv_owner@SURV1> declare
      2     l_fs1_bytes number;
      3     l_fs2_bytes number;
      4     l_fs3_bytes number;
      5     l_fs4_bytes number;
      6     l_fs1_blocks number;
      7     l_fs2_blocks number;
      8     l_fs3_blocks number;
      9     l_fs4_blocks number;
    10     l_full_bytes number;
    11     l_full_blocks number;
    12     l_unformatted_bytes number;
    13     l_unformatted_blocks number;
    14  begin
    15     dbms_space.space_usage(
    16        segment_owner      => user,
    17        segment_name       => 'TIBEX_INSTRUMENTADMIN',
    18        segment_type       => 'TABLE',
    19        fs1_bytes          => l_fs1_bytes,
    20        fs1_blocks         => l_fs1_blocks,
    21        fs2_bytes          => l_fs2_bytes,
    22        fs2_blocks         => l_fs2_blocks,
    23        fs3_bytes          => l_fs3_bytes,
    24        fs3_blocks         => l_fs3_blocks,
    25        fs4_bytes          => l_fs4_bytes,
    26        fs4_blocks         => l_fs4_blocks,
    27        full_bytes         => l_full_bytes,
    28        full_blocks        => l_full_blocks,
    29        unformatted_blocks => l_unformatted_blocks,
    30        unformatted_bytes  => l_unformatted_bytes
    31     );
    32     dbms_output.put_line(' FS1 Blocks = '||l_fs1_blocks||' Bytes = '||l_fs1_bytes);
    33     dbms_output.put_line(' FS2 Blocks = '||l_fs2_blocks||' Bytes = '||l_fs2_bytes);
    34     dbms_output.put_line(' FS3 Blocks = '||l_fs3_blocks||' Bytes = '||l_fs3_bytes);
    35     dbms_output.put_line(' FS4 Blocks = '||l_fs4_blocks||' Bytes = '||l_fs4_bytes);
    36     dbms_output.put_line('Full Blocks = '||l_full_blocks||' Bytes = '||l_full_bytes);
    37  end;
    38  /
    FS1 Blocks = 0 Bytes = 0
    FS2 Blocks = 1 Bytes = 8192
    FS3 Blocks = 2 Bytes = 16384
    FS4 Blocks = 252 Bytes = 2064384
    Full Blocks = 76779 Bytes = 628973568
    PL/SQL procedure successfully completed.
    I used one more procedure to find actual space
    set verify off
    set serverout on size 1000000
    declare
       sql_stmt varchar2(1024);
       block_count number;
    cursor tab is
        select owner, table_name,blocks   
        from dba_tables
        where owner=upper('TRD_SRV_OWNER') and table_name like UPPER('TIBEX_QUOTE');
    l_db_block_size NUMBER;
    begin
    dbms_output.put_line('Displaying Actual Space Used for schema TRD_SRV_OWNER ');
    dbms_output.put_line('Log file to Check_counts2.lst ....');
    dbms_output.put_line('....');
    SELECT value INTO l_db_block_size 
    FROM v$parameter WHERE name='db_block_size';
    FOR tab_rec IN tab LOOP
    BEGIN
    sql_stmt:='select count(distinct( dbms_rowid.rowid_block_number(rowid) )) from '
       ||tab_rec.owner||'.' ||tab_rec.table_name;
    EXECUTE IMMEDIATE sql_stmt INTO block_count;
       dbms_output.put_line(rpad(tab_rec.table_name,30)
           ||' '||TO_CHAR(block_count*l_db_block_size)/1024/1024||' Mb'
           ||' ('||TO_CHAR(block_count*l_db_block_size)/1024||' Kb)'    
           ||' Analyze:'
               ||TO_CHAR(tab_rec.blocks*l_db_block_size)/1024/1024||' Mb'
           ||' ('||TO_CHAR(tab_rec.blocks*l_db_block_size)/1024||' Kb)'    
    exception when others then
       dbms_output.put_line('Error counting rows for table '||tab_rec.table_name||' '||SQLERRM);
    END;
    end loop;
    end;
    Displaying Actual Space Used for schema TRD_SRV_OWNER
    Log file to Check_counts2.lst ....
    TIBEX_ORDER                    8585.90625 Mb (8791968 Kb) Analyze:9984.3203125 Mb (10223944 Kb)
    PL/SQL procedure successfully completed.
    Displaying Actual Space Used for schema TRD_SRV_OWNER
    Log file to Check_counts2.lst ....
    TIBEX_QUOTE                    7713.2265625 Mb (7898344 Kb) Analyze:8685.6484375 Mb (8894104 Kb)Regards
    Narasimha
    Edited by: NarasimhaMurthy on 24-May-2010 01:50

  • How to verify reused table space in oracle 10g ?

    Hi..
    From my system, i have seen that the table size keep increasing event the delete query is running. Due to that, I would to check either the oracle allowed to reuse the table space or not ? if not then how could i enable it ?
    Please help me..
    Thank you,
    Baharin

    You can use dbms_space.space_usage to check the for free space.
    Space reuse will depend on whether you are using MSSM or ASSM, PCT_FREE, PCT_USED, and how new data is inserted ?
    You can shrink or move the table and rebuild indexes to reclaim space.

  • Pl/sql error

    Hi ,
    In 10g Oracle as we know table re-organization is much improved i tried to use it for a table and it gave me the foolowing error:
    SIT1>declare
    2
    3 l_fs1_bytes number;
    4 l_fs2_bytes number;
    5 l_fs3_bytes number;
    6 l_fs4_bytes number;
    7 l_fs1_bytes number;
    8 l_fs2_bytes number;
    9 l_fs3_bytes number;
    10 l_fs4_bytes number;
    11 l_full_bytes number;
    12 l_full_blocks number;
    13 l_unformatted_bytes number;
    14 l_unformatted_blocks number;
    15 begin
    16 dbms_space.space_usage (
    17 segment_owner => HR,
    18 segment_name => 'JOBS',
    19 segment_type => 'TABLE',
    20 fs1_bytes => l_fs1_bytes,
    21 fs1_blocks => l_fs1_blocks,
    22 fs2_bytes => l_fs2_bytes,
    23 fs2_blocks => l_fs2_blocks,
    24 fs3_bytes => l_fs3_bytes,
    25 fs3_blocks => l_fs3_blocks,
    26 fs4_bytes => l_fs4_bytes,
    27 fs4_blocks => l_fs4_blocks,
    28 full_bytes => l_full_bytes,
    29 full_blocks => l_full_blocks,
    30 unformatted_blocks => l_unformatted_blocks,
    31 unformatted_bytes => l_unformatted_bytes
    32 );
    33 dbms_output.put_line(' FS1 blocks = '||l_fs1_blocks||' bytes = '||l_fs1_byt
    es);
    34 dbms_output.put_line(' FS2 blocks = '||l_fs2_blocks||' bytes = '||l_fs2_byt
    es);
    35 dbms_output.put_line(' FS3 blocks = '||l_fs3_blocks||' bytes = '||l_fs3_byt
    es);
    36 dbms_output.put_line(' FS4 blocks = '||l_fs4_blocks||' bytes = '||l_fs4_byt
    es);
    37 dbms_output.put_line(' Full blocks = '||l_full_blocks||' bytes = '||l_full_
    bytes);
    38 end;
    39 /
    segment_owner => HR,
    ERROR at line 17:
    ORA-06550: line 17, column 18:
    PLS-00201: identifier 'HR' must be declared
    ORA-06550: line 16, column 1:
    PL/SQL: Statement ignored
    ORA-06550: line 33, column 40:
    PLS-00201: identifier 'L_FS1_BLOCKS' must be declared
    ORA-06550: line 33, column 1:
    PL/SQL: Statement ignored
    ORA-06550: line 34, column 40:
    PLS-00201: identifier 'L_FS2_BLOCKS' must be declared
    ORA-06550: line 34, column 1:
    PL/SQL: Statement ignored
    ORA-06550: line 35, column 40:
    PLS-00201: identifier 'L_FS3_BLOCKS' must be declared
    ORA-06550: line 35, column 1:
    PL/SQL: Statement ignored
    ORA-06550: line 36, column 40:
    PLS-00201: identifier 'L_FS4_BLOCKS' must be declared
    ORA-06550: line 36, column 1:
    PL/SQL: Statement ignored
    can someone help me to formulate?
    thanks

    Dear Please try below script,
    declare
    l_fs1_bytes number;
    l_fs2_bytes number;
    l_fs3_bytes number;
    l_fs4_bytes number;
    l_fs1_blocks number;
    l_fs2_blocks number;
    l_fs3_blocks number;
    l_fs4_blocks number;
    l_full_bytes number;
    l_full_blocks number;
    l_unformatted_bytes number;
    l_unformatted_blocks number;
    begin
    dbms_space.space_usage (
    segment_owner => 'HR',
    segment_name => 'JOBS',
    segment_type => 'TABLE',
    fs1_bytes => l_fs1_bytes,
    fs1_blocks => l_fs1_blocks,
    fs2_bytes => l_fs2_bytes,
    fs2_blocks => l_fs2_blocks,
    fs3_bytes => l_fs3_bytes,
    fs3_blocks => l_fs3_blocks,
    fs4_bytes => l_fs4_bytes,
    fs4_blocks => l_fs4_blocks,
    full_bytes => l_full_bytes,
    full_blocks => l_full_blocks,
    unformatted_blocks => l_unformatted_blocks,
    unformatted_bytes => l_unformatted_bytes
    dbms_output.put_line(' FS1 blocks = '||l_fs1_blocks||' bytes = '||l_fs1_bytes);
    dbms_output.put_line(' FS2 blocks = '||l_fs2_blocks||' bytes = '||l_fs2_bytes);
    dbms_output.put_line(' FS3 blocks = '||l_fs3_blocks||' bytes = '||l_fs3_bytes);
    dbms_output.put_line(' FS4 blocks = '||l_fs4_blocks||' bytes = '||l_fs4_bytes);
    dbms_output.put_line(' Full blocks = '||l_full_blocks||' bytes = '||l_full_bytes);
    end;
    Best Regards
    Faheem latif
    Senior Database Architect
    Genie Technologies (Pvt.) Ltd.

  • Too many extents for table on locally managed uniform ASSM tablespace

    Running Oracle 9.2.0.8 on solaris 10, Enterprise edition.
    Tablespace configuration:
    select extent_management, allocation_type, segment_space_management, block_size, initial_extent, next_extent
    from dba_tablespaces
    where tablespace_name = 'PCLARGE';
    LOCAL UNIFORM AUTO 8192 2097152 2097152
    A nightly peoplesoft SQR job inserts and updates the problem table. The job has been in place without change for four years. During that time, the database moved from 8i to 9i, and the tablespace parameters moved to uniform local ASSM. The job selects from a 70 million row table and then updates the target summary table.
    Can somebody help me understand why the number of extents would grow way out of proportion to the number of rows?
    When the row count was 9807427, this table had 233 extents.
    Row count 10759033, table had 501 extents.
    Row count 10764665, table has 1967 extents.
    The table is not analyzed since the system is using RULE. DBMS_SPACE.SPACE_USAGE indicates no extents above the high water mark. Running SELECT name,value FROM v$sysstat WHERE name like '%table%' seems to indicate that chained rows are not a factor, since the row with name "table fetch continued row" returns a small amount of rows.
    Any ideas? Is it possible there is a bug with ASSM that is causing this?
    Unfortunately I don't have detailed extent history information after each nightly run. I just have the 3 data points above.

    Hi Hemant,
    Thanks for your reply! No parallelism was involved in the SQR script.
    Oracle support has pointed me to Metalink Note:469985.1: Sudden Increase in Unformatted Blocks. This behavior matches our symptoms. My company is going to pursue a backport, but in the meantime we may need to move data into tablespaces without ASSM.
    Best regards,
    Ben

  • Find out how much data is in a certain table

    Hi experts,
    I have deleted a lot of entries in a certain table by running the reorganisation-reports in SAP.
    Now I know that the table do not change its size because of the HWM. So new data in the table will be inserted in the freed blocks. Now I would like to know how much data remained in the table.
    So e.g. the table was 100 GB the size before reorganisation. Now I have deleted a lot of entries and I would like to know, how much data remained in the table. I know that I can find out the average line size and number of entries in DB02old but this is imprecise for me.
    Any idea?

    Hi,
    you can use the PL/SQL procedure DBMS_SPACE.SPACE_USAGE for that, if your tablespace is created with auto segment space management.
    Documentation: http://docs.oracle.com/cd/E11882_01/appdev.112/e16760/d_space.htm#CACBDJIH
    Regards
    Stefan

Maybe you are looking for

  • Error in Synchronizing Slave Repository

    Hi All, I've created a Master / Slave pattern and when i make any changes in the Master and Synchronize the slave i get the following error: <b>"Unable to retrieve synchronization data from master repository. See the Assertion Log for more informatio

  • How to backup chat history in a messenger app

    I did buy a new iPhone 5. And when I went to Apple store to get my new order, I found all the chat history or document history in messenger or picture fixing apps were restored in my new iPhone 5. Please, anyone knows how to backup chat history in me

  • Easy DMS & Object Link

    Hi all, in the transactional SAP while I'm creating a new version of a DIR the system allows me to inherit (via copy) the object links included in the DIR of departure. By contrast the Easy DMS does not cover this feature. Suggestions? I have to impl

  • How Tou2026 Create Custom Menu within BPC NW - OPENFILE issue

    Hi Guys, I built a custom menu in BPC 7.5 using the step-by-step procedure available in u201CHow Tou2026 Create Custom Menu within BPC NWu201D. It uses the OPENFILE option with EvMnu to open dynamic templates describing this limit: The OPENFILE optio

  • HT4060 ' charging not supported with this accessory' and Not Charging at all

    Help and advice please. I am having problems getting the new IPad to charge at all and sometime it displays this message. ' charging not supported with this accessory'. This message is appearing occasionally on my 5 week old new iPad (3) within a few