mysql创建
1、学生表
CREATE TABLE `student` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '学号',
`createdate` datetime DEFAULT NULL,
`username` varchar(20) DEFAULT NULL,
`pwd` varchar(36) DEFAULT NULL,
`phone` varchar(11) DEFAULT NULL,
`age` tinyint(3) DEFAULT NULL,
`sex` char(2) DEFAULT NULL,
`introduce` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
2、插入学生信息
INSERT INTO student VALUES(0,'2024-02-25 10:00:00','海绵宝宝','123','1512345678',16,'男','比奇堡')
INSERT INTO student VALUES(0,'2024-02-25 10:00:00','派大星','123','1512345678',16,'男','贝壳')
INSERT INTO student VALUES(0,'2024-02-25 10:00:00','珊迪','123','1512345678',16,'女','松鼠')
INSERT INTO student VALUES(0,'2024-02-25 10:00:00','章鱼哥','123','1512345678',16,'男','章鱼')
INSERT INTO student VALUES(0,'2024-02-25 10:00:00','痞老板','123','1512345678',16,'男','微生物')
INSERT INTO student (username,age,introduce)VALUES('蟹老板','26','钱')
显示效果
3、基础查询测试
#基础查询
SELECT * FROM student;
#筛选列与筛选数据行
select username AS 姓名,age'年龄',sex'性别'
introduce'简介'FROM student
where pwd is not null;
#分页limit有两个重载函数常用
#一个参数为显示条数
#一个参数为从那条开始查询(下表从0开始计算),零一参数为显示条数
select * FROM student LIMIT 3,2;
#从4开始查询2条
SELECT * FROM student orser by age DESC limit 3;#排序,order by根据数值类型进行排序会比较准确
SELECT DISTINCT sex '性别类型' FROM student;#去重语句distinct
标签:INSERT,00,DEFAULT,DML,VALUES,student,DDL,DQL,NULL
From: https://blog.csdn.net/2301_80888284/article/details/137009135