5
I want to reference a foreign key from a different bank, saw on some forums that it is only necessary to do `nome_database`.`nome_tabela`
, but it’s not working.
My code is this::
ALTER TABLE `relatorio_gestao`.`usuario_setores`
ADD CONSTRAINT `id_unidade_ifpe`
FOREIGN KEY (`id_unidade_ifpe`)
REFERENCES `bancobase`.`unidade_ifpe` (`id_unidade_IFPE`)
ON DELETE NO ACTION
ON UPDATE NO ACTION;
What I’m doing wrong?
There are no mistakes in the construction of
FOREIGN KEY
. A database isrelatorio_gestao
and the other isbancobase
? The field name in the tableunidade_ifpe
isid_unidade_IFPE
(capital)?– Lucas Henrique
I created the Databases and tables on my machine and it worked perfectly. Your code is correct. Are the two tables INNODB? Are the columns of the same type and have the same size? When you reply, put comment and at the beginning put arroba and name_do_usuario (Lucas Henrique) to notify me.
– Lucas Henrique