Single Table

Background

Single rule is used to specify which single tables need to be managed by ShardingSphere, or to set the default single table data source.

Parameters

Class:org.apache.shardingsphere.single.api.config.SingleRuleConfiguration

Attributes:

nameDataTypeDescriptionDefault Value
tables (+)Collection<String>single tables-
defaultDataSource (?)Stringsingle table default data source-

Procedure

  1. Initialize SingleRuleConfiguration;
  2. Add a single table to be loaded and configure the default data source.

Sample

  1. SingleRuleConfiguration ruleConfig = new SingleRuleConfiguration();
  2. ShardingSphereDataSourceFactory.createDataSource(createDataSourceMap(), Arrays.asList(ruleConfig), new Properties());