读书人

oracle中添加外键时发生异常

发布时间: 2012-03-03 15:33:04 作者: rapoo

oracle中添加外键时发生错误
Error starting at line 1 in command:
alter table PLANT_ASSET add constraint fk_plantAsset_plantAssetType foreign key(TYPEID) references PLANTASSET_TYPE(ID) on delete cascade
Error report:
SQL Error: ORA-02298: 无法验证 (USER_BASK_SYS.FK_PLANTASSET_PLANTASSETTYPE) - 未找到父项关键字
02298. 00000 - "cannot validate (%s.%s) - parent keys not found"
*Cause: an alter table validating constraint failed because the table has
child records.
*Action: Obvious

[解决办法]
你把主键设成外键了!换一个弄成外键就成了,现在你的typeid为主键吧?自己看下

读书人网 >J2EE开发

热点推荐