maria-discuss team mailing list archive
-
maria-discuss team
-
Mailing list archive
-
Message #00123
Re: Problems with Foreign Key
Hi, Alexandre!
On Mar 30, Alexandre Almeida wrote:
>
> Hi all,
>
> Any idea why I am getting this error:
>
>
> A) ERROR
>
> ALTER TABLE login ADD CONSTRAINT fk_db_perfil FOREIGN KEY (id_perfil)
> REFERENCES db_perfil (id_perfil) ON DELETE NO ACTION ON UPDATE NO ACTION;
> ERROR 1005 (HY000): Can't create table 'dbhomo_aa.#sql-c1f_281' (errno:
> 150)
you tell us too litle to guess.
perhaps there's no db_perfil table in the dbhomo_aa database ?
As the manual explains, after errno:150 you can use SHOW ENGINE INNODB
STATUS to see a detailed error message
> B) HERE IT WORKS
>
> ALTER TABLE login ADD CONSTRAINT fk_db_perfil FOREIGN KEY
> (id_perfil) REFERENCES dbhomo.db_perfil (id_perfil) ON DELETE NO ACTION ON
> UPDATE NO ACTION;
> Query OK, 35199 rows affected (3,27 sec)
> Records: 35199 Duplicates: 0 Warnings: 0
>
> Note that when I change the database to the original database the command
> works as expected. Both tables are innodb, the permissions are fine.
>
> Thanks,
>
> Alex
>
Regards,
Sergei
References