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;
/

Similar Messages

  • 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

  • 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

  • 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

  • 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

  • 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

  • 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.

  • Need to find Exact Database Size in MB

    Hi
    I need to find the Exeact database size the actual space taken by data not the extent allocated by the table. I mean if the extent size is 64k and there is only 2k of actual data sitting there i need to get that 2k answer.
    Thanks in advance.

    Hi,
    Consider using DBMS_SPACE.SPACE_USAGE.
    There are lots of examples somewhere on AskTom website.
    Regards.
    PS: Bear in mind, SPACE_USAGE works with ASSM only. For MSSM you should use another procedures of DBMS_SPACE package.
    http://asktom.oracle.com/pls/ask/f?p=4950:8:3624308638663951627::NO::F4950_P8_DISPLAYID,F4950_P8_CRITERIA:5350053031470
    There you go.
    Message was edited: added a note about MSSM.

  • Calculating free space in tablespace

    Oracle 11.0.1.7:
    I am trying to calculate free space in the tablespace but I am not sure if Allocated Space (bytes_used) also has some free space that doesn't get reflected in the query below. Is it correct to assume that bytes_used is the space allocated to extents but may not have been really used (no data or LOB) yet? How do I calculate space that's currently been used by row data, index data or blob data?
    I am currently using below query:
    select     a.TABLESPACE_NAME,
         a.BYTES bytes_used,
         b.BYTES bytes_free,
         b.largest,
         round(((a.BYTES-b.BYTES)/a.BYTES)*100,2) percent_used
    from      
              select      TABLESPACE_NAME,
                   sum(BYTES) BYTES
              from      dba_data_files
              group      by TABLESPACE_NAME
         a,
              select      TABLESPACE_NAME,
                   sum(BYTES) BYTES ,
                   max(BYTES) largest
              from      dba_free_space
              group      by TABLESPACE_NAME
         b
    where      a.TABLESPACE_NAME=b.TABLESPACE_NAME
    order      by ((a.BYTES-b.BYTES)/a.BYTES) desc

    DBA_FREE_SPACE give you the free space information which has not been allocated to any segment. The segments can also have free space in their allocated space and in order to find that, use DBMS_SPACE.SPACE_USAGE procedure. To find out free space in LOB segments refer to metalink doc: 386341.1
    Thanks
    Daljit Singh

  • 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'

  • DBMS_SPACE.OBJECT_GROWTH_TREND returns ORA-14551

    Hi,
    When I used DBMS_SPACE.OBJECT_GROWTH_TREND, it ran successfully but ended with an error.
    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> SHOW USER
    USER is "SYS"
    SQL> SELECT *
      2  FROM
      3  table(
      4   DBMS_SPACE.OBJECT_GROWTH_TREND (
      5    object_owner =>'HR',
      6    object_name  =>'NAMES',
      7    object_type  =>'TABLE',
      8    partition_name =>NULL,
      9    start_time =>NULL,
    10    end_time   =>NULL,
    11    interval   =>to_dsinterval('0 00:10:00')  ,
    12    skip_interpolated => 'FALSE',
    13    timeout_seconds =>NULL,
    14    single_datapoint_flag =>'TRUE')
    15  )
    16  /
    TIMEPOINT                      SPACE_USAGE SPACE_ALLOC QUALITY
    04-OCT-09 03.58.47.421000 PM      10443367    11534336 INTERPOLATED
    04-OCT-09 04.08.47.421000 PM      10443367    11534336 INTERPOLATED
    04-OCT-09 04.18.47.421000 PM      10443367    11534336 INTERPOLATED
    04-OCT-09 04.28.47.421000 PM      10443367    11534336 INTERPOLATED
    04-OCT-09 04.38.47.421000 PM      10443367    11534336 INTERPOLATED
    04-OCT-09 04.48.47.421000 PM      10443367    11534336 INTERPOLATED
    04-OCT-09 04.58.47.421000 PM      10443367    11534336 INTERPOLATED
    04-OCT-09 05.08.47.421000 PM      10443367    11534336 INTERPOLATED
    04-OCT-09 05.18.47.421000 PM      10443367    11534336 INTERPOLATED
    04-OCT-09 05.28.47.421000 PM      10443367    11534336 INTERPOLATED
    04-OCT-09 05.38.47.421000 PM      10443367    11534336 INTERPOLATED
    TIMEPOINT                      SPACE_USAGE SPACE_ALLOC QUALITY
    04-OCT-09 05.48.47.421000 PM      10443367    11534336 INTERPOLATED
    04-OCT-09 05.58.47.421000 PM      10443367    11534336 INTERPOLATED
    04-OCT-09 06.08.47.421000 PM      10443367    11534336 INTERPOLATED
    04-OCT-09 06.18.47.421000 PM      10443367    11534336 INTERPOLATED
    04-OCT-09 06.28.47.421000 PM      10443367    11534336 INTERPOLATED
    04-OCT-09 06.38.47.421000 PM      10443367    11534336 INTERPOLATED
    04-OCT-09 06.48.47.421000 PM      10443367    11534336 INTERPOLATED
    04-OCT-09 06.58.47.421000 PM      10443367    11534336 INTERPOLATED
    04-OCT-09 07.08.47.421000 PM      10443367    11534336 INTERPOLATED
    04-OCT-09 07.18.47.421000 PM      10443367    11534336 INTERPOLATED
    04-OCT-09 07.28.47.421000 PM      10443367    11534336 INTERPOLATED
    TIMEPOINT                      SPACE_USAGE SPACE_ALLOC QUALITY
    04-OCT-09 07.38.47.421000 PM      10443367    11534336 INTERPOLATED
    04-OCT-09 07.48.47.421000 PM      10443367    11534336 INTERPOLATED
    04-OCT-09 07.58.47.421000 PM      10443367    11534336 INTERPOLATED
    04-OCT-09 08.08.47.421000 PM      10443367    11534336 INTERPOLATED
    04-OCT-09 08.18.47.421000 PM      10443367    11534336 INTERPOLATED
    04-OCT-09 08.28.47.421000 PM      10443367    11534336 INTERPOLATED
    04-OCT-09 08.38.47.421000 PM      10443367    11534336 INTERPOLATED
    04-OCT-09 08.48.47.421000 PM      10443367    11534336 INTERPOLATED
    04-OCT-09 08.58.47.421000 PM      10443367    11534336 INTERPOLATED
    04-OCT-09 09.08.47.421000 PM      10443367    11534336 PROJECTED
    04-OCT-09 09.18.47.421000 PM      10443367    11534336 PROJECTED
    TIMEPOINT                      SPACE_USAGE SPACE_ALLOC QUALITY
    04-OCT-09 09.28.47.421000 PM      10443367    11534336 PROJECTED
    04-OCT-09 09.38.47.421000 PM      10443367    11534336 PROJECTED
    04-OCT-09 09.48.47.421000 PM      10443367    11534336 PROJECTED
    36 rows selected.
    EXCEPTION in chrow processing -  code: -14551  msg: ORA-14551: cannot perform a
    DML operation inside a query*
    -- changed to another table for testing
    SQL> ED
    Wrote file afiedt.buf
      1  SELECT *
      2  FROM
      3  table(
      4   DBMS_SPACE.OBJECT_GROWTH_TREND (
      5    object_owner =>'HR',
      6    object_name  =>'EMPLOYEES',
      7    object_type  =>'TABLE',
      8    partition_name =>NULL,
      9    start_time =>NULL,
    10    end_time   =>NULL,
    11    interval   =>to_dsinterval('0 00:10:00')  ,
    12    skip_interpolated => 'FALSE',
    13    timeout_seconds =>NULL,
    14    single_datapoint_flag =>'TRUE')
    15* )
    SQL> /
    TIMEPOINT                      SPACE_USAGE SPACE_ALLOC QUALITY
    04-OCT-09 04.09.20.343000 PM         12614       65536 GOOD
    EXCEPTION in chrow processing -  code: -14551  msg: ORA-14551: cannot perform a
    DML operation inside a query

    DECLARE
    v_object_owner VARCHAR2 (30):='ME';
    v_object_name VARCHAR2 (30):='ACCOUNTS';
    v_object_type VARCHAR2 (30):='TABLE PARTITION';
    v_partition_name VARCHAR2 (30):='PAF19960501';
    v_objrefcursor sys_refcursor;
    r_obj_trend DBMS_SPACE.object_growth_trend_row;
    CURSOR c_parts (p_owner IN VARCHAR2, p_table IN VARCHAR2)
    IS
    SELECT table_owner, table_name, partition_name
    FROM dba_tab_partitions
    WHERE table_owner = p_owner AND table_name = p_table
    order by partition_name;
    BEGIN
    FOR r IN c_parts ('ME', 'ACCOUNTS')
    LOOP
    v_objrefcursor :=
    DBMS_SPACE.object_growth_trend_cur (
    object_owner => v_object_owner,
    object_name => v_object_name,
    object_type => v_object_type,
    partition_name => v_partition_name,
    start_time => sysdate - 120,
    end_time => sysdate + 30,
    interval =>null,
    skip_interpolated => 'FALSE',
    timeout_seconds => 360
    loop
    FETCH v_objrefcursor INTO r_obj_trend;
    exit when v_objrefcursor%notfound;
    -- if r_obj_trend.SPACE_USAGE * 1.5 <= r_obj_trend.SPACE_ALLOC THEN
    DBMS_OUTPUT.PUT_LINE( v_object_name ||' '||v_partition_name
    || ' '
    || r_obj_trend.timepoint
    || ' '
    || r_obj_trend.SPACE_USAGE
    || ' '
    || r_obj_trend.SPACE_ALLOC
    || ' '
    || r_obj_trend.quality);
    -- end if;
    END LOOP;
    end loop;
    CLOSE v_objrefcursor;
    END;
    EXCEPTION in chrow processing - code: -1031 msg: ORA-01031: insufficient privileges
    ACCOUNTS PAF19960501 18-DEC-09 06.49.07.857150 PM 32768 196608 INTERPOLATED
    ACCOUNTS PAF19960501 23-DEC-09 01.40.33.571436 AM 32768 196608 INTERPOLATED
    ACCOUNTS PAF19960501 27-DEC-09 08.31.59.285722 AM 32768 196608 INTERPOLATED
    ACCOUNTS PAF19960501 31-DEC-09 03.23.25.000008 PM 32768 196608 GOOD
    ACCOUNTS PAF19960501 04-JAN-10 10.14.50.714294 PM 32768 196608 PROJECTED
    ACCOUNTS PAF19960501 09-JAN-10 05.06.16.428580 AM 32768 196608 PROJECTED
    ACCOUNTS PAF19960501 13-JAN-10 11.57.42.142866 AM 32768 196608 PROJECTED
    EXCEPTION in chrow processing - code: -1031 msg: ORA-01031: insufficient privileges
    ACCOUNTS PAF19960501 02-SEP-09 03.23.25.000000 PM 32768 196608 INTERPOLATED
    ACCOUNTS PAF19960501 06-SEP-09 10.14.50.714286 PM 32768 196608 INTERPOLATED
    ACCOUNTS PAF19960501 11-SEP-09 05.06.16.428572 AM 32768 196608 INTERPOLATED
    ACCOUNTS PAF19960501 31-DEC-09 03.23.25.000008 PM 32768 196608 GOOD
    ACCOUNTS PAF19960501 04-JAN-10 10.14.50.714294 PM 32768 196608 PROJECTED
    ACCOUNTS PAF19960501 09-JAN-10 05.06.16.428580 AM 32768 196608 PROJECTED
    ACCOUNTS PAF19960501 13-JAN-10 11.57.42.142866 AM 32768 196608 PROJECTED
    EXCEPTION in chrow processing - code: -1031 msg: ORA-01031: insufficient privileges
    ACCOUNTS PAF19960501 02-SEP-09 03.23.25.000000 PM 32768 196608 INTERPOLATED
    ACCOUNTS PAF19960501 06-SEP-09 10.14.50.714286 PM 32768 196608 INTERPOLATED
    ACCOUNTS PAF19960501 11-SEP-09 05.06.16.428572 AM 32768 196608 INTERPOLATED
    ACCOUNTS PAF19960501 31-DEC-09 03.23.25.000008 PM 32768 196608 GOOD
    ACCOUNTS PAF19960501 04-JAN-10 10.14.50.714294 PM 32768 196608 PROJECTED
    ACCOUNTS PAF19960501 09-JAN-10 05.06.16.428580 AM 32768 196608 PROJECTED
    ACCOUNTS PAF19960501 13-JAN-10 11.57.42.142866 AM 32768 196608 PROJECTED
    EXCEPTION in chrow processing - code: -1031 msg: ORA-01031: insufficient privileges
    ACCOUNTS PAF19960501 02-SEP-09 03.23.25.000000 PM 32768 196608 INTERPOLATED
    ACCOUNTS PAF19960501 06-SEP-09 10.14.50.714286 PM 32768 196608 INTERPOLATED
    ACCOUNTS PAF19960501 11-SEP-09 05.06.16.428572 AM 32768 196608 INTERPOLATED
    ACCOUNTS PAF19960501 31-DEC-09 03.23.25.000008 PM 32768 196608 GOOD
    ACCOUNTS PAF19960501 17-JAN-10 06.49.07.857152 PM 32768 196608 PROJECTED
    ACCOUNTS PAF19960501 22-JAN-10 01.40.33.571438 AM 32768 196608 PROJECTED
    ACCOUNTS PAF19960501 26-JAN-10 08.31.59.285724 AM 32768 196608 PROJECTED
    EXCEPTION in chrow processing - code: -1031 msg: ORA-01031: insufficient privileges
    ACCOUNTS PAF19960501 02-SEP-09 03.23.25.000000 PM 32768 196608 INTERPOLATED
    Maybe not the best example but as you can see,
    for every switch to a different partition I get this EXCEPTION msg.
    The output seems correct otherwise.
    I can create the message several different ways!
    Row#     BANNER
    1     Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
    2     PL/SQL Release 10.2.0.4.0 - Production
    3     CORE     10.2.0.4.0     Production
    4     TNS for IBM/AIX RISC System/6000: Version 10.2.0.4.0 - Productio
    5     NLSRTL Version 10.2.0.4.0 - Production

  • 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.

  • How to view one table used percentage in sqlplus?

    if the table only one record in dba_free_space,then use
    'select round(block_id/blocks,4)*100
    from dba_free_space
    where tablespace_name='xxx'"
    could list used percentage,
    but one table have many records in dba_free_space,
    how to display this table's used percentage?

    DBA_FREE_SPACE displays free extents in all tablespaces: there is no direct relationship with any given table.
    If you want to get free space in a existing table you should use DBMS_SPACE package. Here a a old but nice demo on AskTom.

  • Dbms_space.unused_space

    I have a database 8k block size. Tablespace initial extent is 40K.
    I created a table
    D1
    CREATE TABLE D1
    ( RID NUMBER, TABLENAME VARCHAR2(30 BYTE)
    Pct free = 10.
    No data is currently inserted into the table.
    However when I use dbms_space.unused_space
    DBMS_SPACE.UNUSED_SPACE (
    p_owner,
    p_segname,
    p_type,
    l_total_blocks,
    l_total_bytes,
    l_unused_blocks,
    l_unused_bytes,
    l_last_used_extent_file_id,
    l_last_used_extent_block_id,
    l_last_used_block,
    l_partition_name);
    Unused space
    l_total_blocks--> 5
    l_total_bytes--> 40960
    l_unused_blocks--> 2
    l_unused_bytes--> 16384
    l_last_used_extent_file_id--> 16
    l_last_used_extent_block_id 497199
    l_last_used_block--> 3
    5 blocks are allocated 8k * 5 = 40k which is the initial extent size. But I get 2 blocks that are unused
    How do we determine the amount of space oracle uses for table management?
    Isn't 24K alot.
    Thanks in advance for all the help.

    This amount of 'unused space' is meaningless, overall considering today databases can hold Tb and Oracle is ready to accept Eb. After the amount of unused blocks you are reporting I assume you are working on a locally managed tablespace with manual segment space management. have you tried this test on an automatic segment space managed tablespace?
    Meaningless, unless you are planning to create thousands of tiny tables, and even in this case, from a practical perspective, the cost of storage is not the same as it used to be a decade ago.
    ~ Madrid
    http://hrivera99.blogspot.com

  • DBMS_Space

    I have a partioned table named bUsers and name of partion is Partion1. How can I use DBMS_Space to get information. Please guide me.
    Regards,
    null

    They are allocated to the segment, but have never been used.
    If they have been used, but are now empty, they are no longer unformatted.
    Sybrand Bakker
    Senior Oracle DBA

Maybe you are looking for

  • Acrobat 9.5.5からAcrobat XI Proへのバージョンアップ方法について

    Acrobat 9.5.5からAcrobat XI Proへのバージョンアップ方法について.Acrobat 9.5.5の製品サポートが終了した今でも.バージョンアップする形式とは可能でしょうか.それとも.新規にXI Proを購入する形式となりますか.

  • Select options default value

    Hi, Kindly assist me on how to set a default value for dynamically created Select options. I am coding the below code snippet for default value and it's working but when I remove the default value for the select option on portal screen ...I encounter

  • Logic X Tracks Mute Randomly

    I have a very unique problem, that said because I've found no other forums that have helped me. My instrument tracks will mute for absolutely no reason, it seems. Whether adjusting an oscillator, opening the digital keyboard, or even moving a plugin

  • How do I use reminders on iOS 7?

    How do I re name and edit lists on reminders as when I tap the plus icon nothing happens and I thought that was how you do it?

  • E-recruiting - Add manual entries in hitlist search

    We have created a new posting channel in e-recruiting. With this new posting channel, we would like to create entries in standard hitlist for employee and for candidates (As standard posting channel 1 and 2 do) We tried copying the PUBLISH method of