Skip to Main Content

Breadcrumb

Question and Answer

Tom Kyte

Thanks for the question, Girish.

Asked: June 06, 2006 - 11:40 pm UTC

Last updated: July 12, 2006 - 4:49 pm UTC

Version: 9.2

Viewed 1000+ times

You Asked

Hi Tom,

Thanks for opening link to ask questions
I have couple of questions

1.I have a partitioned table and each partition on different tablespace.I want to determine how much of tablespace is full
for each partition.And one tablespace may be full but another one may be 10% full.Is there way/or is there any script which can be used

If I use following script how much it will be correct

select a.tablespace_name,
a.next_extent
from user_tab_partitions a
where not exists ( select 'X' from dba_free_space b
where a.tablespace_name = b.tablespace_name
and b.bytes >= a.next_extent);

This gives me "is there any space available to allocate next extents"

2.Is there a way to determine whether a table is partitioned monthly
,quarterly or yearly.Since I found that high_value column in user_tab_partitions is LONG datatype I cannot use SUBSTR
Is it possible to know if so then how

3.If I want delete/drop a DATABASE what all required files I need to delete (Oracle related file on OS)

Thanks & Regds
Girish

and Tom said...

1)
This is the script I use to view free space by tablespace (and largest contigous extent sizes as well)

</code> http://asktom.oracle.com/Misc/free.html <code>


2)
You would have to query the data dictionary - for to us, it is just "ranges" - a high and low data points, they need not all be the same:

ops$tkyte@ORA10GR2> CREATE TABLE t
2 (
3 dt date,
4 x int,
5 y varchar2(25)
6 )
7 PARTITION BY RANGE (dt)
8 -- subpartition by hash(x)
9 (
10 PARTITION part1 VALUES LESS THAN (to_date('13-mar-2003','dd-mon-yyyy')) ,
11 PARTITION part2 VALUES LESS THAN (to_date('14-mar-2003','dd-mon-yyyy')) ,
12 PARTITION part3 VALUES LESS THAN (to_date('14-jun-2003','dd-mon-yyyy')) ,
13 PARTITION part4 VALUES LESS THAN (to_date('14-sep-2003','dd-mon-yyyy')) ,
14 PARTITION part5 VALUES LESS THAN (to_date('14-mar-2004','dd-mon-yyyy')) ,
15 PARTITION junk VALUES LESS THAN (MAXVALUE)
16 )
17 /

Table created.

ops$tkyte@ORA10GR2> declare
2 l_last date;
3 l_curr date;
4 begin
5 for x in ( select high_value
6 from user_tab_partitions
7 where table_name = 'T'
8 order by partition_position )
9 loop
10 exit when x.high_value = 'MAXVALUE';
11 execute immediate 'begin :x := ' || x.high_value || '; end;' using OUT l_curr;
12 if ( l_last is not null )
13 then
14 dbms_output.put_line( (l_curr-l_last) || ' days between this and last partition' );
15 end if;
16 l_last := l_curr;
17 end loop;
18 end;
19 /
1 days between this and last partition
92 days between this and last partition
92 days between this and last partition
182 days between this and last partition

PL/SQL procedure successfully completed.



3) you can use dbca to do that, but in general:

o datafiles
o control files
o online redo log files
o init (.ora) files



Rating

  (2 ratings)

Is this answer out of date? If it is, please let us know via a Comment

Comments

Questions on Table Partitions ---> Getting Error

Girish, July 11, 2006 - 7:28 am UTC

Hi Tom,

When I executed the script below I am getting an error.But I do not have any MAXVALUE partitions in any of my partitioned table tables.How to make below script work when we do not have any partitions with MAXVALUE.Pls reply

SQL> declare
  2             l_last date;
  3             l_curr date;
  4     begin
  5             for x in ( select high_value
  6                          from user_tab_partitions
  7                       where table_name = 'MYTAB_PART'
  8                          order by partition_position )
  9             loop
 10                    exit when x.high_value = 'MAXVALUE';
 11                      execute immediate 'begin :x := ' || x.high_value || '; 
 12   end;' using OUT l_curr;
 13                     if ( l_last is not null )
 14                     then
 15            dbms_output.put_line( (l_curr-l_last) || ' days between this and last partition' );
 17                     end if;
 18                     l_last := l_curr;
 19             end loop;
 20     end;
 21  /
declare
*
ERROR at line 1:
ORA-06502: PL/SQL: numeric or value error
ORA-06512: at line 1
ORA-06512: at line 11 

Tom Kyte
July 11, 2006 - 7:57 pm UTC

umm, maybe add some debug and dbms_output the x.high value and see what it is??

perhaps your partition values are in fact not dates...

Isn't Long the problem?

Mark Brady, July 12, 2006 - 10:02 am UTC

High_value is of type Long.

</code> http://asktom.oracle.com/pls/asktom/f?p=100:11:::::P11_QUESTION_ID:426318778291 <code>

Does this explain the result?

Tom Kyte
July 12, 2006 - 4:49 pm UTC

Nope, it does not.

longs are OK in plsql like as long as they are less than 32k and I would expect a partition definition to be less than that....

(the block works when the table is partitioned using nice date ranges - see top of page)

More to Explore

VLDB

If you are new to partitioning, check out Connor McDonald's introduction series here.

VLDB

Documentation set on VLDB and Partitioning.