The SHOW SHARDING TABLE RULE syntax is used to query the sharding table rule in the specified schema.
ShowShardingTableRule ::=
'SHOW' 'SHARDING' 'TABLE' ('RULE' tableName | 'RULES') ('FROM' schemaName)?
tableName ::=
identifier
schemaName ::=
identifier
schemaName is not specified, the default is the currently used SCHEMA. If SCHEMA is not used, No database selected will be prompted.| Column | Description |
|---|---|
| table | Logical table name |
| actual_data_nodes | Actual data node |
| actual_data_sources | Actual data source (Displayed when creating rules by RDL) |
| database_strategy_type | Database sharding strategy type |
| database_sharding_column | Database sharding column |
| database_sharding_algorithm_type | Database sharding algorithm type |
| database_sharding_algorithm_props | Database sharding algorithm properties |
| table_strategy_type | Table sharding strategy type |
| table_sharding_column | Table sharding column |
| table_sharding_algorithm_type | Table sharding algorithm type |
| table_sharding_algorithm_props | Table sharding algorithm properties |
| key_generate_column | Sharding key generator column |
| key_generator_type | Sharding key generator type |
| key_generator_props | Sharding key generator properties |
SHOW SHARDING TABLE RULES FROM sharding_db;
+--------------+-------------------+---------------------+------------------------+--------------------------+----------------------------------+-----------------------------------+---------------------+-----------------------+-------------------------------+--------------------------------+---------------------+--------------------+---------------------+
| 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 |
+--------------+-------------------+---------------------+------------------------+--------------------------+----------------------------------+-----------------------------------+---------------------+-----------------------+-------------------------------+--------------------------------+---------------------+--------------------+---------------------+
| t_order | | ds_0,ds_1 | | | | | mod | order_id | mod | sharding-count=4 | | | |
| t_order_item | | ds_0,ds_1 | | | | | mod | order_id | mod | sharding-count=4 | | | |
+--------------+-------------------+---------------------+------------------------+--------------------------+----------------------------------+-----------------------------------+---------------------+-----------------------+-------------------------------+--------------------------------+---------------------+--------------------+---------------------+
2 rows in set (0.12 sec)
SHOW SHARDING TABLE RULES;
+--------------+-------------------+---------------------+------------------------+--------------------------+----------------------------------+-----------------------------------+---------------------+-----------------------+-------------------------------+--------------------------------+---------------------+--------------------+---------------------+
| 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 |
+--------------+-------------------+---------------------+------------------------+--------------------------+----------------------------------+-----------------------------------+---------------------+-----------------------+-------------------------------+--------------------------------+---------------------+--------------------+---------------------+
| t_order | | ds_0,ds_1 | | | | | mod | order_id | mod | sharding-count=4 | | | |
| t_order_item | | ds_0,ds_1 | | | | | mod | order_id | mod | sharding-count=4 | | | |
+--------------+-------------------+---------------------+------------------------+--------------------------+----------------------------------+-----------------------------------+---------------------+-----------------------+-------------------------------+--------------------------------+---------------------+--------------------+---------------------+
2 rows in set (0.12 sec)
SHOW SHARDING TABLE RULE t_order;
+--------------+-------------------+---------------------+------------------------+--------------------------+----------------------------------+-----------------------------------+---------------------+-----------------------+-------------------------------+--------------------------------+---------------------+--------------------+---------------------+
| 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 |
+--------------+-------------------+---------------------+------------------------+--------------------------+----------------------------------+-----------------------------------+---------------------+-----------------------+-------------------------------+--------------------------------+---------------------+--------------------+---------------------+
| t_order | | ds_0,ds_1 | | | | | mod | order_id | mod | sharding-count=4 | | | |
+--------------+-------------------+---------------------+------------------------+--------------------------+----------------------------------+-----------------------------------+---------------------+-----------------------+-------------------------------+--------------------------------+---------------------+--------------------+---------------------+
1 rows in set (0.12 sec)
