1.学生表
CREATE TABLE `student` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`createDate` datetime DEFAULT NULL,
`userName` varchar(20) DEFAULT NULL,
`pwd` varchar(36) DEFAULT NULL,
`phone` varchar(11) DEFAULT NULL,
`age` tinyint(3) DEFAULT NULL,
`sex` char(2) DEFAULT NULL,
`introduce` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
2.插入学生信息
insert into student values (0,'2024-02-25 10:00:00','赵灵儿','123',
'15612345678',16,'女','逍遥哥哥');
insert into student values (0,'2024-02-25 10:00:00','王语嫣','123',
'15612345678',16,'女','慕容复我与你不共戴天');
insert into student values (0,'2024-02-25 10:00:00','龙姑娘','123',
'15612345678',16,'女','过儿');
insert into student values (0,'2024-02-25 10:00:00','杨过','123',
'15612345678',16,'男','一遇杨过误终身');
insert into student values (0,'2024-02-25 10:00:00','杨逍','123',
'15612345678',16,'男','光明左使');
insert into student values (0,'2024-02-25 10:00:00','东方不败','123',
'15612345678',16,'女','天下第一');
insert into student values (0,'2024-02-25 10:00:00','典韦','123',
'15612345678',16,'男','步战无双');
3.基础查询测试DQL
#基础查询
SELECT * FROM student;
#筛选列与筛选数据行
select userName ,age,sex,introduce
from student
where pwd is not null;
#分页,limit有两个重载函数常用
#1.一个参数为显示条数
#2.一个参数为从那条开始查询(下标从零开始计算),零一参数为显示条数
select * from student limit 3,2;#从4(0-3)开始查询查第二条
#排序,order by根据数值类型进行排序会比较准确
select * from student order by age desc limit 3;
#去重语句distinct
select distinct sex from student;
标签:25,00,DEFAULT,必备,学习,student,MySQL,NULL,into From: https://blog.csdn.net/2301_82241198/article/details/137009059