[MySQL] foreign key(외래키) 추가, 삭제, 확인 방법
1.foreign key 추가
alter table [추가할테이블명] add constraint [제약조건명] foreign key(컬럼명)
references [부모테이블명] (PK컬럼명) [ON DELETE CASCADE / ON UPDATE CASECADE];
2. foreign key 삭제
alter table [테이블명] drop foreign key [제약조건명];
3. foreign key 확인 방법
3.1 테이블 기준 확인
select * from information_schema.table_constraints where table_name = '테이블명';
3.2 데이터베이스 기준 확인
select * from information_schema.table_constraints where constraint_schema = '데이터베이스명';