123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- <?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.customer.mapper.TableInfoMapper">
- <update id="useDataBase">
- use ${dataBaseName}
- </update>
- <update id="createMysqlDataBase">
- CREATE database IF NOT EXISTS `${dataBaseName}`;
- use `${dataBaseName}`;
- CREATE TABLE IF NOT EXISTS `${tableName}`
- (
- <foreach collection="filedList" item="filed" separator=",">
- ${filed}
- </foreach>
- );
- </update>
- <select id="mysqlDataBaseExist" resultType="int">
- SELECT count(1) FROM information_schema.SCHEMATA where SCHEMA_NAME= #{dataBaseName};
- </select>
- <select id="mysqlTableExist" resultType="int">
- SELECT count(1) FROM information_schema.TABLES t, information_schema.SCHEMATA n WHERE t.table_name = #{tableName} AND n.SCHEMA_NAME = #{dataBaseName};
- </select>
- <select id="sqlServerTableExist" resultType="int">
- select count(1) from sysobjects where id = object_id(#{tableName})
- </select>
- <update id="createSqlServerDataBase">
- IF DB_ID ( <![CDATA[ N'${dataBaseName}' ]]>) IS NULL
- CREATE DATABASE ${dataBaseName};
- </update>
- <update id="createSqlServerTable">
- use ${dataBaseName};
- create table ${tableName}
- (
- <foreach collection="filedList" item="filed" separator=",">
- ${filed}
- </foreach>
- );
- <foreach collection="descriptionList" item="description" separator=";">
- ${description}
- </foreach>
- </update>
- <select id="existOrNot" resultType="int">
- select count(1) From master.dbo.sysdatabases where name = #{dataBaseName}
- </select>
- <select id="dmTableExist" resultType="int">
- select count(1) from dba_segments where dba_segments.OWNER=#{dataBaseName} and SEGMENT_NAME=#{tableName}
- </select>
- <select id="dmDataBaseExist" resultType="int">
- select COUNT(1) from sysobjects where NAME=#{dataBaseName} and SUBTYPE$ is null
- </select>
- <update id="createDmDataBase">
- CREATE SCHEMA ${databaseName}
- </update>
- <update id="useDmDataBase">
- set schema ${dataBaseName};
- </update>
- <update id="createDmTable">
- create table ${tableName}
- (
- <foreach collection="filedList" item="filed" separator=",">
- ${filed}
- </foreach>
- );
- </update>
- <update id="addTableDescription">
- ${description}
- </update>
- <select id="oracleTableExist" resultType="int">
- select count(1) from user_tables where table_name=upper(#{tableName})
- </select>
- <update id="createOracleTable">
- create table ${tableName}
- (
- <foreach collection="filedList" item="filed" separator=",">
- ${filed}
- </foreach>
- )
- </update>
- <update id="addOracleTableDescription">
- ${description}
- </update>
- </mapper>
|