mybatis 动态生成表和字段,适用于分表操作

来源:互联网 发布:淘宝的主要盈利模式 编辑:程序博客网 时间:2024/05/29 13:38
create table IF NOT EXISTS `NewTable` ( id int not null AUTO_INCREMENT , author_id int not null, primary key (id))
上面SQL是建立表,若将它作为mybatis 动态判断生成表,附上代码
<update id="createNewTable" parameterType="String">       create table  IF NOT EXISTS  ${tableName} (             id int not null AUTO_INCREMENT,             author_id int not null,             primary key (id))   </update>  

因部分业务需要,看了几篇文章,自己也试过,这种方法是可行的。

若需要将字段也可以动态生成。

阅读全文
0 0