总是忘记的mysql语句

设置外键

alter table table_name_1 add constraint fk_外键名字 foreign key (column_name_1) references table_name_2(column_name_2)

 

设置联合主键

alter table table_name add constraint pk_主键名字 primary key(column_name_1,column_name_2)

 删除列

alter table table_name drop column column_name

 添加列

alter table table_name add column column_name column_type

 删除表中所有数据

truncate table table_name;

 

你可能感兴趣的:(mysql)