1.DDL
CREATE TABLE `student` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '学号',
`createDate` datetime DEFAULT NULL COMMENT '创建日期',
`userName` varchar(20) DEFAULT NULL COMMENT '姓名',
`pwd` varchar(36) DEFAULT NULL COMMENT '密码',
`phone` varchar(11) DEFAULT NULL COMMENT '手机号',
`age` tinyint(3) unsigned DEFAULT NULL COMMENT '年龄',
`sex` char(2) DEFAULT '男' COMMENT '性别',
`introduce` varchar(255) DEFAULT NULL COMMENT '介绍',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=29 DEFAULT CHARSET=utf8;
2.DML
INSERT INTO `student` VALUES (21, '2024-02-25 10:10:10', '马牛', '123456', '15612345678', 20, '女人', '团长');
INSERT INTO `student` VALUES (22, '2024-02-25 10:10:10', '丁成', '123457', '15612345698', 19, '女人', '队员');
INSERT INTO `student` VALUES (23, '2024-02-25 10:10:10', '宋亚', '123466', '15612349678', 20, '女人', '队员');
INSERT INTO `student` VALUES (24, '2024-02-25 10:10:10', '张员', '129456', '15662345678', 21, '女人', '队员');
INSERT INTO `student` VALUES (25, '2024-02-25 10:10:10', '严翔', '183456', '15612345678', 22, '女人', '队员');
INSERT INTO `student` VALUES (26, '2024-02-25 10:10:10', '贺军', '123459', '15612344678', 24, '女人', '队员');
INSERT INTO `student` VALUES (27, '2024-02-25 10:10:10', '刘为', '123456', '15612345678', 23, '女人', '队员');
INSERT INTO `student` VALUES (28, NULL, '悠悠球琛
3.DQL
select count(*) from student where age < 25;
select max(age) from student;
select min(age) from student;
select avg(age) from student;
select sum(age)/(select count(*) from student) 'sum计算平均年龄',avg(age)'平均年龄'from student;