介绍

SQL语句生成网址:https://sqlfather.com

帮你轻松生成 SQL 语句、假数据和代码,大幅提升开发效率~

无论你是前端、后端、测试、数据开发、数据科学的同学,相信这个工具都会对你有帮助。

快速生成 SQL 和模拟数据

示列:

我们有一个hospital(医院数据库)

需要创建病人表(patient)

病人表

输入配置

一些没有的规则可以自行用正则表达式来表达

身份证号码的正则表达式:[1-9]d{5}(18|19|20)d{2}((0[1-9])|(1[0-2]))((0-2)|10|20|30|31)d{3}[0-9Xx]

密码的正则表达式:([a-zA-Z])[0-9A-Za-z]{6,20}

 /**
                 * 密码至少包含 数字和英文,长度6-20
 */
                String reg = "^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,20}$";
 /**
                 * 密码包含 数字,英文,字符中的两种以上,长度6-20
 */
                String reg = "^(?![0-9]+$)(?![a-z]+$)(?![A-Z]+$)(?!([^(0-9a-zA-Z)])+$).{6,20}$";
  /**
                 * 至少包含数字跟字母,可以有字符
*/
                String reg = "(?=.*([a-zA-Z].*))(?=.*[0-9].*)[a-zA-Z0-9-*/+.~!@#$%^&*()]{6,20}$";

银行卡账户(19位数字):([1-9]{1})(d{14}|d{18})

生成结果

SQL代码

SQL代码

创建表

-- 病人表
create table if not exists hospital.`patient`
(
`patientID` int not null auto_increment comment '病人编号' primary key,
`password` varchar(20) not null comment '登入密码',
`birthDate` date not null comment '出生日期',
`gender` varchar(4) default '男' not null comment '性别',
`patientName` varchar(50) not null comment '病人姓名',
`phoneNum` varchar(50) not null comment '联系电话',
`email` varchar(70) not null comment '邮箱',
`identityNum` varchar(20) not null comment '身份证号',
`address` varchar(256) default '地址不详' not null comment '地址'
) comment '病人表';

插入数据

insert into hospital.`patient` (`patientID`, `password`, `birthDate`, `gender`, `patientName`, `phoneNum`, `email`, `identityNum`, `address`) values (1, 'MjY', '2022-01-16 09:32:46', '女', '刘昊然', '15590525765', 'kyle.goldner@gmail.com', '37630018450423580x', '海门');
insert into hospital.`patient` (`patientID`, `password`, `birthDate`, `gender`, `patientName`, `phoneNum`, `email`, `identityNum`, `address`) values (2, 'luqxz', '2022-05-14 18:44:50', '女', '曾靖琪', '15519526106', 'carli.rowe@hotmail.com', '51771831750131101x', '大庆');
insert into hospital.`patient` (`patientID`, `password`, `birthDate`, `gender`, `patientName`, `phoneNum`, `email`, `identityNum`, `address`) values (3, 'bM5', '2022-02-03 06:03:00', '男', '冯锦程', '14578674386', 'sylvester.witting@hotmail.com', '43909819650428796x', '潍坊');
insert into hospital.`patient` (`patientID`, `password`, `birthDate`, `gender`, `patientName`, `phoneNum`, `email`, `identityNum`, `address`) values (4, '0BPc8', '2022-04-26 23:40:45', '女', '石浩然', '15850286301', 'liliana.green@gmail.com', '160693364004309353', '吉林');
insert into hospital.`patient` (`patientID`, `password`, `birthDate`, `gender`, `patientName`, `phoneNum`, `email`, `identityNum`, `address`) values (5, 'nxrbO', '2022-09-23 08:36:03', '女', '侯文博', '13422105353', 'jolene.fadel@hotmail.com', '71630627810201545x', '株洲');
insert into hospital.`patient` (`patientID`, `password`, `birthDate`, `gender`, `patientName`, `phoneNum`, `email`, `identityNum`, `address`) values (6, 'XN', '2022-12-27 15:40:48', '女', '邓苑博', '15697339789', 'aracely.osinski@gmail.com', '74167027320631920x', '云浮');
insert into hospital.`patient` (`patientID`, `password`, `birthDate`, `gender`, `patientName`, `phoneNum`, `email`, `identityNum`, `address`) values (7, 'jU', '2022-09-03 07:31:17', '男', '丁驰', '13784266237', 'sueann.kutch@gmail.com', '76169218860831844x', '海口');
insert into hospital.`patient` (`patientID`, `password`, `birthDate`, `gender`, `patientName`, `phoneNum`, `email`, `identityNum`, `address`) values (8, 'W7', '2022-02-22 07:39:48', '女', '莫振家', '17198564324', 'darwin.yost@gmail.com', '94266739651130163x', '丽水');
insert into hospital.`patient` (`patientID`, `password`, `birthDate`, `gender`, `patientName`, `phoneNum`, `email`, `identityNum`, `address`) values (9, '31RK', '2022-01-04 02:22:37', '女', '孔浩然', '17540068733', 'leatha.feest@gmail.com', '95416321331029445X', '莱西');
insert into hospital.`patient` (`patientID`, `password`, `birthDate`, `gender`, `patientName`, `phoneNum`, `email`, `identityNum`, `address`) values (10, 'mka1', '2022-11-05 05:58:04', '女', '钱建辉', '17009247178', 'ivan.quitzon@gmail.com', '77213518921106408X', '富阳');
insert into hospital.`patient` (`patientID`, `password`, `birthDate`, `gender`, `patientName`, `phoneNum`, `email`, `identityNum`, `address`) values (11, 'FXT3', '2022-04-28 22:56:42', '男', '廖明轩', '17775513196', 'elton.buckridge@yahoo.com', '24499228670508400X', '潍坊');
insert into hospital.`patient` (`patientID`, `password`, `birthDate`, `gender`, `patientName`, `phoneNum`, `email`, `identityNum`, `address`) values (12, 'QAN', '2022-03-26 15:06:49', '女', '石擎宇', '17354499633', 'joesph.ohara@hotmail.com', '400932191906163330', '扬州');
insert into hospital.`patient` (`patientID`, `password`, `birthDate`, `gender`, `patientName`, `phoneNum`, `email`, `identityNum`, `address`) values (13, 'NdWHv', '2022-10-12 02:03:42', '男', '李鑫磊', '15288491025', 'allie.yost@gmail.com', '17118136161028408x', '湖州');
insert into hospital.`patient` (`patientID`, `password`, `birthDate`, `gender`, `patientName`, `phoneNum`, `email`, `identityNum`, `address`) values (14, '5WB', '2022-07-05 15:53:19', '男', '潘风华', '17028567212', 'earle.hessel@gmail.com', '580872180110308417', '安阳');
insert into hospital.`patient` (`patientID`, `password`, `birthDate`, `gender`, `patientName`, `phoneNum`, `email`, `identityNum`, `address`) values (15, 'DM8', '2022-01-18 09:48:44', '男', '孔立辉', '14520905222', 'peter.pagac@gmail.com', '641845195902079744', '自贡');
insert into hospital.`patient` (`patientID`, `password`, `birthDate`, `gender`, `patientName`, `phoneNum`, `email`, `identityNum`, `address`) values (16, 'aZ', '2022-10-06 16:27:09', '男', '丁立轩', '17161788801', 'brent.smith@yahoo.com', '29832819691112368x', '青岛');
insert into hospital.`patient` (`patientID`, `password`, `birthDate`, `gender`, `patientName`, `phoneNum`, `email`, `identityNum`, `address`) values (17, 'N1oHl', '2022-08-19 03:14:28', '男', '韩烨伟', '15631382673', 'laronda.green@yahoo.com', '67249218711004278x', '银川');
insert into hospital.`patient` (`patientID`, `password`, `birthDate`, `gender`, `patientName`, `phoneNum`, `email`, `identityNum`, `address`) values (18, 'UnYd', '2022-11-14 16:53:50', '女', '杜浩', '15018982795', 'jesusita.hirthe@hotmail.com', '69258234240923111x', '长沙');
insert into hospital.`patient` (`patientID`, `password`, `birthDate`, `gender`, `patientName`, `phoneNum`, `email`, `identityNum`, `address`) values (19, 'zBFwR', '2022-06-19 09:26:30', '女', '戴志泽', '15696742699', 'lucien.stark@hotmail.com', '12986126111030802x', '柳州');
insert into hospital.`patient` (`patientID`, `password`, `birthDate`, `gender`, `patientName`, `phoneNum`, `email`, `identityNum`, `address`) values (20, 'pkpVU', '2022-08-07 06:56:48', '女', '姜博涛', '15226471776', 'leonia.ebert@yahoo.com', '33727123041026059x', '文登');

模拟数据

模拟数据

JSON数据

简单列后面两个

[
{
    "patientName": "龚志强",
    "identityNum": "726484198110067593",
    "password": "jtb",
    "address": "西宁",
    "gender": "女",
    "patientID": "19",
    "phoneNum": "17120983825",
    "birthDate": "2022-03-10 05:59:17",
    "email": "marta.schmitt@yahoo.com"
  },
  {
    "patientName": "罗晟睿",
    "identityNum": "311649322607273905",
    "password": "fnh",
    "address": "云浮",
    "gender": "女",
    "patientID": "20",
    "phoneNum": "17811803091",
    "birthDate": "2022-05-15 10:10:56",
    "email": "francesco.balistreri@yahoo.com"
  }
]

Java代码

简单列一个

实体代码

import lombok.Data;

/**
 * 病人表
 */
@Data
public class Patient implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 病人编号
     */
    private Integer patientID;

    /**
     * 登入密码
     */
    private String password;

    /**
     * 出生日期
     */
    private Date birthDate;

    /**
     * 性别
     */
    private String gender;

    /**
     * 病人姓名
     */
    private String patientName;

    /**
     * 联系电话
     */
    private String phoneNum;

    /**
     * 邮箱
     */
    private String email;

    /**
     * 身份证号
     */
    private String identityNum;

    /**
     * 地址
     */
    private String address;

}

对象代码

Patient patient = new Patient();
patient.setPatientid(1);
patient.setPassword("qh");
patient.setBirthdate("2022-02-06 10:17:38");
patient.setGender("女");
patient.setPatientname("吴明辉");
patient.setPhonenum("17072827800");
patient.setEmail("shirleen.schroeder@yahoo.com");
patient.setIdentitynum("51720018800431434X");
patient.setAddress("南京");

前端代码

Typescript 类型代码

/**
 * 病人表
 */
interface Patient {
  // 病人编号
  patientID: number;
  // 登入密码
  password: string;
  // 出生日期
  birthDate: Date;
  // 性别
  gender: string;
  // 病人姓名
  patientName: string;
  // 联系电话
  phoneNum: string;
  // 邮箱
  email: string;
  // 身份证号
  identityNum: string;
  // 地址
  address: string;
}

词库

我们需要一个关于医院科室的词库,但原词库没有,我们可以自行创建

创建词库

创建后我们再看一下词库就有我们刚刚创建的词

创建词库例子

建表语句

-- 科室表
create table if not exists hospital.`department`
(
`depID` int not null auto_increment comment '科室编号' primary key,
`depName` varchar(50) not null comment '科室名称'
) comment '科室表';

插入语句

insert into hospital.`department` (`depID`, `depName`) values (1, '急诊室');
insert into hospital.`department` (`depID`, `depName`) values (2, '急诊室');
insert into hospital.`department` (`depID`, `depName`) values (3, '外科重症室');
insert into hospital.`department` (`depID`, `depName`) values (4, '初生婴儿重症室');
insert into hospital.`department` (`depID`, `depName`) values (5, '初生婴儿重症室');
insert into hospital.`department` (`depID`, `depName`) values (6, '急诊室');
insert into hospital.`department` (`depID`, `depName`) values (7, '内科值班室');
insert into hospital.`department` (`depID`, `depName`) values (8, '急诊手术室');
insert into hospital.`department` (`depID`, `depName`) values (9, '初生婴儿重症室');
insert into hospital.`department` (`depID`, `depName`) values (10, '内科重症室');

看以上SQL语句我们发现有重复的科室 像一些特殊的不能重复的 需要自行更改 缺点+1

还有很多好用的功能,请看以下作者的视频介绍

视频教程:我做了个小工具,帮你提升100倍开发效率!_哔哩哔哩_bilibili

最后修改:2022 年 11 月 18 日
如果觉得我的文章对你有用,请随意赞赏