create table bookstore3(
bookid int not null,
price char(10) not null,
publisher varchar(10) not null unique,
bookname char (10) not null,
constraint bookstore3_pk primary key (bookid)
);
create table sale2(
bookname char(10) not null,
bookid int not null,
price char(10) not null,
timedate char (10) not null,
number varchar(10) not null unique,
constraint sale2_pk primary key (bookname),
constraint sale2_bookstore3_fk foreign key (bookid)
references bookstore3(bookid)
);
create table stock2(
bookname char(10) not null,
number varchar(10) not null unique,
publisher char(10) not null,
price char(10) not null,
constraint stock2_pk primary key (bookname),
constraint stock2_bookstore3_fk foreign key (bookname)
references bookstore3(bookname)
);
下面的提示是
Msg 1776, Level 16, State 0, Line 18
在被引用表 'bookstore3' 中没有与外键 'stock2_bookstore3_fk' 中的引用列列表匹配的主键或候选键。
Msg 1750, Level 16, State 0, Line 18
无法创建约束。请参阅前面的错误消息。
bookid int not null,
price char(10) not null,
publisher varchar(10) not null unique,
bookname char (10) not null,
constraint bookstore3_pk primary key (bookid)
);
create table sale2(
bookname char(10) not null,
bookid int not null,
price char(10) not null,
timedate char (10) not null,
number varchar(10) not null unique,
constraint sale2_pk primary key (bookname),
constraint sale2_bookstore3_fk foreign key (bookid)
references bookstore3(bookid)
);
create table stock2(
bookname char(10) not null,
number varchar(10) not null unique,
publisher char(10) not null,
price char(10) not null,
constraint stock2_pk primary key (bookname),
constraint stock2_bookstore3_fk foreign key (bookname)
references bookstore3(bookname)
);
下面的提示是
Msg 1776, Level 16, State 0, Line 18
在被引用表 'bookstore3' 中没有与外键 'stock2_bookstore3_fk' 中的引用列列表匹配的主键或候选键。
Msg 1750, Level 16, State 0, Line 18
无法创建约束。请参阅前面的错误消息。
解决方案 »
- 100分来散分的,跟贴者都有!
- 表A,字段如下(RecordID,DoorList),其中DoorList,为nvarchar,值为:'1,3,4',有一变量S='3,4',显示DoorList中含有3,或4的RecordID记录.
- 请问:如何把image文件,保存入sql server2005中呢?
- 问问一条简单的sql语句
- sql server 查询分析器问题 请教高手是什么原因怎么改阿?
- FCKEditor中,输入的多行内容,为什么只有第一行数据能插入到数据库中?其它行却不能?
- 求一条sql语句,请大家帮忙
- 非常非常非常奇怪的问题
- 只要一些逻辑就可以了
- vfp中怎么让一个表单得到焦点?
- 一个简单的关于SQL数据库索引的问题。
- 询问一个存储过程的简单问题,请帮忙,谢谢。。
你的bookstore3表中bookname又不是主键,你怎么引用?外键引用的必须是其它表的主键列。