典型现象就是没有配置在分表规则中的所有表执行SQL会报错:Table or view 'xxx' does not exist
这是因为 ShardingSphere 更新配置文件格式导致的,参考文档 https://shardingsphere.apache.org/document/current/en/user-manual/shardingsphere-jdbc/yaml-config/rules/single/
只需要添加以下设置
rules:
- !SINGLE
tables:
# MySQL 格式
- ds_0.t_single # 指定单表
- ds_1.* # 指定 ds_1 的所有表
- "*.*" # 所有所有库的所有表
# PostgreSQL 格式
- ds_0.public.t_config
- ds_1.public.*
- ds_2.*.*
- "*.*.*"
defaultDataSource: ds_0 # 执行创建表语句时的默认数据源。默认null,表示随机单播路由.
发表回复