views:

1019

answers:

1

Hi,

I'm using the 11g interval partitioning feature in one of my tables. I set it up to create 1 day partitions on a timestamp field and created a job to delete data 3 months old. When I try to delete the oldest partition I get the following error:

ORA-14758: Last partition in the range section cannot be dropped

I would have thought that "Last" refers to the newest partition and not the oldest. How should I interpret this error? Is there something wrong with my partitions or should I in fact keep the oldest partition there at all time?

Thanks in advance, PJ

A: 

Yes, the error message is somewhat misleading, but it refers to the last STATICALLY created partition (in your original table DDL before Oracle started creating the partitions automatically. I think the only way to avoid this is to create an artifical "MINVAL" partition that you're sure will never be used and then drop the real partitions above this.

[Edit after exchange of comments]

I assume this test case reproduces your problem:

CREATE TABLE test 
    ( t_time        DATE
    )
  PARTITION BY RANGE (t_time)
  INTERVAL(NUMTODSINTERVAL(1, 'DAY'))
    ( PARTITION p0 VALUES LESS THAN (TO_DATE('09-1-2009', 'MM-DD-YYYY')),
      PARTITION p1 VALUES LESS THAN (TO_DATE('09-2-2009', 'MM-DD-YYYY')),
      PARTITION p2 VALUES LESS THAN (TO_DATE('09-3-2009', 'MM-DD-YYYY')),
      PARTITION p3 VALUES LESS THAN (TO_DATE('09-4-2009', 'MM-DD-YYYY')) 
);
insert into test values(TO_DATE('08-29-2009', 'MM-DD-YYYY'));
insert into test values(TO_DATE('09-1-2009', 'MM-DD-YYYY'));
insert into test values(TO_DATE('09-3-2009', 'MM-DD-YYYY'));
insert into test values(TO_DATE('09-10-2009', 'MM-DD-YYYY'));

When I do this I can drop partitions p0,p1, and p2 but get your error when attempting to drop p3 even though there is a system-generated partition beyond this.

The only workaround I could find was to temporarily redefine the table partitioning by:

alter table test set interval ();

and then drop partition p3. Then you can redefine the partitioning as per the original specification by:

alter table test set INTERVAL(NUMTODSINTERVAL(1, 'DAY'));
dpbradley
By the name of the partition I can tell this one was automatically created and the weirdest thing is that I was able to delete statically created partitions before that one. Anyhow I wanted to try your suggestion and I got this error:alter table TABLE1 add partition test VALUES LESS THAN ('07-JUL-09 11.59.00.000000000 PM');ERROR at line 1:ORA-14760: ADD PARTITION is not permitted on Interval partitioned objectsAny ideas?Thanks,PJ
poijoi
Sorry, forgot to say thanks :)
poijoi
Hmmm... I ran into your problem and it was the STATIC vs. DYNAMIC positioning issue in my case. When I mentioned the MINVAL partition I was thinking of re-creating the table with this single partition (and interval partitioning defined) and then re-inserting the data - is this possible in your situation?
dpbradley
I don't have enough disk space, this table is huge. This could be in fact the first automatically created partition. I can delete newer partitions tho... can you think of any other way around this?
poijoi
I haven't tried this in a fashion that would cross the partition types, but could you perform SPLIT or MERGE partition operations to move the boundaries?
dpbradley
Responding to my own comment - SPLIT/MERGE doesn't help - have edited my answer with the only solution I can think of.
dpbradley