被引用表 'good_publisher' 中没有与外键 'FK__goods__g_name_' 的引用列的列表匹配的主键或候选键。 10
createtablegood_publisher(g_pub_namechar(10)notnull,g_pub_numchar(10)primarykey,g_pub...
create table good_publisher(g_pub_name char(10) not null,g_pub_num char(10) primary key,g_pub_password char(9) not null,g_pub_goods char(10),g_pub_good_num char(10),g_pub_phone char(20));create table goods(g_name char(10),g_num char(10)not null,publisher_name char(10),publisher_num char(10),publisher_phone char(20),foreign key(g_name)references good_publisher(g_pub_goods),foreign key (g_num)references good_publisher(g_pub_good_num), foreign key(publisher_name)references good_publisher(g_pub_name),foreign key(publisher_num)references good_publisher(g_pub_num),foreign key(publisher_phone)references good_publisher(g_pub_phone));
展开
1个回答
展开全部
create table good_publisher
(
g_pub_name char(10) not null,
g_pub_num char(10) primary key
,g_pub_password char(9) not null,
g_pub_goods char(10),
g_pub_good_num char(10),
g_pub_phone char(20)
);
create table goods(
g_name char(10),
g_num char(10)not null,
publisher_name char(10),
publisher_num char(10),
publisher_phone char(20),
foreign key(g_name)references good_publisher(g_pub_goods),--这里有问题,主键只是在g_pub_num字段上
foreign key (g_num)references good_publisher(g_pub_good_num), --这里有问题,主键只是在g_pub_num字段上
foreign key(publisher_name)references good_publisher(g_pub_name),--这里有问题,主键只是在g_pub_num字段上
foreign key(publisher_num)references good_publisher(g_pub_num),--这个关系是没得问题的
foreign key(publisher_phone)references good_publisher(g_pub_phone)--这里有问题,主键只是在g_pub_num字段上
);
追问
实在不知怎么改,劳烦大哥给小弟改改行不?
追答
create table good_publisher
(
g_pub_name char(10) not null,
g_pub_num char(10) primary key
,g_pub_password char(9) not null,
g_pub_goods char(10),
g_pub_good_num char(10),
g_pub_phone char(20)
);
create table goods(
g_name char(10),
g_num char(10)not null,
publisher_name char(10),
publisher_num char(10),
publisher_phone char(20),
foreign key(publisher_num)references good_publisher(g_pub_num),--这个关系是没得问题的
);
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询