mysql中添加字段,添加索引sql语句
alter table `tbl_stu` add column `stu_name` varchar(20) DEFAULT '' COMMENT '学生姓名' after `stu_no`;
alter table `tbl_stu` modify column `stu_name` varchar(30) DEFAULT '' COMMENT '学生姓名';
alter table `tbl_stu` drop column `stu_name`;
CREATE TABLE `tbl_student` (
`id` varchar(32) NOT NULL COMMENT '主键ID',
`stu_no` varchar(12) DEFAULT '' COMMENT '学号',
`stu_name` varchar(20) DEFAULT '' COMMENT '学生姓名',
PRIMARY KEY (`id`),
KEY `idx_tbl_stu_no` (`stu_no`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='学生表';
alter table `tbl_stu` add index tbl_idx(`stu_no`);
alter table `tbl_stu` drop index `idx_tbl_stu_no`;