mysql> create table a1 (i int, j int); Query OK, 0 rows affected (0.17 sec) mysql> create table a2 ( i int , j int, foreign key (i) references a1(i)); ERROR 1005 (HY000): Can't create table '.\test\a2.frm' (errno: 150) mysql> alter table a1 add index (i); Query OK, 0 rows affected (0.16 sec) Records: 0 Duplicates: 0 Warnings: 0 mysql> create table a2 ( i int , j int, foreign key (i) references a1(i)); Query OK, 0 rows affected (0.27 sec)