For example, is it possible to use MyBatis to issue DDL(Alter table, Drop table
) to database? For example, modify the table schema using alter table?
Asked
Active
Viewed 1,263 times
1 Answers
2
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.
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 >
Here is nice answer for alter

VedantK
- 9,728
- 7
- 66
- 71