<?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.utic.center.utic.traf.server.dao.mapper.dwdb.DwdbTableManagerMapper">

    <select id="findTableExist" parameterType="java.lang.String" resultType="com.utic.center.utic.traf.server.dto.TableExistDto" timeout="10">
        <![CDATA[
        SELECT COUNT(1) AS tableExist FROM USER_TABLES WHERE TABLE_NAME = #{tableName}
        ]]>
    </select>

    <update id="addTableComment" parameterType="java.lang.String">
        COMMENT ON TABLE ${tableName} IS '${tableComment}'
    </update>

    <update id="addColumnComment" parameterType="java.lang.String">
        COMMENT ON COLUMN ${tableName}.${columnName} IS '${columnComment}'
    </update>

    <update id="createTrafficCenterHistTable" parameterType="java.lang.String">
        create table TRAFFIC_CENTER_${crtMonth}
        (
            linkid         VARCHAR2(10) not null,
            missvalueyn    CHAR(1),
            regdate        DATE not null,
            linklevel      CHAR(1),
            speed          NUMBER(3),
            traveltime     NUMBER(7),
            trafficgrade   CHAR(2),
            incidentid     VARCHAR2(12),
            datarestype    CHAR(1),
            centerid       VARCHAR2(3),
            psdmissvalueyn CHAR(1),
            psdspeed       NUMBER(3),
            knnspeed       NUMBER(3),
            knncnt         NUMBER(3)
        )
        tablespace ODS_DATA
        pctfree 10
        initrans 1
        maxtrans 255
        storage
        (
           initial 64K
            next 1M
            minextents 1
            maxextents unlimited
        )
    </update>

    <update id="addTrafficCenterHistPrimaryKey" parameterType="java.lang.String">
        alter table TRAFFIC_CENTER_${crtMonth}
            add constraint PK_TRAFFIC_CENTER_${crtMonth} primary key (REGDATE, LINKID)
            using index
            tablespace ODS_INDX
            pctfree 10
            initrans 2
            maxtrans 255
            storage
            (
                initial 64K
                next 1M
                minextents 1
                maxextents unlimited
            )
    </update>

</mapper>
