Sometimes we get this error on creating table in MySQL.This error will come when we use the constraint with the same name that is already used somewhere else.
If the table you're trying to create includes a foreign key constraint, and you've provided a name for that constraint, then remember that it must be unique within the whole database. Run the below query to see if that name is in use somewhere in the database:
SELECT
constraint_name,
table_name
FROM
information_schema.table_constraints
WHERE
constraint_type = 'FOREIGN KEY'
AND table_schema = DATABASE()
ORDER BY
constraint_name;
Hope this will help you :)
0 Comment(s)