Help with Foreign Key, Mysql - Xampp

Asked

Viewed 28 times

-1

Mysql database
Question 1:
I’m trying to delete a Foreign Key and it’s making this mistake:
#1044 - User denied '@' access to the information_schema database'
Code: alter table informacoesproduto drop foreign key informacoesproduto_ibfk_1;

Question 2:
I wanted to know how to rename a Foreign Key, because when I was creating, I ended up putting a special character in the name(+), so now I’m not able to delete.
Code: alter table informacoesproduto drop foreign key fk_exemplo+teste;

  • Lupart, just ask one question per page.

1 answer

0

Question 1:
As the error shows, he was denied access. This may be because the user who is logged in does not have permission in the table "product information", need to confirm.

To see permissions, use the command: show grants for 'usuario'

Question 2:
Unable to rename a Constraint, you need to erase (drop foreign key) and create again. Put the name in quotes:

alter table informacoesproduto drop foreign key `fk_exemplo+teste`,
      add constraint `nome-correto` foreign key (`nome-do-campo) references `nome-da-tabela`(`nome-do-campo-na-outra-tabela`);
  • Who negatived could please point out where the wrong information is in this answer?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.