Mohamed Houri’s Oracle Notes

March 15, 2011

Partition DDL and global indexes

Filed under: Partitioning — hourim @ 7:03 pm

This is just a simple reminder for me and for those who have experienced ORA-01502 error after a DDL on a partitioned table

ORA-01502: index 'XXX.ZZZ_TII_PK' or partition of such index is in unusable state

Let’s explain this situation through a simple demo:


create table TAB1 ( Value number(10))
partition by range(value)
(
partition p1 values less than (10),
partition p2 values less than (20),
partition p3 values less than (30),
partition p4 values less than (40),
partition p5 values less than (50)
);

insert into tab1
select rownum
from dual connect by rownum < 50;

commit;
sql>create index tab1_indx1 on tab1(value);

sql> select index_name, status
2  from user_indexes
3  where index_name = 'TAB1_INDX1';

INDEX_NAME                     STATUS
------------------------------ --------
TAB1_INDX1                     VALID

sql> alter table tab1 drop partition p2 UPDATE GLOBAL INDEXES;

Table altered.

sql> select index_name, status
2  from user_indexes
3  where index_name = 'TAB1_INDX1';

INDEX_NAME                     STATUS
------------------------------ --------
TAB1_INDX1                     VALID

sql> alter table tab1 drop partition p3;

Table altered.

sql> select index_name, status
2  from user_indexes
3  where index_name = 'TAB1_INDX1';

INDEX_NAME                     STATUS
------------------------------ --------
TAB1_INDX1                     UNUSABLE

Footnote: always think about the status of the global indexes when doing DDL on a partitioned table. If you want to keep those indexes in a valid status then you need to add the UPDATE GLOBAL INDEXES clause to your partition DDL

Advertisements

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at WordPress.com.

Tony's Oracle Tips

Tony Hasler's light hearted approach to learning about Oracle

Richard Foote's Oracle Blog

Focusing Specifically On Oracle Indexes, Database Administration and Some Great Music

Hatem Mahmoud Oracle's blog

Just another Oracle blog : Database topics and techniques

Mohamed Houri’s Oracle Notes

Qui se conçoit bien s’énonce clairement

Oracle Diagnostician

Performance troubleshooting as exact science

Raheel's Blog

Things I have learnt as Oracle DBA

Coskan's Approach to Oracle

What I learned about Oracle

So Many Oracle Manuals, So Little Time

“Books to the ceiling, Books to the sky, My pile of books is a mile high. How I love them! How I need them! I'll have a long beard by the time I read them”—Lobel, Arnold. Whiskers and Rhymes. William Morrow & Co, 1988.

EU Careers info

Your career in the European Union

Carlos Sierra's Tools and Tips

Tools and Tips for Oracle Performance and SQL Tuning

Oracle Scratchpad

Just another Oracle weblog

OraStory

Dominic Brooks on Oracle Performance, Tuning, Data Quality & Sensible Design ... (Now with added Sets Appeal)

%d bloggers like this: