准备数据

第一步,准备数据

我们准备一张学生表,来完成这个简单的项目

运行以下sql,完成数据准备

-- 如果test数据库不存在,就创建test数据库:
CREATE DATABASE IF NOT EXISTS test;

-- 切换到test数据库
USE test;

-- 删除student表(如果存在):
DROP TABLE IF EXISTS student;

-- 创建students表:
CREATE TABLE `student` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '姓名',
  `gender` tinyint unsigned NOT NULL DEFAULT '1' COMMENT '性别 1男2女',
  `create_time` int unsigned NOT NULL,
  `update_time` int unsigned NOT NULL,
  `is_deleted` tinyint unsigned NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='学生表';

-- 插入students记录:
INSERT INTO student (name, gender, create_time, update_time) VALUES ('小明', 1, 1691219600, 1691219600);
INSERT INTO student (name, gender, create_time, update_time) VALUES ('小红', 2, 1691219600, 1691219600);
INSERT INTO student (name, gender, create_time, update_time) VALUES ('小军', 1, 1691219600, 1691219600);
INSERT INTO student (name, gender, create_time, update_time) VALUES ('小米', 2, 1691219600, 1691219600);
INSERT INTO student (name, gender, create_time, update_time) VALUES ('小白', 1, 1691219600, 1691219600);
INSERT INTO student (name, gender, create_time, update_time) VALUES ('小兵', 1, 1691219600, 1691219600);
INSERT INTO student (name, gender, create_time, update_time) VALUES ('小林', 2, 1691219600, 1691219600);
INSERT INTO student (name, gender, create_time, update_time) VALUES ('小新', 2, 1691219600, 1691219600);
INSERT INTO student (name, gender, create_time, update_time) VALUES ('小王', 1, 1691219600, 1691219600);
INSERT INTO student (name, gender, create_time, update_time) VALUES ('小丽', 2, 1691219600, 1691219600);