Project: ShardingSphere (App Definition and Development / Database)
File: show-sharding-table-rule.en.md

+++ title = "SHOW SHARDING TABLE RULE" weight = 1 +++ The `SHOW SHARDING TABLE RULE` syntax is used to query the sharding table rule in the specified database. {{< tabs >}} {{% tab name="Grammar" %}} ```sql ShowShardingTableRule ::= 'SHOW' 'SHARDING' 'TABLE' ('RULE' tableName | 'RULES') ('FROM' databaseName)? tableName ::= identifier databaseName ::= identifier ``` {{% /tab %}} {{% tab name="Railroad diagram" %}} <iframe frameborder="0" name="diagram" id="diagram" width="100%" height="100%"></iframe> {{% /tab %}} {{< /tabs >}} When `databaseName` is not specified, the default is the currently used `DATABASE`. If `DATABASE` is not used, `No database selected` will be prompted. | Column | Description | |--|--| | table | Logical table name | | actualdatanodes | Actual data node | | actualdatasources | Actual data source (Displayed when creating rules by RDL) | | databasestrategytype | Database sharding strategy type | | databaseshardingcolumn | Database sharding column | | databaseshardingalgorithm_type | Database sharding algorithm type | | databaseshardingalgorithm_props | Database sharding algorithm properties | | tablestrategytype | Table sharding strategy type | | tableshardingcolumn | Table sharding column | | tableshardingalgorithm_type | Table sharding algorithm type | | tableshardingalgorithm_props | Table sharding algorithm properties | | keygeneratecolumn | Sharding key generator column | | keygeneratortype | Sharding key generator type | | keygeneratorprops | Sharding key generator properties | Query the sharding table rules of the specified logical database ```sql SHOW SHARDING TABLE RULES FROM sharding_db; ``` ```sql +--+-+++--+-+--++--+-+--++--++ | table | actualdatanodes | actualdatasources | databasestrategytype | databaseshardingcolumn | databaseshardingalgorithmtype | databaseshardingalgorithmprops | tablestrategytype | tableshardingcolumn | tableshardingalgorithmtype | tableshardingalgorithmprops | keygeneratecolumn | keygeneratortype | keygeneratorprops | +--+-+++--+-+--++--+-+--++--++ | torder | | ds0,ds1 | | | | | mod | orderid | mod | sharding-count=4 | | | | | torderitem | | ds0,ds1 | | | | | mod | order_id | mod | sharding-count=4 | | | | +--+-+++--+-+--++--+-+--++--++ 2 rows in set (0.12 sec) ``` Query the sharding table rules of the current logic database ```sql SHOW SHARDING TABLE RULES; ``` ```sql +--+-+++--+-+--++--+-+--++--++ | table | actualdatanodes | actualdatasources | databasestrategytype | databaseshardingcolumn | databaseshardingalgorithmtype | databaseshardingalgorithmprops | tablestrategytype | tableshardingcolumn | tableshardingalgorithmtype | tableshardingalgorithmprops | keygeneratecolumn | keygeneratortype | keygeneratorprops | +--+-+++--+-+--++--+-+--++--++ | torder | | ds0,ds1 | | | | | mod | orderid | mod | sharding-count=4 | | | | | torderitem | | ds0,ds1 | | | | | mod | order_id | mod | sharding-count=4 | | | | +--+-+++--+-+--++--+-+--++--++ 2 rows in set (0.12 sec) ``` Query the specified sharding table rule ```sql SHOW SHARDING TABLE RULE t_order; ``` ```sql +--+-+++--+-+--++--+-+--++--++ | table | actualdatanodes | actualdatasources | databasestrategytype | databaseshardingcolumn | databaseshardingalgorithmtype | databaseshardingalgorithmprops | tablestrategytype | tableshardingcolumn | tableshardingalgorithmtype | tableshardingalgorithmprops | keygeneratecolumn | keygeneratortype | keygeneratorprops | +--+-+++--+-+--++--+-+--++--++ | torder | | ds0,ds1 | | | | | mod | orderid | mod | sharding-count=4 | | | | +--+-+++--+-+--++--+-+--++--++ 1 row in set (0.12 sec) ``` `SHOW`, `SHARDING`, `TABLE`, `RULE`, `FROM`