如下的语法,请用 DistSQL怎么写

rules:
  sharding:
    default-database-strategy:
      standard:
        sharding-column: site
        sharding-algorithm-name: databaseInline
    default-table-strategy:
      none:
    sharding-algorithms:
      databaseInline:
        type: INLINE
        props:
          algorithm-expression: ds$->{site}
    tables:
      student_info:
        logicTable: student_info

我想问下,下面这个规则,我在DistSQL中应该怎么写

tables:
  student_info:
    logicTable: student_info

我现在的DistSQL实现

create database demo;
use demo;

ADD RESOURCE demo1 (
    HOST=192.168.0.201,
    PORT=3306,
    DB=demo1,
    USER=root,
    PASSWORD=Longnows@888
);

ADD RESOURCE demo2 (
    HOST=192.168.0.201,
    PORT=3306,
    DB=demo2,
    USER=root,
    PASSWORD=Longnows@888
);

SHOW SCHEMA RESOURCES FROM demo;

DROP DEFAULT SHARDING DATABASE STRATEGY;
DROP SHARDING ALGORITHM database_inline;
CREATE SHARDING ALGORITHM database_inline (
	TYPE(NAME=inline,PROPERTIES("algorithm-expression"="demo${site}"))
);
CREATE DEFAULT SHARDING DATABASE STRATEGY (
	TYPE = standard,SHARDING_COLUMN=site,SHARDING_ALGORITHM=database_inline
);

SHOW SHARDING TABLE RULES;
DROP SHARDING TABLE RULE student_info;
CREATE SHARDING TABLE RULE student_info (
	datanodes("demo${1..2}.student_info")
)

SELECT * FROM student_info where site = 1;

我想实现的模式是多租户只分库不分表

tables:
  student_info:
    logicTable: student_info

这一段怎么转成DistSQL实现

现在最大的问题其实在这儿
datanodes(“demo${1…2}.student_info”)
实际的环境中我这个是一个 编码,可能不是连续的.我想使用
CREATE SHARDING TABLE RULE student_info (
DATANODES(“demo${site}.student_info”)
)
来代替,是不行的

inline 表达式不仅支持连续的数字,也支持枚举的形式,如:
datanodes("demo${[1,3]}") 表示 demo1demo3

image

只分库不分表这样配置可以生效,但是我不知道用DistSQL怎么实现?

京ICP备2021015875号