MySQL创建数据库需要自行创建,数据库名称可以为【schoolDB】,字符集【utf8】,排序规则【utf8_general_ci】
1、学生表DDL
CREATE TABLE `student` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '学号',
`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、插入学生信息DML
insert into student values(0,'2024-02-25 10:10:10','赵灵儿','123',
'15698746254',16,'女','逍遥哥哥,你终于找到我了。');
insert into student values(0,'2024-02-25 10:10:10','王语嫣','123',
'15698746254',17,'女','慕容复,我与你不共戴天。');
insert into student values(0,'2024-02-25 10:10:10','龙姑娘','123',
'15698746254',22,'女','我想过过过儿过过的日子。');
insert into student values(0,'2024-02-25 10:10:10','杨过','123',
'15698746254',18,'男','一遇杨过误终身。');
insert into student values(0,'2024-02-25 10:10:10','杨逍','123',
'15698746254',27,'男','杨过跟程英的大儿子。');
insert into student (userName,age,introduce)values('黄衣女子',26,'杨过与龙姑娘的大女儿。');
实际效果:
3、基础查询测试DQL
select * from student;
select userName as 姓名,age '年龄',sex '性别',introduce '简介'
from student
where ppwd is not null;
select * from student limit 2,3;
select * from student order by age desc limit 3;
select distinct sex '性别类型' from student;
实际效果: