首先我们创建student数据表
CREATE TABLE `student` (
`id` int NOT NULL AUTO_INCREMENT COMMENT '学号',
`name` varchar(30) NOT NULL DEFAULT '匿名' COMMENT '姓名',
`pwd` varchar(20) NOT NULL DEFAULT '123456' COMMENT '密码',
`sex` varchar(2) NOT NULL DEFAULT '女' COMMENT '性别',
`birthday` datetime DEFAULT NULL COMMENT '出生日期',
`address` varchar(100) DEFAULT NULL COMMENT '家庭住址',
`email` varchar(50) DEFAULT NULL COMMENT '邮箱',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
1、把表student重命名为student1
alter table student rename as student1;
2、给student1表添加字段age
alter table student1 add age int;
3、修改age的数据类型为varchar(11)
alter table student1 modify age varchar(11);
3、把字段age重命名为age1
alter table student1 change age age1 varchar(11);
4、删除字段
alter table student1 drop age1;
5、查看student1最后的表结构和详细信息
desc student1;