Recently I was performing database reorg operation on one of pre-prod environment with traditional way of table/lob movement followed by index rebuild. After moving all segments from current tablespace to new, I was ready to drop original one.
SQL> select count(0) from dba_segments where tablespace_name='MY_TABLESPACE'; COUNT(0) ---------- 0
And it errored out!!!
SQL> DROP TABLESPACE MY_TABLESPACE INCLUDING CONTENTS AND DATAFILES; DROP TABLESPACE MY_TABLESPACE INCLUDING CONTENTS AND DATAFILES *ERROR at line 1: ORA-14404: partitioned table contains partitions in a different tablespace
As first step, I tried purging dba_recyclebin, but it didn’t help.
After searching on metalink, I found following note with similar issue: ORA-14404 or ORA-14407 When Trying to Drop a Tablespace (Doc ID 1674989.1)
which talks about two causes of this issue:
1. An attempt was made to drop a tablespace which contains tables whose partitions or subpartitions are not completely contained in this tablespace.
OR
2. This can happen due to deferred segment creation introduced in 11.2.
First cause was matching my case:
I tried finding out tables whose partitions were spread across other partitions along with tablespace MY_TABLESPACE & moved to it to new tablespace as well:
SELECT 'alter table '|| table_owner|| '.'|| table_name|| ' move partition '|| partition_name|| ' tablespace MY_TABLESPACE_NEW;' FROM (SELECT DISTINCT table_name, partition_name FROM dba_tab_partitions WHERE tablespace_name = 'MY_TABLESPACE') a, dba_tab_partitions b WHERE b.tablespace_name <> 'MY_TABLESPACE' AND a.table_name = b.table_name;
After moving all affected table partitions, I once again tried dropping tablespace: MY_TABLESPACE. It once again failed with same error: ORA-14404.
Then I found same issue with some of index partitions as well, for which I used following command:
select distinct 'alter index ' || index_owner || '.' || a.index_name || ' rebuild partition ' || a.partition_name || ' tablespace MY_TABLESPACE_NEW;'from ( select distinct index_name,partition_namefrom dba_ind_partitionswhere tablespace_name = 'MY_TABLESPACE' ) a, dba_ind_partitions bwhere b.tablespace_name <> 'MY_TABLESPACE' and a.index_name = b.index_name;
Once indexes were rebuild, I was able to drop tablespace MY_TABLESPACE without any issues 🙂
Note: You may also get ORA-14407 is some cases, wherein sub-partitions are the issue, for which you will use above commands just with sub-partitions views.
Just to elaborate seconds possible cause of this error: deferred segment creation:
The Oracle Database 11.2 includes a new space allocation method. When you create a non-partitioned heap table, the table segment creation is deferred to the first row insert. This functionality is enabled by default with the initialization parameter DEFERRED_SEGMENT_CREATION set to TRUE.So in simple words, if you have set this parameter to value TRUE, particular table will be populated in dba_tables once created, but will not be populated in dba_segments unless we insert a row to it. So in the case of defered segments, you will not be able to drop tablespace.
Hope so u will find this post very useful:-)
Cheers
Regards,
Adityanath
Categories: Administration, Advanced features, ORA errors, Uncategorized
Spot on with this write-up, I actually assume this web site needs rather more consideration. I’ll probably be once more to read rather more, thanks for that info.
Hello There,
Thanks for visiting and appreciate your feedback.:-)
Regards,
Adi
Very good write-up. I certainly love this website. Thanks!
Excellent pieces. Keep writing such kind of information on your site. Im really impressed by it.
Does your blog have a contact page? I’m having trouble locating it but, I’d like to shoot you an e-mail. I’ve got some suggestions for your blog you might be interested in hearing. Either way, great site and I look forward to seeing it expand over time.
Hi There,
https://adityanathoracledba.com/about-me/
Regards,
Adi
Heya! I’m at work surfing around your blog from my new iphone!
Just wanted to say I love reading your blog and look forward to all
your posts! Carry on the great work!
I’m not that much of a internet reader to be honest but your blogs really nice, keep it up! I’ll go ahead and bookmark your site to come back later on. All the best
excellent one
Thanks for feedback
Regards,
Adi
I’m not that much of a online reader to be honest but your sites really nice, keep it up! I’ll go ahead and bookmark your website to come back down the road. Many thanks
its wonderful as your other articles : D, regards for posting.
Article writing is also a fun, if you know then you can write or else it is complicated to write.
It’s in reality a nice and helpful piece of info. I am satisfied that you shared this helpful
information with us. Please keep us informed like this. Thank you for sharing.
Thanks very nice blog!