【店小二】公告:
| | |
功能介绍
1.支持多种数据库的建表 sql转java, 其中包含(pg、oracle、mysql)等数据库; 建表语句, 建表语句, 建表语句(重要的说3遍)
2.在转换 sql 的时候, 需要确认下是否需要切换处理类型, 暂时支持3种处理方式(normal, postgresql, oracle), 默认: normal.
3.支持自定义是否需要lombok
,包名
,驼峰
说明: 不能在 sql 中包含注释内容(即:-- xxx
或# xxx
); 由于此工具是通过 ; 来分割语句处理. 所以 normal 状态下可以同时处理多个建表语句; postgresql 和 oracle 由于需要解析注释, 只支持单个建表语句.
示例
mysql 建表语句
CREATE TABLE if not exists user (
id int NOT NULL AUTO_INCREMENT,
name varchar(10) NOT NULL COMMENT '姓名',
gender tinyint NOT NULL DEFAULT 0 COMMENT '性别 0-未知 1-男 2-女',
age int NOT NULL COMMENT '年龄',
created_date datetime DEFAULT CURRENT_TIMESTAMP,
updated_date datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (id)
);
处理后
// Code generated by https://gotool.top
package com.gotool.sql2java;
public class User {
private Integer id;
/**
* 姓名1
*/
private String name;
/**
* 性别 0-未知 1-男 2-女
*/
private Integer gender;
/**
* 年龄1
*/
private Integer age;
private Date created_date;
private Date updated_date;
public Integer getId() {
return this.id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
public Integer getGender() {
return this.gender;
}
public void setGender(Integer gender) {
this.gender = gender;
}
public Integer getAge() {
return this.age;
}
public void setAge(Integer age) {
this.age = age;
}
public Date getCreated_date() {
return this.created_date;
}
public void setCreated_date(Date created_date) {
this.created_date = created_date;
}
public Date getUpdated_date() {
return this.updated_date;
}
public void setUpdated_date(Date updated_date) {
this.updated_date = updated_date;
}
}
pgsql 建表语句
CREATE TABLE if not exists user (
id character varying(32) NOT NULL DEFAULT sys_guid(),
name character varying(10) NOT NULL,
gender tinyint NOT NULL,
age tinyint NOT NULL,
created_date timestamp without time zone DEFAULT now(),
updated_date timestamp without time zone DEFAULT now(),
CONSTRAINT user_pkey PRIMARY KEY (id)
);
COMMENT ON TABLE user IS '用户表';
COMMENT ON COLUMN user.id IS '主键';
COMMENT ON COLUMN user.name IS '姓名';
COMMENT ON COLUMN user.gender IS '性别 0-未知 1-男 2-女';
COMMENT ON COLUMN user.age IS '年龄';
COMMENT ON COLUMN user.created_date IS '创建时间';
COMMENT ON COLUMN user.updated_date IS '更新时间';
处理后
// Code generated by https://gotool.top
package com.gotool.sql2java;
public class User {
/**
* 主键
*/
private String id;
/**
* 姓名
*/
private String name;
/**
* 性别 0-未知 1-男 2-女
*/
private Integer gender;
/**
* 年龄
*/
private Integer age;
/**
* 创建时间
*/
private Integer createdDate;
/**
* 更新时间
*/
private Integer updatedDate;
public String getId() {
return this.id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
public Integer getGender() {
return this.gender;
}
public void setGender(Integer gender) {
this.gender = gender;
}
public Integer getAge() {
return this.age;
}
public void setAge(Integer age) {
this.age = age;
}
public Integer getCreatedDate() {
return this.createdDate;
}
public void setCreatedDate(Integer createdDate) {
this.createdDate = createdDate;
}
public Integer getUpdatedDate() {
return this.updatedDate;
}
public void setUpdatedDate(Integer updatedDate) {
this.updatedDate = updatedDate;
}
}
oracle 建表语句
CREATE TABLE if not exists user (
id character varying(32) NOT NULL DEFAULT sys_guid(),
name character varying(10) NOT NULL,
gender tinyint NOT NULL,
age tinyint NOT NULL,
created_date date default sysdate,,
updated_date date default sysdate,,
CONSTRAINT user_pkey PRIMARY KEY (id)
);
COMMENT ON TABLE user IS '用户表';
COMMENT ON COLUMN user.id IS '主键';
COMMENT ON COLUMN user.name IS '姓名';
COMMENT ON COLUMN user.gender IS '性别 0-未知 1-男 2-女';
COMMENT ON COLUMN user.age IS '年龄';
COMMENT ON COLUMN user.created_date IS '创建时间';
COMMENT ON COLUMN user.updated_date IS '更新时间';
处理后
// Code generated by https://gotool.top
package com.gotool.sql2java;
public class User {
/**
* 主键
*/
private String id;
/**
* 姓名
*/
private String name;
/**
* 性别 0-未知 1-男 2-女
*/
private Integer gender;
/**
* 年龄
*/
private Integer age;
/**
* 创建时间
*/
private String createdDate;
/**
* 更新时间
*/
private String updatedDate;
public String getId() {
return this.id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
public Integer getGender() {
return this.gender;
}
public void setGender(Integer gender) {
this.gender = gender;
}
public Integer getAge() {
return this.age;
}
public void setAge(Integer age) {
this.age = age;
}
public String getCreatedDate() {
return this.createdDate;
}
public void setCreatedDate(String createdDate) {
this.createdDate = createdDate;
}
public String getUpdatedDate() {
return this.updatedDate;
}
public void setUpdatedDate(String updatedDate) {
this.updatedDate = updatedDate;
}
}