前言
数据库名可以为schooldb,字符集utf8,排序规律【utf8_general_ci】
1,建表语序——DDL
CREATE TABLE `schooldb` (
`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) 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 schooldb VALUES(0,'2024-02-22 10:00:00','刘德华','123454','12345678909',62,'男','男神');
INSERT INTO schooldb VALUES(0,'2024-02-22 10:00:00','刘青云','123456','13023455432',56,'男','好演员');
INSERT INTO schooldb VALUES(0,'2024-02-22 10:00:00','周星驰','123432','13423456789',61,'男','重视爱情');
INSERT INTO schooldb VALUES(0,'2024-02-22 10:00:00','刘亦菲','123432','13423456689',18,'女','神仙姐姐');
INSERT INTO schooldb VALUES(0,'2024-02-22 10:00:00','成龙','123432','13423411789',61,'男','功夫之星');
3,查询语句——DQL
SELECT * FROM `schooldb`where userName like '刘%';
SELECT * FROM `schooldb`where pwd is null;
SELECT * FROM `schooldb`where pwd is not null;
SELECT * FROM `schooldb`where age between 30 and 40;
SELECT * FROM `schooldb`where createDate between '2024-02-21 00:00:00'and'2024-02-23 00:00:00';
SELECT * FROM `schooldb`where userName in ('刘德华','刘亦菲');