首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > oracle >

oracle主外键约束有关问题,求教

2012-02-28 
oracle主外键约束问题,求教!我在oracle的scott用户下创建了两张表,A表和B表,其中A表的主键是B表的字段,然

oracle主外键约束问题,求教!
我在oracle的scott用户下创建了两张表,A表和B表,其中A表的主键是B表的字段,然后我写了添加约束的代码 
alter table B add constraint FK_A_B foreign key (B表与A表约束的字段) references A(A表主键);
然后我直接给B表插入数据(A表没数据),然后成功了,这是为什么呢? 这个问题一般会是什么地方出错了? 
求教!

[解决办法]
官网给的解释:

Issued Against Child Table 子表的约束

OK only if the foreign key value exists in the parent key or is partially or all null

能插入成功,是因为A表为空的关系。
[解决办法]

探讨
官网给的解释:

Issued Against Child Table 子表的约束

OK only if the foreign key value exists in the parent key or is partially or all null

能插入成功,是因为A表为空的关系。

[解决办法]
外键字段设置成 not null了吗。

热点排行