DDL
CREATE TABLE `studentid` (
`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 NULL COMMENT '性别',
`introduce` varchar(255) DEFAULT NULL COMMENT '简介',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=19 DEFAULT CHARSET=utf8;
DML
INSERT INTO studentid VALUES(0,'2023-12-21','盘古','123456','29833376362',240,'神','开天辟地第一人');
INSERT INTO studentid VALUES(0,'2023-12-21','女娲','123456','29833376362',240,'女','造娃第一人');
INSERT INTO studentid VALUES(0,'2023-12-21','伏羲','123456','29833376362',240,'神','先天八卦');
INSERT INTO studentid VALUES(0,'2023-12-21','螺祖','123456','29833376362',225,'神','教会百姓养蚕织布');
INSERT INTO studentid VALUES(0,'2023-12-21','神农','123456','29833376362',225,'神','尝百草,死于断肠草下');
INSERT INTO studentid VALUES(0,'2023-12-21','蚩尤','123456','29833376362',225,'男','锻造大神,坐下食铁巨兽');
INSERT INTO studentid(username,age,introduce) VALUES('仓颉',124,'中国形象文字');
DQL
#5个常用的聚合函数count(x),max(x),min(x),sum(x),avg(x);
SELECT count(*) FROM `studentid` where pwd is not null;
SELECT max(age) '最大年龄',min(age)'最小年龄'from studentid;
SELECT sum(age)'总年龄' from studentid;
SELECT avg(age) '平均年龄'from studentid;
标签:COMMENT,INSERT,studentid,聚合,函数,DEFAULT,VALUES,MYSQL,NULL
From: https://blog.csdn.net/2401_83904930/article/details/137145678