SHOW SHARDING TABLE RULE

描述

SHOW SHARDING TABLE RULE 语法用于查询指定逻辑库中的分片规则。

语法

语法 铁路图

  1. ShowShardingTableRule ::=
  2. 'SHOW' 'SHARDING' 'TABLE' ('RULE' tableName | 'RULES') ('FROM' databaseName)?
  3. tableName ::=
  4. identifier
  5. databaseName ::=
  6. identifier

补充说明

  • 未指定 databaseName 时,默认是当前使用的 DATABASE。 如果也未使用 DATABASE 则会提示 No database selected

返回值说明

说明
table逻辑表名
actual_data_nodes实际的数据节点
actual_data_sources实际的数据源(通过 RDL 创建的规则时显示)
database_strategy_type数据库分片策略类型
database_sharding_column数据库分片键
database_sharding_algorithm_type数据库分片算法类型
database_sharding_algorithm_props数据库分片算法参数
table_strategy_type表分片策略类型
table_sharding_column表分片键
table_sharding_algorithm_type表分片算法类型
table_sharding_algorithm_props表分片算法参数
key_generate_column分布式主键生成列
key_generator_type分布式主键生成器类型
key_generator_props分布式主键生成器参数

示例

  • 查询指定逻辑库的分片规则
  1. SHOW SHARDING TABLE RULES FROM sharding_db;
  1. +--------------+-------------------+---------------------+------------------------+--------------------------+----------------------------------+-----------------------------------+---------------------+-----------------------+-------------------------------+--------------------------------+---------------------+--------------------+---------------------+
  2. | table | actual_data_nodes | actual_data_sources | database_strategy_type | database_sharding_column | database_sharding_algorithm_type | database_sharding_algorithm_props | table_strategy_type | table_sharding_column | table_sharding_algorithm_type | table_sharding_algorithm_props | key_generate_column | key_generator_type | key_generator_props |
  3. +--------------+-------------------+---------------------+------------------------+--------------------------+----------------------------------+-----------------------------------+---------------------+-----------------------+-------------------------------+--------------------------------+---------------------+--------------------+---------------------+
  4. | t_order | | ds_0,ds_1 | | | | | mod | order_id | mod | sharding-count=4 | | | |
  5. | t_order_item | | ds_0,ds_1 | | | | | mod | order_id | mod | sharding-count=4 | | | |
  6. +--------------+-------------------+---------------------+------------------------+--------------------------+----------------------------------+-----------------------------------+---------------------+-----------------------+-------------------------------+--------------------------------+---------------------+--------------------+---------------------+
  7. 2 rows in set (0.12 sec)
  • 查询当前逻辑库的分片规则
  1. SHOW SHARDING TABLE RULES;
  1. +--------------+-------------------+---------------------+------------------------+--------------------------+----------------------------------+-----------------------------------+---------------------+-----------------------+-------------------------------+--------------------------------+---------------------+--------------------+---------------------+
  2. | table | actual_data_nodes | actual_data_sources | database_strategy_type | database_sharding_column | database_sharding_algorithm_type | database_sharding_algorithm_props | table_strategy_type | table_sharding_column | table_sharding_algorithm_type | table_sharding_algorithm_props | key_generate_column | key_generator_type | key_generator_props |
  3. +--------------+-------------------+---------------------+------------------------+--------------------------+----------------------------------+-----------------------------------+---------------------+-----------------------+-------------------------------+--------------------------------+---------------------+--------------------+---------------------+
  4. | t_order | | ds_0,ds_1 | | | | | mod | order_id | mod | sharding-count=4 | | | |
  5. | t_order_item | | ds_0,ds_1 | | | | | mod | order_id | mod | sharding-count=4 | | | |
  6. +--------------+-------------------+---------------------+------------------------+--------------------------+----------------------------------+-----------------------------------+---------------------+-----------------------+-------------------------------+--------------------------------+---------------------+--------------------+---------------------+
  7. 2 rows in set (0.12 sec)
  • 查询指定逻辑表的分片规则
  1. SHOW SHARDING TABLE RULE t_order;
  1. +--------------+-------------------+---------------------+------------------------+--------------------------+----------------------------------+-----------------------------------+---------------------+-----------------------+-------------------------------+--------------------------------+---------------------+--------------------+---------------------+
  2. | table | actual_data_nodes | actual_data_sources | database_strategy_type | database_sharding_column | database_sharding_algorithm_type | database_sharding_algorithm_props | table_strategy_type | table_sharding_column | table_sharding_algorithm_type | table_sharding_algorithm_props | key_generate_column | key_generator_type | key_generator_props |
  3. +--------------+-------------------+---------------------+------------------------+--------------------------+----------------------------------+-----------------------------------+---------------------+-----------------------+-------------------------------+--------------------------------+---------------------+--------------------+---------------------+
  4. | t_order | | ds_0,ds_1 | | | | | mod | order_id | mod | sharding-count=4 | | | |
  5. +--------------+-------------------+---------------------+------------------------+--------------------------+----------------------------------+-----------------------------------+---------------------+-----------------------+-------------------------------+--------------------------------+---------------------+--------------------+---------------------+
  6. 1 row in set (0.12 sec)

保留字

CREATESHARDINGTABLERULEFROM

相关链接