drop table 报错ora- 全分析

来源:互联网 发布:网络营销策划行业动态 编辑:程序博客网 时间:2024/06/07 04:13

Drop tablespace 有下面两种方式:

drop tablespace crm_data including contents and datafiles;
drop tablespace crm_data including contents cascade constraints;

报错有下面几种:

一. ORA-23515


--- ORA-23515: materialized views and/or their indices exist in the tablespace

drop tablespace crm_data including contents and datafiles
*
ERROR at line 1:
ORA-23515: materialized views and/or their indices exist in the tablespace

意思是:该表空间 CRM_DATA含有物化视图,或者含有物化视图的索引

解决办法:

-- 首先删掉该表空间下的的物化视图
select 'drop  materialized view '||owner||'.'||segment_name||' ;'
  from dba_segments
 where segment_name in (select mview_name from dba_mviews)
   and tablespace_name = 'CRM_DATA'


-- 然后删除该表空间下的其他表空间下物化视图在本表空间下创建的索引
select *
  from dba_segments
 where tablespace_name = 'CRM_DATA'
   and segment_name in
       (select index_name
          from dba_indexes
         where table_name in (select mview_name from dba_mviews));

二. ORA-02429

 

---ORA-02429: cannot drop index used for enforcement of unique/primary key

drop tablespace crm_idx including contents cascade constraints
*
ERROR at line 1:
ORA-00604: error occurred at recursive
SQL level 1
ORA-02429: cannot drop index used for enforcement of unique/primary key

ORA-02429的意思是: 让你删除该表空间下面的 primary key 和 unique key

处理办法:
select 'alter table '||owner||'.'||table_name||' drop constraint '||constraint_name||' ;'
  from dba_constraints
 where constraint_type in ('U', 'P')
   and (index_owner, index_name) in
       (select owner, segment_name
          from dba_segments
         where tablespace_name = 'CRM_IDX');

 

三. ORA-14404

 

--ORA-14404: partitioned table contains partitions in a different tablespace


drop tablespace crm_arc_data including contents and datafiles
*
ERROR at line 1:
ORA-14404: partitioned table contains partitions in a different tablespace

意思是: 本表空间下面有这么样一个或一些分区表的分区: this partition OR partitions的table所包含的全部 partitions不在一个表空间下面:

处理办法:
select 'alter table '||owner||'.'||segment_name||' drop partition '||partition_name||' ;'
  from dba_segments
 where segment_name in (select distinct segment_name
                          from dba_segments
                         where tablespace_name = 'CRM_ARC_DATA'
                           and segment_type like '%PART%')
   and tablespace_name <> 'CRM_ARC_DATA';

杀手锏: 直接drop 这个分区表(如果允许的话)

 

四. ORA-02449

 

--- ORA-02449: unique/primary keys in table referenced by foreign keys


drop tablespace crm_data including contents and datafiles
*
ERROR at line 1:
ORA-02449: unique/primary keys in table referenced by foreign keys

意思是: 这个要删除的表空间 里面含有这么样的一些主键: 其他表空间的表在这些主键上建有外键

处理办法: 去掉这些垃圾外键

select 'alter table '||owner||'.'||table_name||' drop constraint '||constraint_name||' ;'
  from dba_constraints
 where constraint_type = 'R'
   and table_name in (select segment_name
                        from dba_segments
                       where tablespace_name = 'CRM_DATA'
                         and segment_type like '%TABLE%');
                        

如果还是不行的话,就用这个语句来删表空间吧:

drop tablespace crm_data including contents cascade constraints

原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 天然植物纤维面料发黄怎么办 阴阳师吸血姬血太厚了怎么办 电话被骗了钱怎么办 镇魔曲元宝被扣怎么办 镇魔曲以前的角色怎么办 镇魔曲手游转职后装备怎么办 镇魔曲个性标签任务怎么办 教师资格证申请表打不开怎么办 怎么办appstore换到日本 电脑内存太小怎么办 win10声音卡顿怎么办 录音播放卡顿怎么办 笔记本电脑玩dnf卡怎么办 龙之谷约惠码被删了怎么办 天涯明月刀马没有了怎么办 icloud照片无法同步怎么办 ipad不能下载app怎么办 ipad屏幕孔进水怎么办 ipad无法验证登录怎么办 dnf电脑配置低怎么办 淘宝直播粉丝不够怎么办 电脑页面显示不全怎么办 脸上发痒长痘怎么办 扣扣魔性表情泡泡消失怎么办 脚起小泡泡很痒怎么办 孕妇脚痒起水泡怎么办 孕妇手脚起湿疹怎么办 嘴巴破皮了怎么办 小便刺痛阴唇红肿怎么办 集成墙面挂照片怎么办 苹果电脑网页游戏打不开怎么办 苹果6plus发热怎么办 玩手游手机太卡怎么办 苹果七发烫厉害怎么办 苹果手机延迟高怎么办 王者荣耀总是卡怎么办 王者荣耀卡屏怎么办 王者荣耀网络延迟怎么办 荣耀8手机卡了怎么办 荣耀v10有点卡怎么办 荣耀10有点卡怎么办