MySQL中添加、删除字段,使用SQL语句操作

1.新增字段

alter table table1
add col1 int(2) not NULL DEFAULT 0 COMMENT '注释1',
add col2 VARCHAR(300) DEFAULT NULL COMMENT '注释2'                        语法:alter table 表名 add 列名 int(2) 字段数据类型、长度 NOT NULL (是否可为空)DEFAULT 0  默认值

2.删除字段

alter table id_name drop column age,drop column address;


语法:alter table 表名 drop column 列名
下班记得打卡
原文地址:https://www.cnblogs.com/onlyzhangmeng/p/13901099.html