数据库名称可以为【schoolDB】,字符集【utf8】,排序规则【utf8_general_ci】。
1、创建数据库——DDL语句
CREATE TABLE `student` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '学号',
`createDate` datetime DEFAULT NULL COMMENT '创建时间',
`userNmae` 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=7 DEFAULT CHARSET=utf8;
2、插入数据DML语句
insert into student values(0,'2022-02-02 10:10:10','葫芦爷爷','123321','12332154687',69,'男','葫芦娃爷爷种种子');
insert into student values(0,'2022-02-02 10:10:10','蛇精','123321','1233154687',29,'女','如意如意顺我心意');
insert into student values(0,'2022-02-02 10:10:10','蜈蚣精','123321','1233154687',29,'男','被三娃踢成好多段');
insert into student values(0,'2022-02-02 10:10:10','六娃','123321','1233154687',29,'男','我是谁我在哪我要做什么');
select * from student;
3、基础查询语句——DQL
select userName as '用户名',age '年龄',sex '性别',introduce '简介'from student where pwd is not null;
select distinct sex '性别类型' from student;
select * from student order by username desc;
select * from student limit 6,3;