2024-05-21
Java
00

目录

第一部分 概述
第二部分 支持的数据类型及其对应关系
2.1 布尔类型
2.1.1 boolean
2.2 整数类型
2.2.1 tinyint
2.2.2 int
2.2.3 mediumint
2.2.4 bigint
2.2.5 number
2.3 小数类型
2.3.1 float
2.3.2 double
2.3.3 decimal
2.3.4 currency
2.4 字符串类型
2.4.1 char
2.4.2 varchar
2.4.3 nchar
2.4.4 nvarchar
2.5 日期和时间类型
2.5.1 datetime
2.5.2 time
2.5.3 timestamp
2.5.4 date
2.6 其他数据类型
2.6.1 blob
2.6.2 clob
2.6.3 function
2.6.4 UNKNOWN
2.6.5 uuid

第一部分 概述

Liquibase是一个开源的数据库版本控制工具,旨在简化和自动化数据库变更的管理和部署。它允许开发人员和数据库管理员以声明式的方式定义数据库架构和数据变更,然后自动将这些变更应用到各种数据库中。Liquibase支持多种数据库类型,提供了良好的可移植性和可扩展性。

使用场景

  • 持续集成和持续部署(CI/CD):在CI/CD管道中,Liquibase可以自动应用数据库变更脚本,确保数据库在各个环境中的一致性。
  • 数据库版本控制:通过将数据库变更脚本与应用程序代码一起管理,可以实现数据库版本的追踪和回滚。
  • 团队协作:多人团队可以通过Liquibase共享和协作管理数据库变更,避免冲突和重复工作。
  • 自动化数据库迁移:自动化数据库结构和数据迁移,减少手动操作的错误和工作量。

第二部分 支持的数据类型及其对应关系

Liquibase在不同数据库系统中支持多种数据类型。以下是一些常见的数据类型及其在不同数据库中的对应关系。

2.1 布尔类型

2.1.1 boolean

  • MySQLDatabase: BIT(1)
  • SQLiteDatabase: BOOLEAN
  • H2Database: BOOLEAN
  • PostgresDatabase: BOOLEAN
  • UnsupportedDatabase: BOOLEAN
  • DB2Database: SMALLINT
  • MSSQLDatabase: [bit]
  • OracleDatabase: NUMBER(1)
  • HsqlDatabase: BOOLEAN
  • FirebirdDatabase: SMALLINT
  • DerbyDatabase: SMALLINT
  • InformixDatabase: BOOLEAN
  • SybaseDatabase: BIT
  • SybaseASADatabase: BIT

2.2 整数类型

2.2.1 tinyint

  • MySQLDatabase: TINYINT
  • SQLiteDatabase: TINYINT
  • H2Database: TINYINT
  • PostgresDatabase: SMALLINT
  • UnsupportedDatabase: TINYINT
  • DB2Database: SMALLINT
  • MSSQLDatabase: [tinyint]
  • OracleDatabase: NUMBER(3)
  • HsqlDatabase: TINYINT
  • FirebirdDatabase: SMALLINT
  • DerbyDatabase: SMALLINT
  • InformixDatabase: TINYINT
  • SybaseDatabase: TINYINT
  • SybaseASADatabase: TINYINT

2.2.2 int

  • MySQLDatabase: INT
  • SQLiteDatabase: INTEGER
  • H2Database: INT
  • PostgresDatabase: INT
  • UnsupportedDatabase: INT
  • DB2Database: INTEGER
  • MSSQLDatabase: [int]
  • OracleDatabase: INTEGER
  • HsqlDatabase: INT
  • FirebirdDatabase: INT
  • DerbyDatabase: INTEGER
  • InformixDatabase: INT
  • SybaseDatabase: INT
  • SybaseASADatabase: INT

2.2.3 mediumint

  • MySQLDatabase: MEDIUMINT
  • SQLiteDatabase: MEDIUMINT
  • H2Database: MEDIUMINT
  • PostgresDatabase: MEDIUMINT
  • UnsupportedDatabase: MEDIUMINT
  • DB2Database: MEDIUMINT
  • MSSQLDatabase: [int]
  • OracleDatabase: MEDIUMINT
  • HsqlDatabase: MEDIUMINT
  • FirebirdDatabase: MEDIUMINT
  • DerbyDatabase: MEDIUMINT
  • InformixDatabase: MEDIUMINT
  • SybaseDatabase: MEDIUMINT
  • SybaseASADatabase: MEDIUMINT

2.2.4 bigint

  • MySQLDatabase: BIGINT
  • SQLiteDatabase: BIGINT
  • H2Database: BIGINT
  • PostgresDatabase: BIGINT
  • UnsupportedDatabase: BIGINT
  • DB2Database: BIGINT
  • MSSQLDatabase: [bigint]
  • OracleDatabase: NUMBER(38, 0)
  • HsqlDatabase: BIGINT
  • FirebirdDatabase: BIGINT
  • DerbyDatabase: BIGINT
  • InformixDatabase: INT8
  • SybaseDatabase: BIGINT
  • SybaseASADatabase: BIGINT

2.2.5 number

  • MySQLDatabase: numeric
  • SQLiteDatabase: NUMBER
  • H2Database: NUMBER
  • PostgresDatabase: numeric
  • UnsupportedDatabase: NUMBER
  • DB2Database: numeric
  • MSSQLDatabase: [numeric](18, 0)
  • OracleDatabase: NUMBER
  • HsqlDatabase: numeric
  • FirebirdDatabase: numeric
  • DerbyDatabase: numeric
  • InformixDatabase: numeric
  • SybaseDatabase: numeric
  • SybaseASADatabase: numeric

2.3 小数类型

2.3.1 float

  • MySQLDatabase: FLOAT
  • SQLiteDatabase: FLOAT
  • H2Database: FLOAT
  • PostgresDatabase: FLOAT
  • UnsupportedDatabase: FLOAT
  • DB2Database: FLOAT
  • MSSQLDatabase: [float](53)
  • OracleDatabase: FLOAT
  • HsqlDatabase: FLOAT
  • FirebirdDatabase: FLOAT
  • DerbyDatabase: FLOAT
  • InformixDatabase: FLOAT
  • SybaseDatabase: FLOAT
  • SybaseASADatabase: FLOAT

2.3.2 double

  • MySQLDatabase: DOUBLE
  • SQLiteDatabase: DOUBLE
  • H2Database: DOUBLE
  • PostgresDatabase: DOUBLE PRECISION
  • UnsupportedDatabase: DOUBLE
  • DB2Database: DOUBLE
  • MSSQLDatabase: [float](53)
  • OracleDatabase: FLOAT(24)
  • HsqlDatabase: DOUBLE
  • FirebirdDatabase: DOUBLE PRECISION
  • DerbyDatabase: DOUBLE
  • InformixDatabase: DOUBLE PRECISION
  • SybaseDatabase: DOUBLE
  • SybaseASADatabase: DOUBLE

2.3.3 decimal

  • MySQLDatabase: DECIMAL
  • SQLiteDatabase: DECIMAL
  • H2Database: DECIMAL
  • PostgresDatabase: DECIMAL
  • UnsupportedDatabase: DECIMAL
  • DB2Database: DECIMAL
  • MSSQLDatabase: [decimal](18, 0)
  • OracleDatabase: DECIMAL
  • HsqlDatabase: DECIMAL
  • FirebirdDatabase: DECIMAL
  • DerbyDatabase: DECIMAL
  • InformixDatabase: DECIMAL
  • SybaseDatabase: DECIMAL
  • SybaseASADatabase: DECIMAL

2.3.4 currency

  • MySQLDatabase: DECIMAL
  • SQLiteDatabase: REAL
  • H2Database: DECIMAL
  • PostgresDatabase: DECIMAL
  • UnsupportedDatabase: DECIMAL
  • DB2Database: DECIMAL(19, 4)
  • MSSQLDatabase: [money]
  • OracleDatabase: NUMBER(15, 2)
  • HsqlDatabase: DECIMAL
  • FirebirdDatabase: DECIMAL(18, 4)
  • DerbyDatabase: DECIMAL
  • InformixDatabase: MONEY
  • SybaseDatabase: MONEY
  • SybaseASADatabase: MONEY

2.4 字符串类型

2.4.1 char

  • MySQLDatabase: CHAR
  • SQLiteDatabase: CHAR
  • H2Database: CHAR
  • PostgresDatabase: CHAR
  • UnsupportedDatabase: CHAR
  • DB2Database: CHAR
  • MSSQLDatabase: [char](1)
  • OracleDatabase: CHAR
  • HsqlDatabase: CHAR
  • FirebirdDatabase: CHAR
  • DerbyDatabase: CHAR
  • InformixDatabase: CHAR
  • SybaseDatabase: CHAR
  • SybaseASADatabase: CHAR

2.4.2 varchar

  • MySQLDatabase: VARCHAR
  • SQLiteDatabase: VARCHAR
  • H2Database: VARCHAR
  • PostgresDatabase: VARCHAR
  • UnsupportedDatabase: VARCHAR
  • DB2Database: VARCHAR
  • MSSQLDatabase: [varchar](1)
  • OracleDatabase: VARCHAR2
  • HsqlDatabase: VARCHAR
  • FirebirdDatabase: VARCHAR
  • DerbyDatabase: VARCHAR
  • InformixDatabase: VARCHAR
  • SybaseDatabase: VARCHAR
  • SybaseASADatabase: VARCHAR

2.4.3 nchar

  • MySQLDatabase: NCHAR
  • SQLiteDatabase: NCHAR
  • H2Database: NCHAR
  • PostgresDatabase: NCHAR
  • UnsupportedDatabase: NCHAR
  • DB2Database: NCHAR
  • MSSQLDatabase: [nchar](1)
  • OracleDatabase: NCHAR
  • HsqlDatabase: CHAR
  • FirebirdDatabase: NCHAR
  • DerbyDatabase: NCHAR
  • InformixDatabase: NCHAR
  • SybaseDatabase: NCHAR
  • SybaseASADatabase: NCHAR

2.4.4 nvarchar

  • MySQLDatabase: NVARCHAR
  • SQLiteDatabase: NVARCHAR
  • H2Database: NVARCHAR
  • PostgresDatabase: VARCHAR
  • UnsupportedDatabase: NVARCHAR
  • DB2Database: NVARCHAR
  • MSSQLDatabase: [nvarchar](1)
  • OracleDatabase: NVARCHAR2
  • HsqlDatabase: VARCHAR
  • FirebirdDatabase: NVARCHAR
  • DerbyDatabase: VARCHAR
  • InformixDatabase: NVARCHAR
  • SybaseDatabase: NVARCHAR
  • SybaseASADatabase: NVARCHAR

2.5 日期和时间类型

2.5.1 datetime

  • MySQLDatabase: datetime
  • SQLiteDatabase: TEXT
  • H2Database: TIMESTAMP
  • PostgresDatabase: TIMESTAMP WITHOUT TIME ZONE
  • UnsupportedDatabase: datetime
  • DB2Database: TIMESTAMP
  • MSSQLDatabase: [datetime]
  • OracleDatabase: TIMESTAMP
  • HsqlDatabase: TIMESTAMP
  • FirebirdDatabase: TIMESTAMP
  • DerbyDatabase: TIMESTAMP
  • InformixDatabase: DATETIME YEAR TO FRACTION(5)
  • SybaseDatabase: datetime
  • SybaseASADatabase: datetime

2.5.2 time

  • MySQLDatabase: time
  • SQLiteDatabase: time
  • H2Database: time
  • PostgresDatabase: TIME WITHOUT TIME ZONE
  • UnsupportedDatabase: time
  • DB2Database: time
  • MSSQLDatabase: [time](7)
  • OracleDatabase: DATE
  • HsqlDatabase: time
  • FirebirdDatabase: time
  • DerbyDatabase: time
  • InformixDatabase: INTERVAL HOUR TO FRACTION(5)
  • SybaseDatabase: time
  • SybaseASADatabase: time

2.5.3 timestamp

  • MySQLDatabase: timestamp
  • SQLiteDatabase: TEXT
  • H2Database: TIMESTAMP
  • PostgresDatabase: TIMESTAMP WITHOUT TIME ZONE
  • UnsupportedDatabase: timestamp
  • DB2Database: timestamp
  • MSSQLDatabase: [datetime]
  • OracleDatabase: TIMESTAMP
  • HsqlDatabase: TIMESTAMP
  • FirebirdDatabase: TIMESTAMP
  • DerbyDatabase: TIMESTAMP
  • InformixDatabase: DATETIME YEAR TO FRACTION(5)
  • SybaseDatabase: datetime
  • SybaseASADatabase: timestamp

2.5.4 date

  • MySQLDatabase: date
  • SQLiteDatabase: date
  • H2Database: date
  • PostgresDatabase: date
  • UnsupportedDatabase: date
  • DB2Database: date
  • MSSQLDatabase: [date]
  • OracleDatabase: date
  • HsqlDatabase: date
  • FirebirdDatabase: date
  • DerbyDatabase: date
  • InformixDatabase: date
  • SybaseDatabase: date
  • SybaseASADatabase: date

2.6 其他数据类型

2.6.1 blob

  • MySQLDatabase: LONGBLOB
  • SQLiteDatabase: BLOB
  • H2Database: BLOB
  • PostgresDatabase: BYTEA
  • UnsupportedDatabase: BLOB
  • DB2Database: BLOB
  • MSSQLDatabase: [varbinary](MAX)
  • OracleDatabase: BLOB
  • HsqlDatabase: BLOB
  • FirebirdDatabase: BLOB
  • DerbyDatabase: BLOB
  • InformixDatabase: BLOB
  • SybaseDatabase: IMAGE
  • SybaseASADatabase: LONG BINARY

2.6.2 clob

  • MySQLDatabase: LONGTEXT
  • SQLiteDatabase: TEXT
  • H2Database: CLOB
  • PostgresDatabase: TEXT
  • UnsupportedDatabase: CLOB
  • DB2Database: CLOB
  • MSSQLDatabase: [varchar](MAX)
  • OracleDatabase: CLOB
  • HsqlDatabase: CLOB
  • FirebirdDatabase: BLOB SUB_TYPE TEXT
  • DerbyDatabase: CLOB
  • InformixDatabase: CLOB
  • SybaseDatabase: TEXT
  • SybaseASADatabase: LONG VARCHAR

2.6.3 function

  • MySQLDatabase: FUNCTION
  • SQLiteDatabase: FUNCTION
  • H2Database: FUNCTION
  • PostgresDatabase: FUNCTION
  • UnsupportedDatabase: FUNCTION
  • DB2Database: FUNCTION
  • MSSQLDatabase: [function]
  • OracleDatabase: FUNCTION
  • HsqlDatabase: FUNCTION
  • FirebirdDatabase: FUNCTION
  • DerbyDatabase: FUNCTION
  • InformixDatabase: FUNCTION
  • SybaseDatabase: FUNCTION
  • SybaseASADatabase: FUNCTION

2.6.4 UNKNOWN

  • MySQLDatabase: UNKNOWN
  • SQLiteDatabase: UNKNOWN
  • H2Database: UNKNOWN
  • PostgresDatabase: UNKNOWN
  • UnsupportedDatabase: UNKNOWN
  • DB2Database: UNKNOWN
  • MSSQLDatabase: [UNKNOWN]
  • OracleDatabase: UNKNOWN
  • HsqlDatabase: UNKNOWN
  • FirebirdDatabase: UNKNOWN
  • DerbyDatabase: UNKNOWN
  • InformixDatabase: UNKNOWN
  • SybaseDatabase: UNKNOWN
  • SybaseASADatabase: UNKNOWN

2.6.5 uuid

  • MySQLDatabase: char(36)
  • SQLiteDatabase: TEXT
  • H2Database: UUID
  • PostgresDatabase: UUID
  • UnsupportedDatabase: char(36)
  • DB2Database: char(36)
  • MSSQLDatabase: [uniqueidentifier]
  • OracleDatabase: RAW(16)
  • HsqlDatabase: char(36)
  • FirebirdDatabase: char(36)
  • DerbyDatabase: char(36)
  • InformixDatabase: char(36)
  • SybaseDatabase: UNIQUEIDENTIFIER
  • SybaseASADatabase: UNIQUEIDENTIFIER
如果对你有用的话,可以打赏哦
打赏
ali pay
wechat pay

本文作者:蒋固金

本文链接:

版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!