eBook – Guide Spring Cloud – NPI EA (cat=Spring Cloud)
announcement - icon

Let's get started with a Microservice Architecture with Spring Cloud:

>> Join Pro and download the eBook

eBook – Mockito – NPI EA (tag = Mockito)
announcement - icon

Mocking is an essential part of unit testing, and the Mockito library makes it easy to write clean and intuitive unit tests for your Java code.

Get started with mocking and improve your application tests using our Mockito guide:

Download the eBook

eBook – Java Concurrency – NPI EA (cat=Java Concurrency)
announcement - icon

Handling concurrency in an application can be a tricky process with many potential pitfalls. A solid grasp of the fundamentals will go a long way to help minimize these issues.

Get started with understanding multi-threaded applications with our Java Concurrency guide:

>> Download the eBook

eBook – Reactive – NPI EA (cat=Reactive)
announcement - icon

Spring 5 added support for reactive programming with the Spring WebFlux module, which has been improved upon ever since. Get started with the Reactor project basics and reactive programming in Spring Boot:

>> Join Pro and download the eBook

eBook – Java Streams – NPI EA (cat=Java Streams)
announcement - icon

Since its introduction in Java 8, the Stream API has become a staple of Java development. The basic operations like iterating, filtering, mapping sequences of elements are deceptively simple to use.

But these can also be overused and fall into some common pitfalls.

To get a better understanding on how Streams work and how to combine them with other language features, check out our guide to Java Streams:

>> Join Pro and download the eBook

eBook – Jackson – NPI EA (cat=Jackson)
announcement - icon

Do JSON right with Jackson

Download the E-book

eBook – HTTP Client – NPI EA (cat=Http Client-Side)
announcement - icon

Get the most out of the Apache HTTP Client

Download the E-book

eBook – Maven – NPI EA (cat = Maven)
announcement - icon

Get Started with Apache Maven:

Download the E-book

eBook – Persistence – NPI EA (cat=Persistence)
announcement - icon

Working on getting your persistence layer right with Spring?

Explore the eBook

eBook – RwS – NPI EA (cat=Spring MVC)
announcement - icon

Building a REST API with Spring?

Download the E-book

Course – LS – NPI EA (cat=Jackson)
announcement - icon

Get started with Spring and Spring Boot, through the Learn Spring course:

>> LEARN SPRING
Course – RWSB – NPI EA (cat=REST)
announcement - icon

Explore Spring Boot 3 and Spring 6 in-depth through building a full REST API with the framework:

>> The New “REST With Spring Boot”

Course – LSS – NPI EA (cat=Spring Security)
announcement - icon

Yes, Spring Security can be complex, from the more advanced functionality within the Core to the deep OAuth support in the framework.

I built the security material as two full courses - Core and OAuth, to get practical with these more complex scenarios. We explore when and how to use each feature and code through it on the backing project.

You can explore the course here:

>> Learn Spring Security

Course – LSD – NPI EA (tag=Spring Data JPA)
announcement - icon

Spring Data JPA is a great way to handle the complexity of JPA with the powerful simplicity of Spring Boot.

Get started with Spring Data JPA through the guided reference course:

>> CHECK OUT THE COURSE

Partner – Moderne – NPI EA (cat=Spring Boot)
announcement - icon

Refactor Java code safely — and automatically — with OpenRewrite.

Refactoring big codebases by hand is slow, risky, and easy to put off. That’s where OpenRewrite comes in. The open-source framework for large-scale, automated code transformations helps teams modernize safely and consistently.

Each month, the creators and maintainers of OpenRewrite at Moderne run live, hands-on training sessions — one for newcomers and one for experienced users. You’ll see how recipes work, how to apply them across projects, and how to modernize code with confidence.

Join the next session, bring your questions, and learn how to automate the kind of work that usually eats your sprint time.

Course – LJB – NPI EA (cat = Core Java)
announcement - icon

Code your way through and build up a solid, practical foundation of Java:

>> Learn Java Basics

Partner – LambdaTest – NPI EA (cat= Testing)
announcement - icon

Distributed systems often come with complex challenges such as service-to-service communication, state management, asynchronous messaging, security, and more.

Dapr (Distributed Application Runtime) provides a set of APIs and building blocks to address these challenges, abstracting away infrastructure so we can focus on business logic.

In this tutorial, we'll focus on Dapr's pub/sub API for message brokering. Using its Spring Boot integration, we'll simplify the creation of a loosely coupled, portable, and easily testable pub/sub messaging system:

>> Flexible Pub/Sub Messaging With Spring Boot and Dapr

1. Introduction

In this article, we’ll explore the various SQL data types supported by Liquibase. We’ll also examine how they are represented across databases such as MySQL, PostgreSQL, Oracle, and more.

2. What Is Liquibase

Liquibase is an open-source database schema change management tool that helps track, version, and deploy database changes. It’s commonly used in Java applications to automate database migrations. With Liquibase, we can manage database changes the same way we manage application code. This helps speed up continuous integration and delivery and maintains version control over database changes.

2.1. Using Liquibase in a Project

To use Liquibase in our project, we first need to add the latest liquibase-core dependency in our Maven pom.xml file:

<dependency> 
    <groupId>org.liquibase</groupId>
    <artifactId>liquibase-core</artifactId>
    <version>4.27.0</version> 
</dependency>

Liquibase supports a wide variety of databases such as MySQL, PostgreSQL, Oracle, and many others. Once our database is ready, we utilize a liquibase.properties file to define the connection settings. The properties file contains fields such as the database host URL, connection credentials, and driver information:

changeLogFile=db/changelog/db.changelog-master.yaml
url=jdbc:mysql://localhost:3306/mydatabase
username=dbuser
password=dbpassword
driver=com.mysql.cj.jdbc.Driver

The most important step comes next, where we define a changelog file.

2.2. The Changelog File

A changelog file acts as a single source of truth and stores the history of the changes in our database over time. The changelog file can be of any format, with the most common formats being SQL, XML, JSON, and YAML.

We should note that changelogs on an existing database can be generated automatically with Maven:

mvn liquibase:generateChangeLog

Let’s take a better look at the changelog file. A changelog consists of a sequence of changesets, each having an identifier (id). A single changeset describes an individual modification to the database. Liquibase supports a plethora of DML changes such as:

  • createTable
  • addColumn
  • dropColumn
  • update
  • insert
  • sql (for custom SQL)

Here’s an example changelog written in XML:

<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
    http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd">

    <changeSet id="1" author="baeldung">
        <createTable tableName="baeldung_articles">
            <column name="id" type="int">
                <constraints primaryKey="true" nullable="false"/>
            </column>
            <column name="name" type="varchar(255)"/>
        </createTable>
    </changeSet>

    <changeSet id="2" author="baeldung">
        <addColumn tableName="baeldung_authors">
            <column name="name" type="varchar(255)"/>
        </addColumn>
    </changeSet>
</databaseChangeLog>

2.3. Structure of an Individual Changeset

An individual changeset header contains the following attributes:

  • id: This is a mandatory attribute required to identify the changeset. This can be any alphanumeric value.
  • author: The identifier of the changeset‘s author goes here.
  • context: This is an optional field mainly used to specify the environment it should run on (development, production).
  • label: This is another optional field and can be used to supply additional context around the change.

The change itself can be broken down into several types of database modifications. Some of the common changes that we can use are:

  • createTable
  • addColumn
  • dropTable
  • insert

Liquibase offers transactional support for changesets under a changelog. Therefore, if an individual changeset fails, the entire changelog rolls back. 

3. SQL Data Types Support in Liquibase

Liquibase in Java supports a plethora of databases. However, it’s important to acknowledge that databases support database data types differently. For example, a character data type might vary in size and name across multiple databases. Some databases might support UUID natively while others might rely on character or string types to store such values.

3.1. The Need for Uniformity in Data Types

Liquibase offers change management solutions for databases. Therefore, Liquibase needs to support database independence. This is achievable only if Liquibase can standardize data types across all the supported databases. A single changeset should be able to execute regardless of the underlying database. Developers should also be able to create a changeset without much concern for the database platform it might run on. 

3.2. Database Independence

Liquibase offers true database independence by implementing three solutions:

  • Standardized Databases: Liquibase defines a standard set of data types most widely used across various database platforms like int, timestamp, and text. Developers can freely use these data types without thinking about the underlying database in use. 
  • Automatic Conversion of data types: Liquibase automatically converts the data type to a platform-specific one. For example, a text Liquibase type will be automatically converted into clob in Oracle database and varchar in SQL Server.
  • Configurable: Liquibase exposes an additional configurable parameter, convert-data-types. We supply this parameter if we do not want to perform automatic data type conversion. If this value is false, we must provide exact data types matching the target database.

3.3. Data Types Provided by Liquibase

Liquibase provides several data types for SQL out of the box:

bigint, blob, boolean, char, clob, currency, datetime, date, decimal, double, float, int, mediumint, nchar, nvarchar, number, smallint, time, timestamp, tinyint, uuid, varchar.

4. Conversion Chart for All the Liquibase Data Types

Liquibase manages the auto conversion of data types. However, it’s still a good practice for the developers to understand how the data type might map according to the host database. In this section, we’ll provide an exhaustive list of these mappings for the most commonly used data types:

Liquibase Data Type MySQL SQLite H2 Postgres DB2 SQL Server Oracle
BOOLEAN BIT(1) BOOLEAN BOOLEAN BOOLEAN SMALLINT BIT NUMBER(1)
TINYINT TINYINT TINYINT TINYINT SMALLINT SMALLINT TINYINT NUMBER(3)
INT INT INTEGER INT INT INTEGER INT INTEGER
MEDIUMINT MEDIUMINT MEDIUMINT MEDIUMINT MEDIUMINT MEDIUMINT INT MEDIUMINT
BIGINT BIGINT BIGINT BIGINT BIGINT BIGINT BIGINT NUMBER(38, 0)
FLOAT FLOAT FLOAT FLOAT FLOAT FLOAT FLOAT(53) FLOAT
DOUBLE DOUBLE DOUBLE DOUBLE DOUBLE PRECISION DOUBLE FLOAT(53) FLOAT(24)
DECIMAL DECIMAL DECIMAL DECIMAL DECIMAL DECIMAL DECIMAL(18, 0) DECIMAL
NUMBER NUMERIC NUMBER NUMBER NUMERIC NUMERIC NUMERIC(18, 0) NUMBER
BLOB LONGBLOB BLOB BLOB BYTEA BLOB VARBINARY BLOB
FUNCTION FUNCTION FUNCTION FUNCTION FUNCTION FUNCTION FUNCTION FUNCTION
DATETIME DATETIME TEXT TIMESTAMP TIMESTAMP WITHOUT TIME ZONE TIMESTAMP DATETIME TIMESTAMP
TIME TIME TIME TIME TIME WITHOUT TIME ZONE TIME TIME(7) DATE
TIMESTAMP TIMESTAMP TEXT TIMESTAMP TIMESTAMP WITHOUT TIME ZONE TIMESTAMP DATETIME TIMESTAMP
DATE DATE DATE DATE DATE DATE DATE DATE
CHAR CHAR CHAR CHAR CHAR CHAR CHAR(1) CHAR
VARCHAR VARCHAR VARCHAR VARCHAR VARCHAR VARCHAR VARCHAR VARCHAR2
NCHAR NCHAR NCHAR NCHAR NCHAR NCHAR NCHAR(1) NCHAR
NVARCHAR NVARCHAR NVARCHAR NVARCHAR VARCHAR NVARCHAR NVARCHAR(1) NVARCHAR2
CLOB LONGTEXT TEXT CLOB TEXT CLOB VARCHAR CLOB
CURRENCY DECIMAL REAL DECIMAL DECIMAL DECIMAL(19, 4) MONEY NUMBER(15, 2)
UUID CHAR(36) TEXT UUID UUID char(36) UNIQUEIDENTIFIER RAW(16)

5. List All Data Types Programmatically

We can employ a Java method to extract the compatibility of the different SQL types with Liquibase. We start by creating two lists. The first list stores the compatible databases supported by Liquibase:

private static List getDatabases() { 
    return List.of(
        new MySQLDatabase(), 
        new SQLiteDatabase(), 
        new H2Database(), 
        new PostgresDatabase(), 
        new DB2Database(), 
        new MSSQLDatabase(), 
        new OracleDatabase(), 
        new HsqlDatabase(), 
        new FirebirdDatabase(), 
        new DerbyDatabase(), 
        new InformixDatabase(), 
        new SybaseDatabase(), 
        new SybaseASADatabase()
    ); 
}

The second list stores the exhaustive list of datatypes that we want to check:

private static List<LiquibaseDataType> getDataTypes() {
    return List.of(
        new BooleanType(),
        new TinyIntType(),
        new IntType(),
        new MediumIntType(),
        new BigIntType(),
        new FloatType(),
        new DoubleType(),
        new DecimalType(),
        new NumberType(),
        new BlobType(),
        new DateTimeType(),
        new TimeType(),
        new TimestampType(),
        new DateType(),
        new CharType(),
        new VarcharType(),
        new NCharType(),
        new NVarcharType(),
        new ClobType(),
        new CurrencyType(),
        new UUIDType()
    );
}

Next, let’s iterate through the mentioned lists of Liquibase data types (dataTypes) and database types (databases) and try to convert each Liquibase data type into a database-specific data type for every database. We also print the data type’s name and database-specific type for every combination. Additionally, we handle exceptions gracefully to continue processing in case of errors:

List<LiquibaseDataType> dataTypes = getDataTypes();
List<AbstractJdbcDatabase> databases = getDatabases();

for (LiquibaseDataType dataTypeInstance : dataTypes) {
    try {
        LiquibaseDataType dataType = dataTypeInstance;
        dataType.finishInitialization("");
        System.out.println(dataType.getName());

        for (AbstractJdbcDatabase databaseInstance : databases) {
            try {
                Database database = databaseInstance;
                String databaseType = dataType.toDatabaseDataType(database)
                  .toString();
                System.out.println(databaseInstance.getName() + ": " + databaseType);
            } catch (Exception e) {
                System.err.println("Error initializing database class "
                            + databaseInstance.getName() + ": " + e.getMessage());
            }
        }
        System.out.println();
    } catch (Exception e) {
        System.err.println("Error initializing data type class "
                            + dataTypeInstance.getName() + ": " + e.getMessage());
    }
}

6. Conclusion

In this article, we looked at how Liquibase provides common data types and helps developers manage database versions.

The code backing this article is available on GitHub. Once you're logged in as a Baeldung Pro Member, start learning and coding on the project.
Baeldung Pro – NPI EA (cat = Baeldung)
announcement - icon

Baeldung Pro comes with both absolutely No-Ads as well as finally with Dark Mode, for a clean learning experience:

>> Explore a clean Baeldung

Once the early-adopter seats are all used, the price will go up and stay at $33/year.

eBook – HTTP Client – NPI EA (cat=HTTP Client-Side)
announcement - icon

The Apache HTTP Client is a very robust library, suitable for both simple and advanced use cases when testing HTTP endpoints. Check out our guide covering basic request and response handling, as well as security, cookies, timeouts, and more:

>> Download the eBook

eBook – Java Concurrency – NPI EA (cat=Java Concurrency)
announcement - icon

Handling concurrency in an application can be a tricky process with many potential pitfalls. A solid grasp of the fundamentals will go a long way to help minimize these issues.

Get started with understanding multi-threaded applications with our Java Concurrency guide:

>> Download the eBook

eBook – Java Streams – NPI EA (cat=Java Streams)
announcement - icon

Since its introduction in Java 8, the Stream API has become a staple of Java development. The basic operations like iterating, filtering, mapping sequences of elements are deceptively simple to use.

But these can also be overused and fall into some common pitfalls.

To get a better understanding on how Streams work and how to combine them with other language features, check out our guide to Java Streams:

>> Join Pro and download the eBook

eBook – Persistence – NPI EA (cat=Persistence)
announcement - icon

Working on getting your persistence layer right with Spring?

Explore the eBook

Course – LS – NPI EA (cat=REST)

announcement - icon

Get started with Spring Boot and with core Spring, through the Learn Spring course:

>> CHECK OUT THE COURSE

Partner – Moderne – NPI EA (tag=Refactoring)
announcement - icon

Modern Java teams move fast — but codebases don’t always keep up. Frameworks change, dependencies drift, and tech debt builds until it starts to drag on delivery. OpenRewrite was built to fix that: an open-source refactoring engine that automates repetitive code changes while keeping developer intent intact.

The monthly training series, led by the creators and maintainers of OpenRewrite at Moderne, walks through real-world migrations and modernization patterns. Whether you’re new to recipes or ready to write your own, you’ll learn practical ways to refactor safely and at scale.

If you’ve ever wished refactoring felt as natural — and as fast — as writing code, this is a good place to start.

eBook Jackson – NPI EA – 3 (cat = Jackson)