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) DEFAULT NULL COMMENT '年龄',
`sex` char(2) DEFAULT NULL COMMENT '性别',
`intrduce` varchar(255) DEFAULT NULL COMMENT '简介',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2 插入数据----DML语句
INSERT INTO student
VALUES
( 0, '2024-02-25 10:00:00', '盘古', '123456', '1234567', 255, '神', '12345678' );
INSERT INTO student
VALUES
( 0, '2024-02-25 10:00:00', '女娲', '123456', '1234567', 255, '神', '12345678' );
INSERT INTO student
VALUES
( 0, '2024-02-25 10:00:00', '黄帝', '123456', '1234567', 255, '神', '12345678' );
INSERT INTO student
VALUES
( 0, '2024-02-25 10:00:00', '蚩尤', '123456', '1234567', 255, '神', '12345678' );
INSERT INTO student
VALUES
( 0, '2024-02-25 10:00:00', '炎帝', '123456', '1234567', 255, '神', '12345678' );
INSERT INTO student
VALUES
( 0, '2024-02-25 10:00:00', '精卫', '123456', '1234567', 255, '神', '12345678' );
INSERT INTO student
VALUES
( 0, '2024-02-25 10:00:00', '神农', '123456', '1234567', 255, '神', '12345678' );
INSERT INTO student ( userName, age, intrduce )
VALUES
( '仓颉', 222, '123456' );
3 基础查询----QDL语句
# 基础查询
SELECT * FROM student;
# 非空查询
SELECT userName as '姓名',age '年龄',introduce '介绍' FROM student where pwd is not null;
# 去重查询
SELECT DISTINCT sex '性别' FROM student;
# 分页查询
SELECT * FROM student LIMIT 6,3;
# 排序
SELECT * FROM student ORDER BY age asc;
标签:COMMENT,00,DEFAULT,DML,VALUES,单表,student,MySQL,123456
From: https://blog.csdn.net/Zevil4/article/details/137045467