-1
I’m trying to create a FK for a table, I don’t understand syntax error, but the TOAD returns the message that cannot create FK. Tables are created in the database, and Pks are right.
ALTER TABLE minsarh.perguntas ADD CONSTRAINT fk_perg_perg FOREIGN KEY (id_ds_pergunta)
REFERENCES minsarh.tb_ds_pergunta (id_ds_pergunta) ON UPDATE NO ACTION ON DELETE NO ACTION;
Looup Error - Mysqk Database Error: Cannot add Foreign key Constraint
I can’t identify the error.
Can someone give me an idea??? Thank you!
Check PK/FK name, type and size
– Costamilam
CREATE TABLE minsarh.tb_ds_question (
id_ds_pergunta
int(11) unsigned NOT NULL AUTO_INCREMENT ,ds_pergunta
varchar(255) NOT NULL ,PRIMARY KEY (id_ds_pergunta
) ) CREATE TABLEperguntas
(id_pergunta
int(10) unsigned NOT NULL AUTO_INCREMENT, PRIMARY KEY (id_pergunta
), Alter Table minsarh.questions add CONSTRAINT fk_questions_perg FOREIGN KEY (id_ds_question) REFERENCES tb_ds_question (id_ds_question) ON DELETE NO ACTION ON UPDATE NO ACTION;– Ivan
So, First thank you for the Wictor reply, but I can’t identify differences, and I’ve tried to change the name of the Constraint, decreasing and still not accepting. I pasted in the previous answer the creation script. if Voce can look.
– Ivan
You created FK before adding CONSTRANIT?
– Costamilam