1. foreign key 추가
alter table '추가할 테이블 명' add constraint '제약조건명' foreign key '컬럼명' references '부모 테이블 명' ('참조하는 PK 컬럼명') [ON DELETE CASCADE/ ON UPDATE CASCADE];
2. foreing key 삭제
alter table '테이블명' drop foreign key '제약조건명';
3. 테이블에서의 외래키 확인방법
select*from information_schema.table_constraints where table_name='테이블명';
4. 데이터베이스(스키마)에서의 외래키 확인방법
select * from information_schema.table_constraints where constraint_schema = '데이터베이스명';
'DB' 카테고리의 다른 글
Error: Packets out of order. Got: 0 Expected: (0) | 2022.08.01 |
---|---|
nginx 새로고침 (0) | 2022.07.09 |
504 Gateway Time-out nginx & MySQL InnoDB Buffer Pool Resizing Online mysql 버퍼 크기 조절 (0) | 2022.05.09 |
mysql db 백업 (0) | 2022.04.07 |
ubuntu mysql 대소문자 (0) | 2022.04.07 |