2017-02-09 1 views
-2

MYSQL에서 외래 키에 이름을 지정하지 않았습니다. 그러나 지금 나는 그것을 떨어 뜨릴 필요가있다. 아무도 나를 도울 수 있습니까 ??DROP FOREIGN KEY

select 
    table_name, 
    column_name, 
    constraint_name, 
    referenced_table_name, 
    referenced_column_name 
from information_schema.key_column_usage 
where table_name = 'Your_table'; 

한 다음 드롭 문 아래 사용 : 당신의 제약 조건의 이름을 찾을 수 아래

답변

0

사용

alter table your_table drop foreign key <foreign_key_constraint_name>; 
+0

는 SHOW을 참조하기에 충분한 표 tablename'을 CREATE'아닌가 외래 키 이름? –

+0

샘을 처리하는 데는 항상 여러 가지 방법이 있습니다. 방금 그 중 하나를 골랐어. 게다가 실제 쿼리를 선호합니다. – GurV

0
SELECT 
constraint_name 
FROM 
information_schema.REFERENTIAL_CONSTRAINTS 
WHERE 
constraint_schema = 'Blog' AND table_name = 'posts'; 


ALTER TABLE posts DROP Foreign Key keyname; 
관련 문제