Relacionamento de tabela mysql error 1452 - & error 1061

0 respostas
W

estou tentando fazer um relacionamento de duas tabela empresa com usuario

Executing:
ALTER TABLE wassystem_comanda.usuario
ADD INDEX ID_EMPRESA_idx (EMPRESA ASC);
ALTER TABLE wassystem_comanda.usuario
ADD CONSTRAINT ID_EMPRESA
FOREIGN KEY (EMPRESA)
REFERENCES wassystem_comanda.empresa (ID)
ON DELETE NO ACTION
ON UPDATE NO ACTION;

Operation failed: There was an error while applying the SQL script to the database.
ERROR 1061: Nom de clef ‘ID_EMPRESA_idx’ déjà utilisé
SQL Statement:
ALTER TABLE wassystem_comanda.usuario
ADD INDEX ID_EMPRESA_idx (EMPRESA ASC)

// quando a tabela tava com registro tava com esse erro

Operation failed: There was an error while applying the SQL script to the database.
ERROR 1452: Cannot add or update a child row: a foreign key constraint fails

// após apagar os registros

Operation failed: There was an error while applying the SQL script to the database.
Executing:
ERROR 1061: Nom de clef ’ ID_EMPRESA_idx ’ déjà utilisé

Criado 23 de abril de 2016
Respostas 0
Participantes 1