I'm trying to join tables and add a chave estrangeira
, so that for example, a purchase table has referência
of id
of the buyers table.
I did as follows:
alter table compras add foreign key (compradores_id) references compradores(id);
insert into compras (valor, recebido, data, compradores_id) values (1500, 1, '2016-06-02', 15);
* The% of buyers% only go to id's
* Both columns ( 3
) were set to compradores.id e compras.compradores_id
It accepts the command of int not null
on a good and writes, how can I fix this?