본문 바로가기
MySql

MySQL Drop 외래 키 오류 152

by 베이스 공부 2021. 2. 3.
반응형

다음을 사용하여 여러 외래 키를 삭제하려고합니다.

ALTER TABLE `table` DROP FOREIGN KEY `fk_table_users1` , DROP FOREIGN KEY `fk_table_accounts1` , DROP FOREIGN KEY `fk_table_data1` ;

하지만 오류를 반환합니다.

Error on rename of './db/table' to './db/#sql2-179c-288289' (errno: 152)

SHOW ENGINE INNODB STATUS 를 실행했습니다.

120725 12:38:37 Error in dropping of a foreign key constraint of table db/table,
in SQL command
ALTER TABLE `table` DROP FOREIGN KEY `fk_table_users1` , DROP FOREIGN KEY `fk_table_accounts1` , DROP FOREIGN KEY `fk_table_data1` 
Cannot find a constraint with the given id fk_table_users1.

SHOW CREATE TABLE 'table' 출력 :

CREATE TABLE `table` (
 `id` int(11) NOT NULL auto_increment,
 `data_id` int(11) NOT NULL,
 `account_id` int(11) NOT NULL,
 `status` enum('pending','complete') NOT NULL default 'pending',
 `created_at` datetime NOT NULL,
 `created_by` int(11) NOT NULL,
 PRIMARY KEY  (`id`),
 KEY `fk_orders_users1` (`created_by`),
 KEY `fk_orders_data1` (`data_id`),
 KEY `fk_orders_accounts1` (`account_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8

그러나 phpmyadmin을 통해 구조를 보면 동일한 이름의 외래 키가 나열됩니다. 외래 키를 삭제하기 전에 다른 작업을 수행해야합니까?

 

해결 방법

 


KEY is normally a synonym for INDEX.


 

참조 페이지 https://stackoverflow.com/questions/11649092

 

 

반응형

댓글