Logical table expressions define which physical tables belong to a logical table. Each expression describes a set of table names using range, step, enumeration, or cross-database notation.
DMS supports five categories of expressions:
Simple rules — sequential numeric suffixes
Multi-level rules — combinations of multiple ranges (Cartesian product)
Database and table rules — cross-database table distribution
Enumeration rules — discrete value lists
Enumeration rules for databases — enumeration across specific databases
Simple rules
Use simple rules to name tables with sequential numeric suffixes. The number of digits in the suffix is determined by the number of leading zeros in the expression.
| Syntax | Example | Generated tables |
|---|---|---|
[start-end] — natural order | test_[0-7] | test_0, test_1, test_2, test_3, test_4, test_5, test_6, test_7 |
[0start-0end] — zero-padded, 2 digits | test_[00-07] | test_00, test_01, test_02, test_03, test_04, test_05, test_06, test_07 |
[00start-00end] — zero-padded, 3 digits | test_[000-007] | test_000, test_001, test_002, test_003, test_004, test_005, test_006, test_007 |
[000start-000end] — zero-padded, 4 digits | test_[0000-0007] | test_0000, test_0001, test_0002, test_0003, test_0004, test_0005, test_0006, test_0007 |
[start-end:step] — range with step | test_[0-8:2] | test_0, test_2, test_4, test_6, test_8 |
[0start-0end:step] — zero-padded range with step | test_[00-07:3] | test_00, test_03, test_06 |
| Range in the middle of a name | test_[00-31]_t | test_00_t, test_01_t, ..., test_31_t |
Step is the increment between consecutive suffix values. For example, [0-8:2] starts at 0 and increments by 2, producing 0, 2, 4, 6, 8.
Multi-level rules
Use multi-level rules to combine two or more ranges in a single expression. Each pair of brackets defines an independent range. The expression generates the Cartesian product of all ranges — every combination of values from each bracket.
For example, [01-12]_[01-31] combines 12 month values with 31 date values, producing 12 × 31 = 372 unique table name suffixes.
| Syntax | Example | Generated tables |
|---|---|---|
| Two ranges | test_[01-12]_[01-31] | 12 × 31 = 372 tables: test_01_01, test_01_02, ..., test_12_31 |
| Two ranges with steps | test_[01-12:2]_[01-31:2] | 6 × 16 = 96 tables: odd months (01, 03, 05, 07, 09, 11) × odd dates (01, 03, ..., 31) |
Partitioned distribution across databases
The /n suffix divides a range into n equal groups and distributes each group to a separate database. Use this syntax to spread tables evenly across multiple databases in a single expression.
Example: alicom_billing_bill_[0000-0007].zw_add_month_[01-12]_[0000-0063/8]
This expression divides the suffix range 0000-0063 (64 values) into 8 groups of 8 and creates the following tables:
alicom_billing_bill_0000.zw_add_month_[01-12]_[0000-0007]alicom_billing_bill_0001.zw_add_month_[01-12]_[0008-0015]...
alicom_billing_bill_0007.zw_add_month_[01-12]_[0056-0063]
Database and table rules
Use database.table notation to define tables that span multiple databases. This is useful when horizontal sharding distributes tables across different database instances.
| Syntax | Example | Generated tables |
|---|---|---|
| Same table in multiple databases | db_[00-31].test | Table test in each of db_00, db_01, ..., db_31 (32 databases) |
| Tables evenly distributed across databases | db_[00-31].test[0000-1023] | 1,024 tables (test0000-test1023) evenly distributed across 32 databases (32 tables per database) |
Enumeration rules
Use enumeration rules to specify discrete suffix values instead of a continuous range. This is useful when your table naming does not follow a sequential pattern.
| Syntax | Example | Generated tables |
|---|---|---|
| Simple enumeration | test_[1,3,6,8,9] | test_1, test_3, test_6, test_8, test_9 |
| Multiple expressions | test_[1,3,6,8,9],test_[2,4,5,7,10] | Two sets of tables created and distributed together |
| Mixed range and enumeration | test_[1-9:2,10-20:2] | Odd values from 1-9 and even values from 10-20 |
Enumeration rules for databases
Use enumeration rules for databases to assign specific tables to specific databases. This is useful when different databases host different subsets of tables.
| Syntax | Example | Generated tables |
|---|---|---|
| Same tables in all specified databases | db_[00-31].test_[[00-31]] | Tables test_00 through test_31 in each of databases db_00 through db_31. The inner [[...]] treats the bracketed expression as a literal table name pattern rather than expanding it. |
| Different tables in different databases | db_01.test_[1,2,4,6,7],db_02.test_[2,3,5,7,9],db_03.test_[1,4,6,7,9] | 5 tables in db_01, 5 tables in db_02, 5 tables in db_03 |
| Different table counts per database | db_01.test_[1-7] and db_02.test_[10-15] | 7 tables in db_01 (test_1-test_7), 6 tables in db_02 (test_10-test_15) |
Expression syntax reference
| Element | Meaning | Example |
|---|---|---|
[start-end] | Continuous range, natural order | [0-7] → 0, 1, 2, 3, 4, 5, 6, 7 |
[0start-0end] | Zero-padded range | [00-07] → 00, 01, ..., 07 |
[start-end:step] | Range with step size | [0-8:2] → 0, 2, 4, 6, 8 |
[a,b,c] | Enumeration list | [1,3,6] → 1, 3, 6 |
[start-end/n] | Range divided into n equal groups | [0000-0063/8] → 8 groups of 8 |
[[expr]] | Literal expression in database notation | [[00-31]] → table name pattern [00-31] |
db.table | Database and table notation | db_[00-31].test |