建表——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 '男' COMMENT '性别',
`introduce` varchar(255) DEFAULT NULL COMMENT '简介',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
插入——DML语句
insert into student values(0,'2024-02-25 10:00:00','刘德华','123654',
'15612345678',62,'男','永远的男神,爱你一万年,爱你经得起考研。');
insert into student values(0,'2024-02-25 10:00:00','刘青云','123154',
'15612345678',65,'男','真正的演员,好角色用心演绎。');
insert into student values(0,'2024-02-25 10:00:00','周星驰','123624',
'15612345678',61,'男','所有的电影都没有对爱情有过轻视。');
insert into student values(0,'2024-02-25 10:00:00','张翰','122654',
'15612345678',32,'男','一起坐死在流星雨下。');
insert into student values(0,'2024-02-25 10:00:00','王祖贤','223654',
'15612345678',27,'女','你再美你能比过王祖贤吗?');
insert into student (userName,age,introduce)values('刘亦菲',37,'神仙姐姐');
查询——DQL语句
//like
select *from `student` where introduce like '%人%'
select *from student where pwd is null;
select *from student where pwd is not null;
//BETWEEN//AND
select *from student where age BETWEEN 150 and 200;
//IN
select *from student WHERE userName in ('刘德华','刘青云','周星驰');