mysql操纵表添加字段、一次添加多个字段

属于创建和操纵表的范畴,主题代码为:alter
1.基础添加字段:选择操作的表名,定义字段名、定义字段类型,是否为空

alter table 已有的表名 add 字段名 not null;

2.添加字段的默认值

alter table 已有的表名 add 字段名 not null default 0;

3.添加字段备注(注意英文输入单引号,复制粘贴容易出错)

alter table 已有的表名 add 字段名 not null default 0 comment '备注';

4.指定在某个字段后面添加

alter table 已有的表名 add 字段名 not null default 0 comment '备注' after 已有字段名;

5.添加多个字段

alter table 已有的表名 add 字段名 not null default 0 comment '备注' after 已有字段名,add 字段名 not null default 0 comment '备注' after 已有字段名

猜你喜欢

转载自blog.csdn.net/lvcal_sunday/article/details/115213386