1. 程式人生 > >mysql 修改表結構

mysql 修改表結構

use 默認值 new ear not varchar data 重命名 int

增加列:

# 增加列:tag(筆記)、sort_num
alter table e_user add tag varchar(50) not null default "筆記" comment ‘標簽‘ after create_timestamp; # 在e_user表的create_timestamp字段後添加tag列
alter table e_user add sort_num int(10) not null  default -1 comment ‘排序號‘

  

刪除列:下面兩種方式都可以

alter table e_user drop column tag_name
alter table e_user drop sort_num

  

重命名表名

alter table old_table rename to new_table;

  

設置列的默認值

設置effect_data表的effective_years默認值為1

alter table effect_data alter effective_years set default 1;

  

mysql 修改表結構