1.学生表DDL 字符集[utf8]
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) DEFAULT NULL COMMENT '年龄',
`sex` char(2) DEFAULT NULL COMMENT '性别',
`introduce` varchar(255) DEFAULT NULL COMMENT '简介',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
2.插入学生信息DML
i
nsert into student VALUES(0,'2024-3-15 12:45:36','美乐乐','245697','1478963325' ,19,'女','路阿啦啦啦');
insert into student values(0,'2024-2-06 13:16:22','东方曜','154874','147896325'
,22,'男','猜猜我是谁');
insert INTO student VALUES(0,'2024-03-19 10:25:00','东方镜','154687','147896325',26,'女','路噜噜');
insert INTO student VALUES(0,'2024-03-19 10:25:00','行云','154687','147896325'
,27,'男','咯咯哒过来');studentstudentstudent
insert INTO student VALUES(0,'2024-08-09 10:25:00','咯咯哒','154687','147896325'
,26,'女','放肆');
insert INTO student VALUES(0,'2024-03-25 10:25:00','鬼谷子','154687','147896325'
,26,'女','额规范的地方');
insert INTO VALUES(0,'2024-06-19 10:25:00','西施','154687','147896325'
,20,'女','路地方边上');
实际效果:
3.基础查询测试DQL
#基础查询
SELECT * FROM student;
#筛选列(匿名)与筛选数据行
select userName as 姓名, age,'年龄',sex '性别',introduce '简介' from student
where pwd is not null;
#分页limit 有两个重载函数常用,
#1、一个班参数为显示条数
#2、 一个参数为从那条开始查询(下标从0开始计算),零一参数为显示条数
SELECT * from student limit 3,2;
#排序,oredr by 根据数值类型进行排序会比较准确
select * from student order by age desc limit 3;
#去重语句 distinct
SELECT DISTINCT sex '性别类型' from student;
标签:COMMENT,25,DEFAULT,DML,2024,student,SQL,DQL,NULL
From: https://blog.csdn.net/2401_82382843/article/details/137009001