I have already checked and engine and is like InnoDB, in code tbm I did not find error, I had already done the command in another table before then I'm a little lost about the cause, follows the codes of the tables:
I have already checked and engine and is like InnoDB, in code tbm I did not find error, I had already done the command in another table before then I'm a little lost about the cause, follows the codes of the tables:
The problem can be solved by changing the table:
'tb_fatura'
The field you are using from the tb_fatura table ( id_fatura ) to link in the table
Just to include you can create a fk_chave int variable and create the link later (I think it's easier)
alter table tb1
add constraint fk_chave
foreign key (fk_chave)
references tb2 (pk_id)
Embrace