【店小二】公告:

sql轉json
4885  |   |   |  16

功能介紹

1.支持多種資料庫的建表 sql轉json, 其中包含(pg、oracle、mysql)等資料庫; 建表語句, 建表語句, 建表語句(重要的說3遍)
2.在轉換 sql 的時候, 需要確認下是否需要切換處理類型, 暫時支持3種處理方式(normal, postgresql, oracle), 默認: normal.
3.支持自定義過濾不需要的欄位, 多個欄位通過 , 隔開


示例

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_TIMESP,
    updated_date datetime DEFAULT CURRENT_TIMESP ON UPDATE CURRENT_TIMESP,
    PRIMARY KEY (id)
);

處理後

{
    "id": "",
    "name": "姓名",
    "gender": "性別 0-未知 1-男 2-女",
    "age": "年齡",
    "created_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 timesp without time zone DEFAULT now(),
    updated_date timesp 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 '更新時間';

處理後

{
    "id": "",
    "name": "姓名",
    "gender": "性別 0-未知 1-男 2-女",
    "age": "年齡",
    "created_date": "",
    "updated_date": ""
}
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 '更新時間';

處理後

{
    "id": "",
    "name": "姓名",
    "gender": "性別 0-未知 1-男 2-女",
    "age": "年齡",
    "created_date": "",
    "updated_date": ""
}