dbms_space.free_space[10]

[入库:2005年8月18日] [更新:2007年3月24日]

本文简介:选择自 youbo2004 的 blog

after a closer look...  may 06, 2003
reviewer:  pingu

hi

i had a closer look and i dont understand why we need the for loop

for x in ( select tablespace_name
                 from dba_tablespaces
                where tablespace_name in ( select distinct tablespace_name
                                            from dba_segments
                                           where segment_type = p_type
                                             and segment_name = p_segname
                                  and segment_space_management <> 'auto' )
             )
    loop
    dbms_space.free_blocks
    ( segment_owner     => p_owner,
      segment_name      => p_segname,
      segment_type      => p_type,
      partition_name    => p_partition,
      freelist_group_id => 0,
      free_blks         => l_free_blks );
    end loop;

i think we dont use anything from the loop.....? or iterating for anything 

followup:
it only calls free blocks if the segment space management is not auto and the 
object exists.

just add a "and rownum = 1" to the query.  lose the distinct, it is not 
relevant. 

  may 19, 2003
reviewer:  a reader

hi tom,

 i am getting error when i use show_space procedure

sql> exec show_space('t1');
error ora-10618: operation not allowed on this segment -10618
begin show_space('t1'); end;

*
error at line 1:
ora-10618: operation not allowed on this segment
ora-06512: at "gaurang.show_space", line 49
ora-06512: at line 1

thanks 

followup:
having no clue what t1 is, i have no comment. 

  may 20, 2003
reviewer:  a reader

t1 is table .

i am using oracle 9ir2 

followup:
sorry, maybe if you show us the entire thing -- are you using the script that 
does auto segment space management "show space", etc...

have you read about the dbms_* packages i use (they are documented).  it is 
pretty straightforward stuff.  

works for me in 9i


ops$tkyte@ora920> l
  1  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  authid current_user
  7  as
  8      l_free_blks                 number;
  9
 10      l_total_blocks              number;
 11      l_total_bytes               number;
 12      l_unused_blocks             number;
 13      l_unused_bytes              number;
 14      l_lastusedextfileid         number;
 15      l_lastusedextblockid        number;
 16      l_last_used_block           number;
 17      procedure p( p_label in varchar2, p_num in number )
 18      is
 19      begin
 20          dbms_output.put_line( rpad(p_label,40,'.') ||
 21                                p_num );
 22      end;
 23  begin
 24      for x in ( select tablespace_name
 25                   from dba_tablespaces
 26                  where tablespace_name = ( select tablespace_name
 27                                              from dba_segments
 28                                             where segment_type = p_type
 29                                               and segment_name = p_segname
 30                                                                              
        and owner = p_owner
 31                                               and segment_space_management 
<> 'auto' )
 32               )
 33      loop
 34      dbms_space.free_blocks
 35      ( segment_owner     => p_owner,
 36        segment_name      => p_segname,
 37        segment_type      => p_type,
 38       partition_name    => p_partition,
 39        freelist_group_id => 0,
 40        free_blks         => l_free_blks );
 41      dbms_output.put_line( 'old fashioned' );
 42      end loop;
 43
 44      dbms_space.unused_space
 45      ( segment_owner     => p_owner,
 46        segment_name      => p_segname,
 47        segment_type      => p_type,
 48       partition_name    => p_partition,
 49        total_blocks      => l_total_blocks,
 50        total_bytes       => l_total_bytes,
 51        unused_blocks     => l_unused_blocks,
 52        unused_bytes      => l_unused_bytes,
 53        last_used_extent_file_id => l_lastusedextfileid,
 54        last_used_extent_block_id => l_lastusedextblockid,
 55        last_used_block => l_last_used_block );
 56
 57      p( 'free blocks', l_free_blks );
 58      p( 'total blocks', l_total_blocks );
 59      p( 'total bytes', l_total_bytes );
 60      p( 'total mbytes', trunc(l_total_bytes/1024/1024) );
 61      p( 'unused blocks', l_unused_blocks );
 62      p( 'unused bytes', l_unused_bytes );
 63      p( 'last used ext fileid', l_lastusedextfileid );
 64      p( 'last used ext blockid', l_lastusedextblockid );
 65      p( 'last used block', l_last_used_block );
 66* end;
ops$tkyte@ora920> drop table t;

table dropped.

ops$tkyte@ora920> create table t ( x int );

table created.

ops$tkyte@ora920> exec show_space('t')
free blocks.............................
total blocks............................8
total bytes.............................65536
total mbytes............................0
unused blocks...........................5
unused bytes............................40960
last used ext fileid....................9
last used ext blockid...................48
last used block.........................3

pl/sql procedure successfully completed.

 

本文关键:dbms_space.free_space
  相关方案
Google
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top