본문 바로가기

프로그래밍/MySQL

[mysql] 그때그때 생각 안나는 명령어들


1. ALTER

assign foreign key 

ALTER TABLE table_name ADD foreign key(column_name) REFERENCES target_table_name(column_name) ON DELETE RESTRICT ON UPDATE RESTRICT;

assign primary key

ALTER TABLE  table_name MODIFY column_name type primary key;

add auto increment property

ALTER TABLE table_name MODIFY column_name type auto_increment;

add not null property

ALTER TABLE table_name MODIFY column_name type not null;