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=9 DEFAULT CHARSET=utf8;
2、DML
insert into student values(
0,'2024-2-25 10:00:00','盘古','123456','1562384728',255,'神','开天辟地第一人' );
insert into student values(
0,'2024-2-25 10:00:00','女娲','123456','1562384728',200,'女','多次造人最终成果' );
insert into student values(
0,'2024-2-25 10:00:00','伏羲','123456','1562384728',215,'神','先天八卦' );
insert into student values(
0,'2024-2-25 10:00:00','神农','123456','1562384728',115,'男','尝百草,死于断肠草下' );
insert into student values(
0,'2024-2-25 10:00:00','嫘祖','123456','1562384728',115,'神','开天辟地第一人' );
insert into student values(
0,'2024-2-25 10:00:00','蚩尤','123456','1562384728',115,'男','锻造大神,坐下食铁巨兽' );
insert into student(userName,age,introduce)values('仓颉',125,'中国象形文字');
3、DQL
#like 的模糊查询
select *from student where introduce like '%人%';
#非空查询
select*from student where pwd is null;
select *from student where pwd is not null;
#范围查询1、数据2、时间
select* from student where age between 150 and 200;
select *from student where createDate between '2024-02-21 00:00:00'and '2024-02-23 00:00:00';
#in语句查询
select *from student where userName in ('盘古','伏羲','神农');