Answer the question
In order to leave comments, you need to log in
How to remove FOREIGN KEY constraint between two tables in Mysql?
Unable to remove contraints in MariaDB.
1. Check for restrictions:
SHOW CREATE TABLE `patient_patientquestionnaireanswer`;
...
PRIMARY KEY (`id`),
KEY `constraint_name_1` (`column_1_id`) USING BTREE,
KEY `constraint_name_2` (`column_2_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=330 DEFAULT CHARSET=utf8
select `CONSTRAINT_NAME`, `TABLE_NAME`, `COLUMN_NAME`, `REFERENCED_TABLE_NAME`, `REFERENCED_COLUMN_NAME`
from INFORMATION_SCHEMA.KEY_COLUMN_USAGE
where REFERENCED_TABLE_SCHEMA = 'my_db' and TABLE_NAME = 'table_with_contraints';
ALTER TABLE `my_db`
DROP FOREIGN KEY `constraint_name`;
Kernel Error: Error( 1091 ) 42000: "Can't DROP FOREIGN KEY `constraint_name`; check that it exists"
Answer the question
In order to leave comments, you need to log in
ALTER TABLE `table_with_contraints`
DROP FOREIGN KEY `constraint_name`;
constraint_name_1
. And maybe constraint_name
it's a column name, not a value.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question