数据库名称可以为【schoolDB】,字符集【utf8】,排列规则【utf8_general_ci】。
1.创建数据表——DDL语句
CREATE TABLE `student` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '学号',
`createName` 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=MyISAM AUTO_INCREMENT=18 DEFAULT CHARSET=utf8;
2.插入语句——DML语句
INSERT into student VALUES(0,'2022-02-02 10:00:00','葫芦爷爷','123456','12345678912','69','男','葫芦娃的爷爷,在穿山甲的帮助下找到了葫芦籽,种下了葫芦娃');
INSERT into student VALUES(0,'2022-02-02 10:00:00','蛇精','123456','12345678912','69','女','如意如意按我心意,快快显灵');
INSERT into student VALUES(0,'2022-02-02 10:00:00','蜈蚣精','123456','12345678912','69','男','被三娃打');
INSERT into student VALUES(0,'2022-02-02 10:00:00','葫芦小金刚','123456','12345678912','69','男','与蝴蝶妹妹有孽缘');
INSERT into student VALUES(0,'2022-02-02 10:00:00','六娃','123456','12345678912','69','男','我是谁,我在哪?');
INSERT into student VALUES(0,'2022-02-02 10:00:00','二娃','123456','12345678912','69','男','眼中钉');
INSERT INTO student (userName,age,introduce) VALUES ('山神',255,'孕育了葫芦娃种子');
3.插入图片
![](https://i-blog.csdnimg.cn/blog_migrate/ec367f692a492ea08b3459d466eb927f.png)
4.基础查询——DQL语句
select userName as '用户名',age 年龄,sex '性 别',introduce '简介'
from student where pwd is not null;
# 去重查询dis tin ct
select distinct sex '性别类型' from student;
# 排序order by
select * from student order by userName desc;
# 分页查询 -limit·是一个重载的函数,当只有1个参数的时候代表显示行数
# 两个参数limit分页:参数1、从N行开始查询=(当前页-1)*每页条数
select * from student limit 6,3;