Changes a relationship between two mysql fields

0

I have my event table ( tbl_eventos ), where I'm going to fetch the contact_id field from the contacts table ( tbl_contactos ). To go create this link, I used the following:

ALTER TABLE 'tbl_eventos'
  ADD CONSTRAINT 'tbl_eventos_ibfk_3' FOREIGN KEY ('id_contacto') REFERENCES 'tbl_contactos' ('id_contacto');

What happens now is that my contact table has changed its name, meaning it went from tbl_contactos to tbl_contactos_cliente . How can I make this change? The code above was generated by phpmyadmin.

    
asked by anonymous 15.07.2014 / 20:30

1 answer

1

I know from comments that it's not exactly what I wanted, but I think the best solution is to run DROP and ADD manually.

ALTER TABLE tbl_eventos DROP CONSTRAINT tbl_eventos_ibfk_3;

ALTER TABLE tbl_eventos ADD CONSTRAINT [NOME_CONSTRAINT] FOREIGN KEY (id_contacto) REFERENCES tbl_contactos_cliente (id_contacto);

(And would put FK_Eventos_Contacts of name:])

    
16.07.2014 / 00:58