注册
达梦数据库-错误码-[-2707]-分析处理
专栏/技术分享/ 文章详情 /

达梦数据库-错误码-[-2707]-分析处理

PYZ 2024/06/07 791 1 0
摘要

错误码:-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);
评论
后发表回复

作者

文章

阅读量

获赞

扫一扫
联系客服