错误码:-2707
错误内容:被引用表[%s]引用索引不存在
创建外键的被引用表无主键或唯一约束
示例:
create table test1(id int,name varchar(20));
--test2创建时则出现报错"-2707:被引用表[TEST1]引用索引不存在"
create table test2(id int,name varchar(20),constraint fk_test2_id foreign key(id) references test1(id));
在被引用表的相关字段创建主键或唯一约束/索引,以下三种方式均可
alter table test1 add constraint pk_test1_id primary key(id);
alter table test1 add constraint uk_test1_id unique(id);
create unique index u_idx_test1_01 on test1(id);
文章
阅读量
获赞