Sharding

Root Configuration

Class name: org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration

Attributes:

NameDataTypeDescriptionDefault Value
tables (+)Collection<ShardingTableRuleConfiguration>Sharding table rules-
autoTables (+)Collection<ShardingAutoTableRuleConfiguration>Sharding automatic table rules-
bindingTableGroups ()Collection<String>Binding table rulesEmpty
broadcastTables ()Collection<String>Broadcast table rulesEmpty
defaultDatabaseShardingStrategy (?)ShardingStrategyConfigurationDefault database sharding strategyNot sharding
defaultTableShardingStrategy (?)ShardingStrategyConfigurationDefault table sharding strategyNot sharding
defaultKeyGenerateStrategy (?)KeyGeneratorConfigurationDefault key generatorSnowflake
defaultShardingColumn (?)StringDefault sharding column nameNone
shardingAlgorithms (+)Map<String, ShardingSphereAlgorithmConfiguration>Sharding algorithm name and configurationsNone
keyGenerators (?)Map<String, ShardingSphereAlgorithmConfiguration>Key generate algorithm name and configurationsNone

Sharding Table Configuration

Class name: org.apache.shardingsphere.sharding.api.config.ShardingTableRuleConfiguration

Attributes:

NameDataTypeDescriptionDefault Value
logicTableStringName of sharding logic table-
actualDataNodes (?)StringDescribe data source names and actual tables, delimiter as point.
Multiple data nodes split by comma, support inline expression
Broadcast table or databases sharding only
databaseShardingStrategy (?)ShardingStrategyConfigurationDatabases sharding strategyUse default databases sharding strategy
tableShardingStrategy (?)ShardingStrategyConfigurationTables sharding strategyUse default tables sharding strategy
keyGenerateStrategy (?)KeyGeneratorConfigurationKey generator configurationUse default key generator

Sharding Automatic Table Configuration

Class name: org.apache.shardingsphere.sharding.api.config.ShardingAutoTableRuleConfiguration

Attributes:

NameDataTypeDescriptionDefault Value
logicTableStringName of sharding logic table-
actualDataSources (?)StringData source names.
Multiple data nodes split by comma
Use all configured data sources
shardingStrategy (?)ShardingStrategyConfigurationSharding strategyUse default sharding strategy
keyGenerateStrategy (?)KeyGeneratorConfigurationKey generator configurationUse default key generator

Sharding Strategy Configuration

Standard Sharding Strategy Configuration

Class name: org.apache.shardingsphere.sharding.api.config.strategy.sharding.StandardShardingStrategyConfiguration

Attributes:

NameDataTypeDescription
shardingColumnStringSharding column name
shardingAlgorithmNameStringSharding algorithm name

Complex Sharding Strategy Configuration

Class name: org.apache.shardingsphere.sharding.api.config.strategy.sharding.ComplexShardingStrategyConfiguration

Attributes:

NameDataTypeDescription
shardingColumnsStringSharding column name, separated by commas
shardingAlgorithmNameStringSharding algorithm name

Hint Sharding Strategy Configuration

Class name: org.apache.shardingsphere.sharding.api.config.strategy.sharding.HintShardingStrategyConfiguration

Attributes:

NameDataTypeDescription
shardingAlgorithmNameStringSharding algorithm name

None Sharding Strategy Configuration

Class name: org.apache.shardingsphere.sharding.api.config.strategy.sharding.NoneShardingStrategyConfiguration

Attributes: None

Please refer to Built-in Sharding Algorithm List for more details about type of algorithm.

Key Generate Strategy Configuration

Class name: org.apache.shardingsphere.sharding.api.config.strategy.keygen.KeyGenerateStrategyConfiguration

Attributes:

NameDataTypeDescription
columnStringColumn name of key generate
keyGeneratorNameStringkey generate algorithm name

Please refer to Built-in Key Generate Algorithm List for more details about type of algorithm.