Add FK to mysql table

0

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:

asked by anonymous 03.10.2018 / 16:35

2 answers

2

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

03.10.2018 / 17:46
0

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

    
09.10.2018 / 15:49