Liquibase - 可用的通用数据类型列表

时间:2014-05-19 16:04:54

标签: liquibase

我需要Liquibase中可用的通用数据类型列表。我在哪里可以找到这些文档。

在我的表中添加列时我需要它们:

<changeSet author="liquibase-docs" id="addColumn-example">
    <addColumn catalogName="cat"
            schemaName="public"
            tableName="person">
        <column name="address" type="varchar(255)"/>
    </addColumn>
</changeSet>

2 个答案:

答案 0 :(得分:28)

Liquibase使用标准JDBC数据类型 - 这是一个引用,来自http://db.apache.org/ojb/docu/guides/jdbc-types.html

DBC Type      Java Type
CHAR          String
VARCHAR       String
LONGVARCHAR   String
NUMERIC       java.math.BigDecimal
DECIMAL       java.math.BigDecimal
BIT           boolean
BOOLEAN       boolean
TINYINT       byte
SMALLINT      short
INTEGER       int
BIGINT        long
REAL          float
FLOAT         double
DOUBLE        double
BINARY        byte[]
VARBINARY     byte[]
LONGVARBINARY byte[]
DATE          java.sql.Date
TIME          java.sql.Time
TIMESTAMP     java.sql.Timestamp
CLOB          Clob
BLOB          Blob
ARRAY         Array
DISTINCT      mapping of underlying type
STRUCT        Struct
REF           Ref
DATALINK      java.net.URL
JAVA_OBJECT   underlying Java class

答案 1 :(得分:0)

根据Liquibase Column tag documentation

为帮助使脚本独立于数据库,以下“通用” 数据类型将转换为正确的数据库实现:

BOOLEAN
CURRENCY
UUID
CLOB
BLOB
DATE
DATETIME
TIME
BIGINT

另外,将指定的java.sql.Types。*类型转换为 以及正确的类型。如果需要,可以包括精度。这是 一些例子:

java.sql.Types.TIMESTAMP
java.sql.Types.VARCHAR(255)

这些是java.sql.Types中的值:

public static final int BIT = -7;
public static final int TINYINT = -6;
public static final int SMALLINT = 5;
public static final int INTEGER = 4;
public static final int BIGINT = -5;
public static final int FLOAT = 6;
public static final int REAL = 7;
public static final int DOUBLE = 8;
public static final int NUMERIC = 2;
public static final int DECIMAL = 3;
public static final int CHAR = 1;
public static final int VARCHAR = 12;
public static final int LONGVARCHAR = -1;
public static final int DATE = 91;
public static final int TIME = 92;
public static final int TIMESTAMP = 93;
public static final int BINARY = -2;
public static final int VARBINARY = -3;
public static final int LONGVARBINARY = -4;
public static final int NULL = 0;
public static final int OTHER = 1111;
public static final int JAVA_OBJECT = 2000;
public static final int DISTINCT = 2001;
public static final int STRUCT = 2002;
public static final int ARRAY = 2003;
public static final int BLOB = 2004;
public static final int CLOB = 2005;
public static final int REF = 2006;
public static final int DATALINK = 70;
public static final int BOOLEAN = 16;
public static final int ROWID = -8;
public static final int NCHAR = -15;
public static final int NVARCHAR = -9;
public static final int LONGNVARCHAR = -16;
public static final int NCLOB = 2011;
public static final int SQLXML = 2009;
public static final int REF_CURSOR = 2012;
public static final int TIME_WITH_TIMEZONE = 2013;
public static final int TIMESTAMP_WITH_TIMEZONE = 2014;