例:向study数据库中插入表person
|
CREATE TABLE IF NOT EXISTS study.person ( id INT(11)NOTNULL AUTO_INCREMENT, username VARCHAR(20)NOTNULL, age INT, grade DOUBLE, addTime DATE, PRIMARYKEY(id) ) ENGINE = MyISAM DEFAULT CHARSET = UTF8; |
当没有在study数据库时,可以用下列2种方法 |
USE study;
CREATE TABLE IF NOT EXISTS person1 ( id INT(11)NOTNULL AUTO_INCREMENT, PRIMARYKEY(id) ) ENGINE = MyISAM DEFAULT CHARSET = UTF8; |
CREATE TABLE IF NOT EXISTS study.person ( id INT(11)NOTNULL AUTO_INCREMENT, PRIMARYKEY(id) ) ENGINE = MyISAM DEFAULT CHARSET = UTF8; |
MyBatis动态建表-SR
|
<update id="createUserWorkflowTableInt" parameterType="com.xhuoaservice.model.vo.UserWorkflowVo"> create table If Not Exists ${userName}( localId int(10) NOT NULL AUTO_INCREMENT, id varchar(10) , memId varchar(10), nodeId varchar(10), docId varchar(10), createDate datetime, workStatus varchar(1), handleState varchar(10), bustleNum int(2), isFollow varchar(1), modifyTime timestamp NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (localId)
) </update> |
CREATE TABLE StuCopy
AS SELECT *
FROM student;