配置文件修改为支持sql中加 ";"的
路径:spring.datasource.dynamic.druid
加配置项:
wall:
multi-statement-allow: true
jdbc连接中加 allowMultiQueries=true
url: jdbc:postgresql://localhost:5432/dbr?allowMultiQueries=true
mapper中:
void createTable(@Param("sql")String sql);
xml:
<update id="createTable">
${sql}
</update>
剩下的就是组织sql了
CREATE TABLE db_yxjg (
num_test VARCHAR ( 10 ),
byte_test bytea,
DWH VARCHAR ( 10 ) PRIMARY KEY NOT NULL,
JLNY TIMESTAMP ( 6 ),
SXRQ TIMESTAMP ( 6 ),
bool_test BOOLEAN,
DWMC VARCHAR ( 60 ) UNIQUE NOT NULL,
);
COMMENT ON COLUMN db_yxjg.num_test IS '数字测试';
COMMENT ON COLUMN db_yxjg.byte_test IS '字节测试';
COMMENT ON COLUMN db_yxjg.DWH IS '单位号';
CREATE INDEX index_db_yxjg_DWYWMC ON db_yxjg ( DWYWMC );
这样的sql , 传入mapper 中做参数就能建表了