[英]Is it possible to use MyBatis to issue DDL?
For example, is it possible to use MyBatis to issue DDL( Alter table, Drop table
) to database? 例如,可以使用MyBatis向数据库发布DDL(
Alter table, Drop table
)吗? For example, modify the table schema using alter table? 例如,使用alter table修改表架构?
Yes it is possible. 对的,这是可能的。 See this thread
看到这个线程
You would do something like : 您将执行以下操作:
<update id="createNewTable" parameterType="String" >
#{value};
</update >
Where the parameter is your 'create table' statement, using #{value} means your parameter will not be escaped. 如果参数是您的“ create table”语句,则使用#{value}表示不会对参数进行转义。
If you just want to set the table name, you would do: 如果只想设置表名,则可以执行以下操作:
<update id="createNewTable" parameterType="String" >
CREATE TABLE IF NOT EXISTS #{value} (
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
ENGINE=InnoDB DEFAULT CHARSET=utf8;
</update >
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.