zoukankan      html  css  js  c++  java
  • mybatis 动态创建表、主键、索引、注释

    1.xxxMapper.xml文件

    <!--创建日志表-->
       <update id="createTablelog">
           <![CDATA[ 
            DECLARE lsql varchar2(4000); 
                 pk varchar2(50) := '主键';
            BEGIN lsql := ' 
                CREATE TABLE ${tableName} ( 
                  ID VARCHAR(32) DEFAULT SYS_GUID(),
                  TS_ID           NUMBER(12),
                  TABLE_NAME      VARCHAR2(200),
                  PRIMARY_KEY     VARCHAR2(200),
                  PRIMARY_VALUE   VARCHAR2(200),
                  START_TIME      TIMESTAMP,
                  END_TIME        TIMESTAMP,
                  LOG_TYPE        CHAR(1),
                  STATE           CHAR(1),
                  MSG              VARCHAR2(4000),
                  CONSTRAINT ${primaryKey} PRIMARY KEY (ID) USING INDEX)'; 
            EXECUTE IMMEDIATE lsql; 
            
             EXECUTE IMMEDIATE 'COMMENT ON COLUMN ' || '${tableName}' ||'.'||'ID'|| ' IS ''' || '主键' || ''''; 
             EXECUTE IMMEDIATE 'COMMENT ON COLUMN ' || '${tableName}' ||'.'||'TS_ID'|| ' IS ''' || '归集任务表主键' || ''''; 
             EXECUTE IMMEDIATE 'COMMENT ON COLUMN ' || '${tableName}' ||'.'||'TABLE_NAME'|| ' IS ''' || '归集任务源表英文名称(即归集库中的表英文名称)' || ''''; 
             EXECUTE IMMEDIATE 'COMMENT ON COLUMN ' || '${tableName}' ||'.'||'PRIMARY_KEY'|| ' IS ''' || '资源表主键,多个以英文逗号隔开' || ''''; 
             EXECUTE IMMEDIATE 'COMMENT ON COLUMN ' || '${tableName}' ||'.'||'PRIMARY_VALUE'|| ' IS ''' || '资源表主键值,多个以英文逗号隔开' || ''''; 
             EXECUTE IMMEDIATE 'COMMENT ON COLUMN ' || '${tableName}' ||'.'||'START_TIME'|| ' IS ''' || '归集开始时间' || ''''; 
             EXECUTE IMMEDIATE 'COMMENT ON COLUMN ' || '${tableName}' ||'.'||'END_TIME'|| ' IS ''' || '归集结束时间' || ''''; 
             EXECUTE IMMEDIATE 'COMMENT ON COLUMN ' || '${tableName}' ||'.'||'LOG_TYPE'|| ' IS ''' || '1、前置机归集,2、文件归集,3、API接口归集' || ''''; 
             EXECUTE IMMEDIATE 'COMMENT ON COLUMN ' || '${tableName}' ||'.'||'STATE'|| ' IS ''' || '归集状态,A成功,X失败' || ''''; 
             EXECUTE IMMEDIATE 'COMMENT ON COLUMN ' || '${tableName}' ||'.'||'MSG'|| ' IS ''' || '归集信息' || ''''; 
             EXECUTE IMMEDIATE 'COMMENT ON TABLE ' || '${tableName}' || ' IS ''' || '归集日志表' || ''''; 
             
            lsql := 'create index ${indexNameTs} on ${tableName} (TS_ID)';
            EXECUTE IMMEDIATE lsql;
            lsql := 'create index ${indexNameTab} on ${tableName} (TABLE_NAME)';
            EXECUTE IMMEDIATE lsql; END; ]]>
       </update>
  • 相关阅读:
    svn命令行使用积累
    linux下编译出现tmp空间不足解决办法
    secure CRT the remote system refused the connection 解决办法
    Makefile 中符合的使用
    函数指针作为某个函数的参数及定义函数指针(回调函数)
    C语言指针变量作为函数参数
    虚拟机下安装ubuntu后root密码登录失败的问题
    管理者需要知道的十大经典理论
    System V 与 POSIX
    带你吃透RTMP
  • 原文地址:https://www.cnblogs.com/zhou-pan/p/15012662.html
Copyright © 2011-2022 走看看