复古 护眼 海天 深邃 暗黑 默认

CONVERT YAML CONFIGURATION

描述

CONVERT YAML CONFIGURATION 语法用于将 YAML 配置转换为对应的 DistSQL RDL 语句。

语法

convertYamlConfiguration ::=
  'CONVERT' 'YAML' 'CONFIGURATION' 'FROM' 'FILE' filePath

filePath ::=
  string

补充说明

  • CONVERT YAML CONFIGURATION 语法仅读取 YAML 文件并将配置转换为 DistSQL 语句,不会影响当前元数据;
  • 当 YAML 中 dataSources 为空时,不会进行 rules 的转换。

示例

mysql> CONVERT YAML CONFIGURATION FROM FILE '/xxx/config_sharding_db.yaml';
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| dist_sql                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| CREATE DATABASE sharding_db;
USE sharding_db;

REGISTER STORAGE UNIT ds_0 (
URL='jdbc:mysql://127.0.0.1:3306/demo_ds_0?serverTimezone=UTC&useSSL=false&allowPublicKeyRetrieval=true',
USER='root',
PASSWORD='123456',
PROPERTIES('maxPoolSize'='10')
), ds_1 (
URL='jdbc:mysql://127.0.0.1:3306/demo_ds_1?serverTimezone=UTC&useSSL=false&allowPublicKeyRetrieval=true',
USER='root',
PASSWORD='123456',
PROPERTIES('maxPoolSize'='10')
);

CREATE SHARDING TABLE RULE t_order (
STORAGE_UNITS(ds_0,ds_1),
SHARDING_COLUMN=order_id,
TYPE(NAME='mod', PROPERTIES('sharding-count'='4')),
KEY_GENERATE_STRATEGY(COLUMN=order_id, TYPE(NAME='snowflake'))
);

|
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.02 sec)

保留字

CONVERTYAMLCONFIGURATIONFROMFILE

相关链接