数据库名称可以为【schoolDB】,字符集【utf8】,排序规则【utf8_general_ci】
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) DEFAULT NULL COMMENT '年龄',
`sex` char(2) DEFAULT NULL COMMENT '性别',
`introduce` varchar(255) DEFAULT NULL COMMENT '简介',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=26 DEFAULT CHARSET=utf8;
2、插入数据——DML语句
INSERT INTO student VALUES(0,'2024-02-25 20:03:00', '宋江','123466','15963247887',50,'男','000');
INSERT INTO student VALUES(0,'2024-02-25 20:03:00', '林冲','123466','15963247887',44,'男','000');
INSERT INTO student VALUES(0,'2024-02-25 20:03:00', '鲁智深','123466','15963247887',32,'男','000');
INSERT INTO student VALUES(0,'2024-02-25 20:03:00', '武松','123466','15963247887',40,'男','000');
INSERT INTO student VALUES(0,'2024-02-25 20:03:00', '诸葛亮','123466','15963247887',30,'男','000');
INSERT INTO student VALUES(0,'2024-02-25 20:03:00', '刘备','123466','15963247887',19,'男','000');
INSERT INTO student VALUES(0,'2024-02-25 20:03:00', '曹操','123466','15963247887',36,'男','000');
INSERT INTO student VALUES(0,'2024-02-25 20:03:00', '关羽','123466','15963247887',56,'男','000');
INSERT INTO student VALUES(0,'2024-02-25 20:03:00', '张飞','123466','15963247887',25,'男','000');
INSERT INTO student VALUES(0,'2024-02-25 20:03:00', '曹丕','123466','15963247887',23,'男','000');
INSERT INTO student VALUES(0,'2024-02-25 20:03:00', '周瑜','123466','15963247887',28,'男','000');
INSERT INTO student VALUES(0,'2024-02-25 20:03:00', '大乔','123466','15963247887',20,'女','000');
INSERT INTO student (userName,age,introduce) VALUES('小乔',30,'555');
select * from student;
3、查询语句——DQL语句
#基础查询
select * from student;
#非空筛选
select userName as '姓名',age 年龄,sex '性别',introduce '简介'
from student where pwd is not null;
#去重查询
select distinct sex '性别'from student;
#分页查询关键字limit有两个参数,只写一个代表查询条数
#第一个参数代表起始查询位置,第二个代表查询行数
#计算机原始分页条数=(当前页-1)*显示页数
select *from student limit 7,4;
#排序
select *from student order by age asc;