<?xml version="1.0" encoding="UTF-8"?>
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
<mapper namespace="com.whyc.mapper.LicenseMapper" >
|
<insert id="add" parameterType="com.whyc.pojo.License">
|
<!-- REPLACE into web_site.tb_license(id,serialNumber,duration,timeInUse) values(1,#{license.serialNumber},#{license.duration},#{license.timeInUse})-->
|
merge into web_site.tb_license tgt
|
using (select 1 as id) as src
|
on tgt.id = src.id
|
when matched then
|
update set tgt.serialNumber = #{license.serialNumber},tgt.duration = #{license.duration},tgt.timeInUse = #{license.timeInUse}
|
when not matched then
|
insert(serialNumber,duration,timeInUse) values(#{license.serialNumber},#{license.duration},#{license.timeInUse})
|
</insert>
|
<update id="createTable">
|
<!--CREATE TABLE web_site.tb_license (
|
id int(11) NOT NULL AUTO_INCREMENT,
|
serialNumber varchar(255) NOT NULL DEFAULT '',
|
duration varchar(255) NOT NULL DEFAULT '',
|
timeInUse varchar(255) NOT NULL DEFAULT '',
|
PRIMARY KEY (id) USING BTREE
|
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ;-->
|
CREATE TABLE "web_site"."tb_license"
|
(
|
"id" INT IDENTITY(1, 1) NOT NULL,
|
"serialNumber" VARCHAR(255) DEFAULT '' NOT NULL,
|
"duration" VARCHAR(255) DEFAULT '0' NOT NULL,
|
"timeInUse" VARCHAR(255) DEFAULT '0' NOT NULL,
|
NOT CLUSTER PRIMARY KEY("id")) STORAGE(ON "MAIN", CLUSTERBTR) ;
|
</update>
|
<update id="reCreateTable">
|
<!--DROP TABLE IF EXISTS web_site.tb_license;
|
CREATE TABLE web_site.tb_license (
|
id int(11) NOT NULL AUTO_INCREMENT,
|
serialNumber varchar(255) NOT NULL DEFAULT '',
|
duration varchar(255) NOT NULL DEFAULT '',
|
timeInUse varchar(255) NOT NULL DEFAULT '',
|
PRIMARY KEY (id) USING BTREE
|
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ;-->
|
DROP TABLE IF EXISTS web_site.tb_license;
|
CREATE TABLE "web_site"."tb_license"
|
(
|
"id" INT IDENTITY(1, 1) NOT NULL,
|
"serialNumber" VARCHAR(255) DEFAULT '' NOT NULL,
|
"duration" VARCHAR(255) DEFAULT '0' NOT NULL,
|
"timeInUse" VARCHAR(255) DEFAULT '0' NOT NULL,
|
NOT CLUSTER PRIMARY KEY("id")) STORAGE(ON "MAIN", CLUSTERBTR) ;
|
</update>
|
<update id="updateTimeInUse">
|
update web_site.tb_license set timeInUse = #{timeInUse}
|
</update>
|
|
|
<select id="selectExist" resultType="java.lang.Integer">
|
select count(*) num from information_schema.TABLES t where t.TABLE_SCHEMA ='web_site' and t.TABLE_NAME ='tb_license'
|
</select>
|
<select id="existColumn" resultType="java.lang.Integer">
|
select count(*) num from information_schema.COLUMNS t where t.TABLE_SCHEMA ='web_site' and t.TABLE_NAME ='tb_license' and
|
t.column_name = 'duration' limit 1
|
</select>
|
<select id="selectOne" resultType="com.whyc.pojo.License">
|
select * from web_site.tb_license limit 1
|
</select>
|
</mapper>
|