Run SQL changes across sharded databases
In a sharded database architecture, the same schema or data change often has to run across many databases or tables. NineData database groups help teams submit one SQL task and execute it consistently across the selected sharded databases.
Common Challenges
Sharded database changes are difficult to manage when teams rely on manual execution or one-off scripts:
- The same DDL or DML statement may need to run across many shards.
- Each data source requires connection handling, credentials, and execution tracking.
- Partial failures need to be captured and resolved without losing visibility.
- Scripts created for one change are often hard to reuse for the next change.
Solution Overview
NineData Database DevOps Professional Edition and later support database groups. A database group can include databases from different data sources. After the group is created, users can submit an SQL task against the group, and NineData plans and executes the statement across the member databases.

Prerequisites
Before you run a sharded database change, make sure that:
- All target data sources have been added to NineData.
- The target databases are ready to be added to a database group.
- You have permission to create database groups and submit SQL tasks.
- SQL development policies and approval processes are configured for the target environment.
Configure The Database Group
1. Add Data Sources
Add every data source that contains a sharded database to NineData.

2. Create A Database Group
Add the sharded databases from the relevant data sources to one database group. In this example, the database group Poc_Shard_DB contains four sharded databases: poc_test01, poc_test02, poc_test03, and poc_test04 from the data sources MySQL-POC1 and MySQL-POC2.

Run A SQL Task Against The Group
Create an SQL task, select the database group, and enter the SQL statement. This example adds an
agecolumn to thePoc_Shard_DBdatabase group.
Review the execution plan generated by NineData. The system identifies the target databases and checks the SQL against the configured development standards.

Submit the task for approval and select the approver.

After approval, execute the task. If execution fails on a shard, the task list shows the failed database so that you can investigate and retry.

Verify the target tables after execution.

Result
The SQL statement is executed across all databases in the selected database group. The task details provide a shared approval record, execution status, and failure visibility for the change.