在mapper.xml中一般都是对表数据进行DML(增删改查)操作,很少通过MyBatis对数据库进行DDL(create, alter, drop)操作,下面就mybatis的DDL给大家做个简单介绍。
在相关mapper.xml文件中DDL的配置代码如下:
<update id="alterTableName"> alter table ${tableName} rename ${newTableName} </update> <update id="truncateTable"> truncate table ${tableName} </update> <update id="createNewTableAndInsertData"> create table ${newTableName} as select * from ${tableName} </update> 注意:DDL语句都应该放在<update>标签中使用。