create table table_name(
col dataype,
co12 datype,
...
primary key (col)
);
alter table table_name
add primary key (col);
alter table person
drop primary key;
한 테이블을 다른 테이블과 연결해주는 역할이며, 참조 되는 테이블의 항목은 그 테이블의 기본키
create table table_name(
col dataype,
co12 datype,
...
foreign key (col) references pk_table(pk_col)
);
show create table table_name;
alter table tablename
drop foreign key fk_constraint;
mul은 그대로 유지되지만, foreign key references는 삭제되었음을 알수있다.
alter table table_name
add foreign key (col) references pk_table (pk_name);