1

I've created a table in MySQL named 'ShoppingCart', but it shows error 1005. What's the mistake here?

 mysql> create table ShoppingCart(
    -> Current_Purchases varchar(100),
    -> Previous_Purchases varchar(100),
    -> Phone_No int(20),
    -> constraint fk_shop foreign key (Phone_No) references Registration(Phone_No));
ERROR 1005 (HY000): Can't create table 'infoproject.shoppingcart' (errno: 150)

The other table 'Registration' is already created and the same column is present with the same datatype.

4

1 回答 1

1

外键引用的列必须是唯一的。Phone_No在您的情况下,错误似乎是由于Registration. 更改Registration表以在 上添加唯一索引Phone_No

于 2013-11-09T08:31:49.313 回答