跪拜 Guibai
← All articles
Backend · Java · Programmer

dbswitch: Offline Bulk Migration to Nearly 30 Databases, DDL Auto-Generated

By SimonKing ·
Read original on juejin.cn ↗ Google Translate ↗ Alt translation

Teams maintaining hand-written migration scripts get one open-source tool that covers mainstream engines, the Chinese domestic database lineup, and common big data stores in a single pipeline. The 120-second minimum sync interval rules out near-real-time use cases; the tool moves data in batches, and real-time replication demands other plumbing.

Summary

dbswitch is an offline batch migration tool from the dromara community, written in Java and released under BSD. It is built for two jobs: moving data between databases and loading data into warehouses or lakes. Structure migration converts field types, primary keys, and table creation statements into target DDL, and regex rules remap table or field names during the move.

Data sync reads source rows through JDBC in batches and writes them with insert or copy statements, supporting full, incremental, and CDC modes. Tables with primary keys get insert/update/delete delta sync from row comparison. Coverage spans nearly 30 databases: MySQL, Oracle, SQL Server, PostgreSQL, DB2, MariaDB, SQLite, and Sybase; the Chinese domestic engines DM, Kingbase8, HighGo, Oscar, GBase8a, OpenGauss, and OceanBase; and big data stores such as Hive, ClickHouse, StarRocks, Doris, Greenplum, MongoDB, and Elasticsearch.

Deployment is Docker-first, with h2, MySQL, PostgreSQL, or OpenGauss as the config store. The Vue2 UI covers connections, tasks, monitoring, scheduling, and audit logs; a config.yml path runs headless. The practical constraint: sync runs only on a schedule, with a tested minimum interval of 120 seconds. This is batch data movement, not near-real-time replication.

Takeaways
— dbswitch is a pure-Java, BSD-licensed member project of the dromara open source community.
— Full, incremental, and CDC (changed-data) sync modes are supported.
— Structure migration auto-generates target DDL, converting field types, primary keys, and create-table statements; regex rules can remap table or field names.
— Nearly 30 database targets exist: MySQL, Oracle, SQL Server, PostgreSQL, DB2, MariaDB, SQLite, Sybase; DM, Kingbase8, HighGo, Oscar, GBase8a, OpenGauss, OceanBase; Hive, ClickHouse, StarRocks, Doris, Greenplum, MongoDB, Elasticsearch.
— A driver isolation architecture lets users extend to custom data sources.
— Two run modes exist: a Vue2 web UI (connections, tasks, monitoring, audit logs) and a config.yml command-line mode.
— Docker deployment takes a DBTYPE env var to pick h2, MySQL, PostgreSQL, or OpenGauss as the config store; default web login is admin/123456.
— Scheduled-task sync has a tested minimum interval of 120 seconds, so near-real-time sync is not supported.
— Against DBSyncer, dbswitch adds automatic table creation.
Conclusions

Incremental sync relies on row comparison for tables with primary keys rather than transaction logs, which fits the 120-second scheduling floor the author reports; near-real-time replication would need a different capture layer.

Domestic engines like DM, Kingbase8, HighGo, and GBase8a sit beside mainstream and big-data stores, so the compatibility list doubles as a map of China's data stack; the practical pitch targets shops mixing legacy engines with state-backed systems.

Positioned against DBSyncer, dbswitch wins on automatic table creation but loses on sync latency, which suggests migration tooling in this space is still chosen feature by feature rather than as a complete platform.

Concepts & terms
CDC
Change Data Capture. Tracking row changes (inserts, updates, deletes) in a source database so a target can mirror them. dbswitch implements it by comparing rows on tables with primary keys rather than reading transaction logs.
Driver isolation architecture
A design where each database driver loads in its own classloader so vendor JDBC drivers don't conflict, and new engines can be added via extensions without affecting existing ones.
dromara
A Chinese open source community that hosts multiple Java projects; dbswitch is one of its member projects.
Gitee
A Chinese Git hosting platform commonly used by Chinese projects alongside GitHub.
From the discussion
Featured comments
VallainMing

I've used Kingbase's kdts; there were failures migrating functions and views.

See top comments, translated →
Source: juejin.cn ↗ Google Translate ↗ Backup ↗