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 列名
posted @ 2020-10-30 11:06  了悟  阅读(3555)  评论(0编辑  收藏  举报