数据库名称可以为【schoolDB】,字符集【uft8】,排序规则【uft8_general_ci】
1、创建数据库——DDL语句
CREATE TABLE `student` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '学号',
`creatDate` 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=9 DEFAULT CHARSET=utf8;
2、插入数据——DML语句
insert into student values(0,'2022-02-02 10:10:10','葫芦爷爷','123456','12345678998',69,'男','葫芦娃的爷爷'
);
insert into student values(0,'2022-02-02 10:10:10','蛇精','123564','12365498789',29,'女','可怕的东西'
);
insert into student values(0,'2022-02-02 10:10:10','蜈蚣精','123562','12365498789',69,'女','可怕的'
);
insert into student values(0,'2022-02-02 10:10:10','葫芦小金刚','123564','12365498789',17,'男','有段孽缘'
);
insert into student values(0,'2022-02-02 10:10:10','六娃','123564','12365498789',19,'女','葫芦'
);
insert into student values(0,'2022-02-02 10:10:10','二娃','123564','12365498789',9,'女','二哥'
);
insert into student (userName,age,introduce) values ('山神',255,'孕育了葫芦种子'
);
select * from student;
3、基础查询数据——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 limit6,3;