【发布时间】:2013-04-05 19:36:21
【问题描述】:
怎么了?
mysql> create table price(
-> p_code char(1) not null,
-> p_description varchar(20),
-> p_rentfee decimal(2,2) not null,
-> p_dylatefee decimal(2,2));
Query OK, 0 rows affected (0.18 sec)
mysql> create table movie(
-> mv_no char(4) not null,
-> mv_name varchar(50) not null,
-> mv_year char(4) not null,
-> mv_cost decimal(2,2) not null,
-> mv_genre varchar(15) not null,
-> p_code char(1) not null,
-> foreign key (p_code) references price(p_code));
ERROR 1215 (HY000): Cannot add foreign key constraint
mysql>
【问题讨论】:
-
p_code是您的price表中的主键吗? -
这只是一个猜测,但
price.p_code和movie.p_code不应该是它们自己表中的索引吗?
标签: mysql