数据库名称可以为【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) unsigned DEFAULT NULL COMMENT '年龄',
`sex` char(2) DEFAULT NULL COMMENT '性别',
`introduce` varchar(255) DEFAULT NULL COMMENT '简介',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8;
2、插入数据——DML语句
insert into student values(0,'2024-03-24 10:10:10','盘古',
'123456','15621325410',255,'神','开天辟地第一人。');
insert into student values(0,'2024-03-24 10:10:10','女娲',
'123457','15621325410',200,'女','女娲造人');
insert into student values(0,'2024-03-24 10:10:10','伏羲',
'123458','15621325410',225,'神','先天八卦');
insert into student values(0,'2024-03-24 10:10:10','神农',
'123459','15621325410',122,'男','尝百草');
insert into student values(0,'2024-03-24 10:10:10','嫘祖',
'123450','15621325410',145,'神','教会百姓养蚕织布');
insert into student values(0,'2024-03-24 10:10:10','蚩尤',
'123454','15621325410',255,'男','锻造大神');
insert into student (userName,age,introduce) values ('仓颉',125,'中国象形文字');
3、基础查询——DQL语句
#基础查询
select * from student;
#非空筛选
select userName as '姓 名',age 年龄,sex '性 别',introduce '介 绍'
from student where pwd is not null;
#去重
select distinct sex '性别' from student;
#分页
select * from student LIMIT 3,3;
#排序
select * from student ORDER BY age asc;