天天看點

oracle之怪現狀:删不掉的對象

看以下現象:

更新一條表資料出錯:

update sch_role set name='SUPPORT' where name='SUPPORT1'

java.sql.SQLException: ORA-00001: unique constraint (FCMCORE.UK_BKPM7NJY2ORT1YOIDDC7JG8GJ) violated

提示UK_BKPM7NJY2ORT1YOIDDC7JG8GJ這個unique constraint阻止了我們更新資料。很自然的我們想到先把它删掉:

alter table sch_role drop constraint UK_BKPM7NJY2ORT1YOIDDC7JG8GJ

java.sql.SQLException: ORA-02443: Cannot drop constraint  - nonexistent constraint

詭異的constraint!  明明阻止了我修改表資料,卻在删除的時候找不到它!。

困擾了好久,中間好多曲折,權限問題,鎖什麼的都想過。無果。meta表中似乎沒有這個constraint的資訊。

第二天一想,nonexistent constraint ! 可是說不定它不是一個constraint呢?all_objects中會不會有呢?于是,

select OBJECT_NAME,OBJECT_TYPE from all_objects where object_name like '%UK_BKPM7NJY2ORT1YOIDDC7JG8GJ%'

OBJECT_NAME,OBJECT_TYPE

UK_BKPM7NJY2ORT1YOIDDC7JG8GJ,INDEX

它是一個index! 于是,

drop index "UK_BKPM7NJY2ORT1YOIDDC7JG8GJ"

update sch_role set name='SUPPORT' where name='SUPPORT1'

成功!。

看起來莫名其妙的問題,總有一個切入點。看起來完美無缺的騙局,總能找到破綻。看起來強大的對手,總有弱點。看你要下多大的決心。