看以下现象:
更新一条表数据出错:
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'
成功!。
看起来莫名其妙的问题,总有一个切入点。看起来完美无缺的骗局,总能找到破绽。看起来强大的对手,总有弱点。看你要下多大的决心。