fg电池监控平台的达梦数据库版本
whycxzp
2024-11-13 08d472a503199c6f43269a1673faaf09bb840224
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?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 ;
    </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 ;
    </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>