脚本如下:
--修改INFO_CUS_COMPLEX_TAX序号类型
alter table INFO_CUS_COMPLEX_TAX add AA number;
-- Add/modify columns
alter table INFO_CUS_COMPLEX_TAX modify NO null;
--禁用约束
alter table INFO_CUS_COMPLEX_TAX disable constraint PK_INFO_COMPLEX_TAX1;
update INFO_CUS_COMPLEX_TAX set AA=NO,NO=null;
commit;
alter table INFO_CUS_COMPLEX_TAX modify NO number(4);
update INFO_CUS_COMPLEX_TAX set NO=AA,AA=null;
commit;
alter table INFO_CUS_COMPLEX_TAX drop column AA;
alter table INFO_CUS_COMPLEX_TAX modify NO not null;
--启用约束
alter table INFO_CUS_COMPLEX_TAX enable constraint PK_INFO_COMPLEX_TAX1;
问题:当禁用约束后,执行update时,依然会说“ORA-00001违反唯一约束条件(PK_INFO_COMPLEX_TAX1)”,我已经禁用了,请问这是什么原因呀?求教。。。。。
------解决方案--------------------
- SQL code
create table t(id int primary key);SQL> select * from t; ID---------------------------------------SQL> insert into t values (1); 1 row insertedSQL> commit; Commit completeSQL> alter table t disable constraint SYS_C0038505; --主键失效 Table alteredSQL> insert into t values (1); --可以正常插入 1 row insertedSQL> commit; Commit completeSQL> select * from t; ID--------------------------------------- 1 1
------解决方案--------------------
你是不是启用约束的时候报的错啊???你数据不唯一了,你再启用主键会报错的
alter table INFO_CUS_COMPLEX_TAX enable constraint PK_INFO_COMPLEX_TAX1;
------解决方案--------------------